Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display PDF in web page and scroll it programmatically [closed]

I've built a search engine to find the most relevant phrases inside a document, after a user text search. After my processing I have a list of phrases texts. What I need now is to display them to the user, showing the original source PDF and scrolling it to the page where the original phrase is found. The best case scenario would be to highlight it, but for now Scrolling is enough.

I'm using PHP and Javascript.

Can anyone point me a way to do this? Is there any framework available?

Any tips are welcome.

like image 329
Miguel E Avatar asked Mar 21 '13 19:03

Miguel E


2 Answers

There is an excellent JavaScript library for embedding PDFs called pdf.js. A demo can be found here

Out of the box, I don't think it has the highlighting and scrolling functionality you're looking for. However, it looks like someone may have figured out how to do it here

like image 108
Cody Bonney Avatar answered Sep 30 '22 18:09

Cody Bonney


If you are using Acrobat Reader to display the file in the browser, then you could use Acrobat Reader URL parameters.

Example:

http://example.org/doc.pdf#page=3

There is also a post about how to embed a PDF document in a web page using Acrobat Reader

If you cannot asume that your users will use Adobe Acrobat Reader, then another option could be to use a library on the server side, then create a temporary PDF file that includes an "OpenAction" redirecting to your target page, and return that temporary file instead. The code for including this OpenAction will depend on the library that you decide to use.

like image 41
yms Avatar answered Sep 30 '22 16:09

yms