내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

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.

Avatar

Level 3

Hi,

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;
//document.body.appendChild(a);
//a.click();
window.open(downloadUrl,'_blank');
}
} else {
window.open(downloadUrl,'_blank');
}

// cleanup
setTimeout(function () {
URL.revokeObjectURL(downloadUrl);
$('body').children('a[download]').remove();
}, 100);
}
deferred.resolve();
return deferred.promise();
}

PFA the my code.any help would be appreciated.

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

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 

resposne.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=\"" + pdfpath + "\"");

 

Arun Patidar

AEM LinksLinkedIn

원본 게시물의 솔루션 보기

1 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

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 

resposne.setContentType("application/pdf");
response.setHeader("Content-Disposition", "inline; filename=\"" + pdfpath + "\"");

 

Arun Patidar

AEM LinksLinkedIn