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?
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?
Share Improve this question asked Feb 10, 2013 at 13:41 GeshGesh 5751 gold badge7 silver badges21 bronze badges1 Answer
Reset to default 12Try to reset the initialBookmark
value before opening the file:
PDFView.initialBookmark = "page=10";
PDFView.open(src + "/" + dest.file);