Display a PDF file on a web page and scroll it programmatically

I created a search engine to search for the most relevant phrases within a document after a custom text search. After my processing, I have a list of phrase texts. Now I need to show them to the user, showing the original source PDF file and scrolling it to the page where the original phrase is found. The best scenario is to highlight it, but for now, scrolling is enough.

I am using PHP and Javascript.

Can someone tell me a way to do this? Is any infrastructure available?

Any advice is appreciated.

+4
source share
2 answers

There is an excellent JavaScript library for embedding PDF files called pdf.js. Demo can be found here.

Out of the box, I don’t think it has the highlight and scroll functions you are looking for. However, it seems someone might have figured out how to do it here.

+5
source

If you use Acrobat Reader to display the file in a browser, you can use Acrobat Reader URL Settings .

Example:

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

There is also a message on how to embed a PDF document into a web page using Acrobat Reader

If you cannot assume that your users will use Adobe Acrobat Reader, then another option would be to use a server-side library, and then create a temporary PDF file that includes redirecting OpenAction to your landing page and return that temporary file. The code to enable this OpenAction will depend on the library you decide to use.

+2
source

All Articles