PDF View/ Download | Community
Skip to main content
Level 5
May 2, 2022
Solved

PDF View/ Download

  • May 2, 2022
  • 1 reply
  • 681 views

Hi All,

 

AEM Version: 6.5.12

 

Problem: In a component, we need to add 2 buttons "view" and "download" and upon clicking, It either opens DAM pdf in a new TAB or download.

 

I am aware of Content disposition filter issue which is implemented for security issue from AEM 6.2.

 

Question: Is there any  way to achieve both either using some JS library or any sort of Servlets?

 

NOTE: We are not looking out to make any change at Dispatcher level for this solution.

 

Thank you in advance.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Hi,

This can be done using servlet,

you need to serve the PDF response over servlet and add headers

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

Use selector e.g. pdfname.view.pdf or pdfname.download.pdf

 

1 reply

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
May 3, 2022

Hi,

This can be done using servlet,

you need to serve the PDF response over servlet and add headers

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition

Use selector e.g. pdfname.view.pdf or pdfname.download.pdf

 

Arun Patidar