Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

PDF View/ Download

Avatar

Level 4

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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