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?
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.
Try to reset the initialBookmark
value before opening the file:
PDFView.initialBookmark = "page=10";
PDFView.open(src + "/" + dest.file);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With