Currently using
https://github.com/stranger82/angular-utf8-base64
and
https://github.com/eligrey/FileSaver.js/
to decode a base64 encoded PDF file which I am fetching from a rest API.
It decodes and downloads just fine, however when I try view it, it's blank.
I have looked at
AngularJS: Display blob (.pdf) in an angular app
and tried adding
responseType: 'arraybuffer'
to my get request however, this causes the response to be null with no data being returned from the get request.
Other files seem to download and render just fine.
Any help would be much appreciated as always!
Code:
function save() {
var fileContent = base64.decode(response.File.fileContent);
var file = new Blob([fileContent], {type: response.File.contentType});
saveAs(file, response.File.name);
}
$http.get(url.join('')).success(function(response) {
save(response);
}).error(function(error) {
console.log('The following error has occured' + error);
});