Having trouble opening a PDF from byte array sent by WebAPI.
This is my Service:
fetchPdfDocument(): Observable<any> {
return this.httpClient
.get(this.configuration.serverUrl + this.configuration.getPdfDoc, {
responseType: "arraybuffer" //tried with 'blob'
});
}
And here's what I have in my component:
this.service.fetchPdfDocument() .subscribe(data => { var file = new Blob([data], { type: 'application/pdf' }); this.pdfContent = URL.createObjectURL(file); window.open(this.pdfContent); })
However, when I run it, the PDF document fails to load. I've enabled pop-ups but still no luck...