In my angular 4 application I want to display a PDF, I found this good way: PDF Blob is not showing content, Angular 2
But in this way I open a new tab in the browser and for example in my case this new popup was blocked by adblock. So there is a way to show the PDF in the current tab? And something to avoid adblock?
Component.ts
print() {
this.ticketBundleService.downloadPDF().subscribe(
(res) => {
const fileURL = URL.createObjectURL(res);
window.open(fileURL);
}
);
}
Service.ts
downloadPDF(): any {
return this.http.get('http://......', {responseType: 'blob'}).map(
(res) => {
return new Blob([res], {type: 'application/pdf'})
})
}