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

javascript - Embedded PDF - open page number without reloading the document - Stack Overflow

programmeradmin3浏览0评论

I have embedded a PDF document using the html object tag, and displayed it on one section of the webpage. Another section contains a tree-view of links (looks like the PDF's bookmarks). Clicking on a link in the tree-view reloads the PDF document and opens it on the correct page (page number is contained in the links). Is there a way to acplish this without reloading the document?

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

I have embedded a PDF document using the html object tag, and displayed it on one section of the webpage. Another section contains a tree-view of links (looks like the PDF's bookmarks). Clicking on a link in the tree-view reloads the PDF document and opens it on the correct page (page number is contained in the links). Is there a way to acplish this without reloading the document?

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

Share Improve this question edited Nov 23, 2012 at 5:55 Donna Navales Petrick asked Nov 22, 2012 at 21:00 Donna Navales PetrickDonna Navales Petrick 611 silver badge3 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7 +200

I think there is no native method in JavaScript that would provide that functionality. You are going to need a library.

The easiest way would be to use a well documented library to work with pdf documents in JavaScript. PDF.js is a very good project in that sense, although it renders the pdf itself, instead of using Acrobat Reader, which might give problems with plicated documents.


Another solution, using Adobe Acrobat reader, would be to use their own JavaScript API, following that link you will see the plete API reference. Quoting from that 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 0-based. [...]

So if you wanted to go to a specific page of the document you could use

this.pageNum = 6;

Where this should be the app context. Here you can find the online API reference with more documentation and examples.

Some guides on using the above JS API:

  • http://blogs.adobe./pdfdevjunkie/web_designers_guide
  • http://cookbooks.adobe./post_Passing_information_actions_from_the_browser_to_an-18885.html
  • http://www.adobe./content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters_v9.pdf#page=5
发布评论

评论列表(0)

  1. 暂无评论