Legacy Knowledge Base
Published Jun. 30, 2025

Is it possible to open a PDF or another previewable file on a certain page from the Documents and Media widget?

Written By

Ricardo Couso

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability 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:
    1. 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.
    2. 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 ?

Legacy Knowledge Base