Is it possible to open a PDF or another previewable file on a certain page from the Documents and Media widget?
How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!
While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.
Legacy Article
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
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.
- 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.
Did this article resolve your issue ?