Issue
- When a Documents and Media widget displays a previewable document like a PDF, it's possible to move around the different pages.
- Is it possible to have a URL that takes you directly to the preview on a specific page of the document?
Environment
- Liferay DXP 7.2, 7.3, 7.4
- Quarterly Release 2023.Q3, 2023.Q4, 2024.Q1
Resolution
- Without relying on a particular Documents and Media widget, it's possible by using the friendly URL and the parameter previewFileIndex. For example:
- /documents/20119/32528/myfile.pdf?previewFileIndex=2
- /documents/d/mysite/myfile?previewFileIndex=2
- Having such a URL based off the D&M widget is not possible out of the box.
- One way to manage it would be:
- Customize the JPS document-library-preview-document/src/main/resources/META-INF/resources/preview/view.jsp to manage a parameter
<portlet-namespace>currentPage
passed in the URL. - Then pass the value to the JS component DocumentPreviewer, instead of the default value 1.
- Customize the JPS document-library-preview-document/src/main/resources/META-INF/resources/preview/view.jsp to manage a parameter
- A different approach would be:
- Use an Asset Publisher together with a Widget Display Template that directly employs the friendly URL with the parameter previewFileIndex.
Contenido exclusivo para suscriptores.
Una Suscripción Enterprise de Liferay proporciona acceso a más de 1.500 artículos que incluyen las mejores practicas, diagnóstico de problemas y otras soluciones útiles. Inicia sesión para tener un acceso completo.
Inicia sesión