3

For a project I am looking for a good way to display pdf files in a webbrowser (IE8 and newer). The browsers used in my project have acrobat reader installed, so thatwillbe the preferred way to visualize thepdf file.

Is there a way to access acrobat reader currently opened in a div to (for instance) switch pages or jump to a given bookmark? Is it also possible to listen for text selection events?

Thanks in advance!

Bjarne77
  • 606
  • 9
  • 28
  • This existing post can get you started: http://stackoverflow.com/questions/1733358/javascript-in-a-pdf – madflow May 27 '12 at 08:09
  • This is for javascripting inside a pdf. I'm more looking for using javascript to access the pdf embedded in a html page. – Bjarne77 May 27 '12 at 12:40

3 Answers3

2

I'm not sure you can control the PDF from the outside of the page. However, pdf.js is a PDF renderer written in Javascript. It allows you to embed a PDF viewer inside a page and fully control it, including flipping pages, and the like. It may just be what you're looking for!

Jonathan Protzenko
  • 1,709
  • 8
  • 13
2

Having worked on this problem for some time, I now use the following solution:

  • Use pdfObject.js to embed the pdf file in my webpage.
  • Communicate between pdf and html using the HostContainer. Important here is that you are able to put some javascript in the PDF file.
  • Important note is that this only works with the embedded Acrobat Reader/Pro version.
  • see: http://www.javabeat.net/articles/print.php?article_id=301)

Good luck. If you encounter problems, just leave a message, perhaps I can help.

Bjarne77
  • 606
  • 9
  • 28
1

This won't solve all of your feature requests, but you may want to take a look at the PDF open parameters. If you open a pdf with the appropriate hash-url, you can control reader's behavior.

For example, the following will open a PDF and go to the third page of the pdf:

http://example.org/doc.pdf#page=3
speedplane
  • 15,673
  • 16
  • 86
  • 138