Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading PDF at a specific page with pdf.js viewer

I'm using pdf.js and the included viewer to display pdfs on my website. I added a menu to the viewer, where users can choose a specific bookmark of different pdf files. If a users is clicking on a menu item the file should be opened and jumping to a specific page.

So far I managed it to open a new pdf file but I didn't find a way to open it at a specific page. I tried it this way:

PDFView.open(src + "/" + dest.file);
PDFView.page = dest.page;

I know, I can use the #page= hashtag when opening the viewer for the first time, but that's not working when I'm loading other files after the viewer is already opened.

Is there any why to solve this problem? Maybe something like a event-listener I can call after the new file is successfully loaded, so I can jump to the page?

like image 652
Gesh Avatar asked Feb 10 '13 13:02

Gesh


People also ask

How do you embed a PDF in HTML?

Using an iframe tag is the second way to embed a pdf file in an HTML web page. In web development, web developers use the iframe tag to embed files in various formats and even other websites within a web page. Due to its wide compatibility, the iframe tag is widely used for embedding pdf.


1 Answers

Try to reset the initialBookmark value before opening the file:

PDFView.initialBookmark = "page=10";
PDFView.open(src + "/" + dest.file);
like image 98
async5 Avatar answered Oct 14 '22 06:10

async5