I am able to view the pdf(in other tab) but not able to download the pdf file when i click the download icon of pdf,the pdf file in blob format.




Previously the pdf downloaded in the same tab ,but my requirement is that view the pdf in other tab and then download the pdf.I am able to view the pdf in another tab,but when i am clicking the download icon of the pdf then it shows network error.The pdf url coming as a blob format.


function sectionPdfGeneration() {
var deferred = $.Deferred();
var sectionName = sectionPdfName;
var blob = convertSectionBase64ToBlob(pdfSectionData);
if (typeof window.navigator.msSaveBlob !== 'undefined') {

// IE workaround for "HTML7007: One or more blob URLs were revoked by closing the blob for which they were created. These URLs will no longer resolve as the data backing the URL has been freed."
window.navigator.msSaveBlob(blob, sectionPdfName+'.pdf');
} else {
var URL = window.URL || window.webkitURL;
var downloadUrl =window.URL.createObjectURL(blob);

if (sectionName) {

// use HTML5 a[download] attribute to specify sectionName
var a = document.createElement("a");

// safari doesn't support this yet
if (typeof a.download === 'undefined') {
window.location = downloadUrl;
} else {
//a.href = downloadUrl;
//a.download = sectionName;
} else {

// cleanup
setTimeout(function () {
}, 100);
return deferred.promise();

PFA the my code.any help would be appreciated.

Accepted Solutions (1)

Accepted Solutions (1)




The easiest solution can be -

1. Add target=_blank to open pdf in new tab.

2. For download link add a selector to the url e.g. /content/dam/project/pdfname.pdfdownload.pdf and based on selector serve pdf from custom servlet with below headers 

response.setHeader("Content-Disposition", "inline; filename=\"" + pdfpath + "\"");


Answers (0)