This previous question had some good work arounds:
Angular 2 download PDF from API and Display it in View
but now that RC5 is out we can use arrayBuffer(). I can't seem to get anywhere with this. How do I go from this to a nice pdf blob:
return this._authHttp.get(this.fileUrl+id)
.map((res:Response) => res.arrayBuffer())
.subscribe(
data => {
console.log(data);
var blob = new Blob([data], {type: 'application/pdf'});
console.log(blob);
saveAs(blob, "testData.pdf");
},
err => console.error(err),
() => console.log('done')
);
data ends up being twice the size I would expect. Any ideas what I'm missing?
Thanks man...
This hack, change my life... thanks. But I make an light change.
I had same issue while downloading pdf files. I wasted two days to fix this but but got it working finally. U need to set the responseType to blob.
And dont forget to import ResponseContentType
Hope this helps you