Embedded PDF - open page number without reloading the document

I embedded a PDF using the html object tag and displayed it in one section of the web page. Another section contains a tree view of links (looks like PDF bookmarks). By clicking on the link in the tree, reload the PDF document and open it on the correct page (the page number is contained in the links). Is there a way to accomplish this without reloading the document?

To rephrase the question, I am looking for a JavaScript function that could simulate the behavior of bookmarks - switching to the page number without reloading the document.

+6
source share
1 answer

I think that in JavaScript there is no built-in method that would provide this functionality. You will need a library.

The easiest way is to use a well-documented library to work with pdf documents in JavaScript. PDF.js is a very good project in this sense, although it does the PDF itself, instead of using Acrobat Reader, which can give problems with complex documents.


Another solution using Adobe Acrobat would be to use a native JavaScript API , following this link you will see the full Help API. Quoting from this document (Page 254):

pageNum

Gets or sets the current page of the document. When setting pageNum to a specific page, remember that the values ​​are based on 0. [...]

So, if you want to go to a specific page of a document, you can use

this.pageNum = 6; 

Where should this be the application context. Here you can find the online API link with additional documentation and examples.

Some guides on using the above JS API:

+7
source

All Articles