At first, I want to open pdf as preview in new tab and then I want to download if I click download icon from that preview with specific name.
I want to change from
blob:http://localhost:4200/22102378-755e-45ba-8c3d-d95b09013fa6
**to **
blob:http://localhost:4200/fileName.pdf
My current code is
previewPDF(url): any {
return this.http.get(url, { responseType: 'blob' }).toPromise().then(
(res) => {
return new Blob([res], { type: 'application/pdf' });
});
}
previewInfoPDF() {
const promises = this.previewInfo.map(async info=> {
return this.apiSvc.previewPDF(info.url);
});
Promise.all(promises).then(results => {
results.map(res => {
const fileURL = URL.createObjectURL(res);
window.open(fileURL, '_blank');
});
});
}
To open in new tab as preview is correct with my code. My requirement is to download with specific file Name when i click download button from that url.