Expand my Community achievements bar.

SOLVED

Issue with Accessing PDF Assets

Avatar

Level 2

I am working to access a PDF asset, Basically once we click on the PDF asset it should load a form.

I created a folder structure /apps/dam/Asset/GET.jsp which is working for the PDF.

However any asset I click jpeg or png, the GET.jsp renders first.

Another issue is with properties in dam console not working with the folder structure.

Any help or direction will be really appreciated.

1 Accepted Solution

Avatar

Correct answer by
Level 8

The first question I would ask is what are the requirements you are trying to implement? In all likelihood trying to use /apps/dam/Asset/GET.jsp is the wrong approach. 

If you look at the recent request console in Felix (http://localhost:4502/system/console/requests) after you viewed a PDF in instance without your custom /dam/Asset/GET.jsp you will see that the code rendering the PDF is actually a chain of servlets - first com.day.cq.dam.core.impl.servlet.BinaryProviderServlet, then com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet, and final the default get servlet org.apache.sling.servlets.get.DefaultGetServlet.

The simplest way to get control of the rendering of the PDF without adversely impacting other functionality is be to create /apps/dam/Asset/myselector.jsp instead of GET.jsp, and then when you reference the PDF in your component print out link as /content/dam/geometrixx/documents/GeoCube_Datasheet.pdf.myselector.pdf for example. That requires that you be printing the link out in a component you control however. 

Now if you can't control the URL then another way to do it would be to create /apps/dam/Asset/pdf.jsp and put your logic there. That would result in all the DAM PDFs getting your logic. However if the logic is specific to a single component or subset of PDFs then that probably isn't the right way to do it. 

If you only want a subset of your PDFs to get this special treatment than the best way would be to write a custom component that extends foundation Download component. Then you can control the URL and add a selector. You can also put the script that is rendering the PDF in with the custom component - /apps/myapp/components/customdownload/myselector.jsp. Then you can use a URL format that looks like the image URLs - /content/geometrixx/en/company/_jcr_content/par/3_1219086936652.img.jpg/1289480092880.jpg but instead something like /content/geometrixx/en/company/_jcr_content/par/3_1219086936652.myselector.pdf/1289480092880.pdf. 

View solution in original post

4 Replies

Avatar

Level 10

Remember cheatsheet[1]. It is resolving to resource type & hence get applied to all dam assets. Use selectors.

[1]  http://dev.day.com/content/ddc/blog/2008/07/cheatsheet/_jcr_content/images/cheatsheet/front.png

Avatar

Level 2

Hi Sham,

I am using AEM 5.6.1.

When I first click on an asset either a PDF or a PNG file in damadmin, it always redirects me to a GET.jsp located under /dam/Asset instead of the properties window.

Following are issues I noticed when i introduce GET.jsp andd the custom servlet:

1. In damadmin when I click on the image to view properties in classic UI interface, I am not able to view the properties of the image. Reason being, it still pushes me to the custom GET.jsp. Attached is the properties window which should work without using custom GET.jsp andd the servlet. 

I see this issue in the classic UI interface alone but I am not able to use the properties on click of the asset in damadmin wheras in granite interface I am able to see the properties for that particular asset.

2. Regarding loading GET.jsp and my custom servlet, as mentioned, GET.jsp loads for all the assets PDF or .PNG files.

How can I add a selector to GET.jsp such that on click of the URL,  http://localhost:4502/content/dam/geometrixx/documents/GeoCube_Datasheet.pdf, the custom GET.jsp and the servlet are invoked and when I click on the PNG file this GET.jsp is not invoked e.g. http://localhost:4502/content/dam/geometrixx/banners/banner-mono.png

Avatar

Correct answer by
Level 8

The first question I would ask is what are the requirements you are trying to implement? In all likelihood trying to use /apps/dam/Asset/GET.jsp is the wrong approach. 

If you look at the recent request console in Felix (http://localhost:4502/system/console/requests) after you viewed a PDF in instance without your custom /dam/Asset/GET.jsp you will see that the code rendering the PDF is actually a chain of servlets - first com.day.cq.dam.core.impl.servlet.BinaryProviderServlet, then com.day.cq.dam.core.impl.servlet.SafeBinaryGetServlet, and final the default get servlet org.apache.sling.servlets.get.DefaultGetServlet.

The simplest way to get control of the rendering of the PDF without adversely impacting other functionality is be to create /apps/dam/Asset/myselector.jsp instead of GET.jsp, and then when you reference the PDF in your component print out link as /content/dam/geometrixx/documents/GeoCube_Datasheet.pdf.myselector.pdf for example. That requires that you be printing the link out in a component you control however. 

Now if you can't control the URL then another way to do it would be to create /apps/dam/Asset/pdf.jsp and put your logic there. That would result in all the DAM PDFs getting your logic. However if the logic is specific to a single component or subset of PDFs then that probably isn't the right way to do it. 

If you only want a subset of your PDFs to get this special treatment than the best way would be to write a custom component that extends foundation Download component. Then you can control the URL and add a selector. You can also put the script that is rendering the PDF in with the custom component - /apps/myapp/components/customdownload/myselector.jsp. Then you can use a URL format that looks like the image URLs - /content/geometrixx/en/company/_jcr_content/par/3_1219086936652.img.jpg/1289480092880.jpg but instead something like /content/geometrixx/en/company/_jcr_content/par/3_1219086936652.myselector.pdf/1289480092880.pdf. 

Avatar

Level 2

Hello Orotas,

The requirement is to have gating on the asset directly.

When you specify a property in the metadata, "gating" or "nogating", the asset should display a form an after collecting information we show the asset.

We want to avoid using separate gated pages as it is a maintenance issue sorting and adding them to pages.

While GET.jsp triggers when you open any asset in DAM admin, pdf.jsp as you mentioned above fails to work for the (PDF) asset.

The issue I am facing with GET.jsp right now is properties window does not work.

Please let me know how I can move forward on this.