I use FileSaver.js and Blob.js in an Angular JS application to save the PDF returned by the REST service (which returns an array of bytes representing the file).
var headers = {headers: {"Authorization":"Bearer "+token, "Accept":"application/pdf"}}; $http.get(URL, headers) .success(function (data) { var blob = new Blob([data], {type: 'application/pdf'}); saveAs(blob, 'contract.pdf'); });
the file is saved with the correct type, and the number of pages is correct, but it is completely empty. Opening it with an editor, it turned out that it contains only the first part of the data returned by the server, for example, truncated.
Thank you all for your help!
source share