最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Loading PDF at a specific page with pdf.js viewer - Stack Overflow

programmeradmin2浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 12

Try to reset the initialBookmark value before opening the file:

PDFView.initialBookmark = "page=10";
PDFView.open(src + "/" + dest.file);
发布评论

评论列表(0)

  1. 暂无评论