Search code examples
javascriptjquerypdfmozillapdf.js

Re-open pdf with pdf.js at the beginning of the document. Not last viewed position


The plugin saves the last position the document was in before it is closed and next time I open the document, it shows the document in this position.

Example:

I am seeing the middle of the second page. I close the document. I open it again and it opens in the middle of the second page.

I want to re-open it at the begginning.

Does anybody knows how to change that behavior?


Solution

  • You should be able to just add a bookmark to the URL, like a traditional HTML bookmark that follows a #. For example:

    <iframe src="viewer.html?file=/sample.pdf#0"></iframe>
    

    Or if you're loading the viewer directly in your browser, just append #0 to the URL. That should override any other bookmark your browser may be remembering, according to the following code in viewer.js:

    initialBookmark: document.location.hash.substring(1),