Read pdf.js search highlight for more information.

pdf.js is a JavaScript library that renders Portable Document Format (PDF) files using the web standards-compliance HTML5 Canvas. The project is led by the Mozilla Foundation after Andreas Gal launched it (initially as an experiment) in 2011.

PDF.js can work as a part of a website or of a browser. Originally created as a Firefox extension, it is now included in Mozilla Firefox since 2012 (version 15) and is enabled by default since 2013 (version 19). It is also included in ownCloud, and as a browser extension for Google Chrome, Chromium, Firefox for Android, Pale Moon, and SeaMonkey.

pdf.js search highlight

Make a PDF search engine with a few clicks

I found a  way to achieve PDF.js search highlight text. Find the co-ordinate of the point in the HTML page and then subtract the co-ordinate(position) of div.textLayer from it to find the co-ordinate of the text in the pdf displayed online.

In order to find the co-ordinate of the text in actual pdf find the aspect ratio and you would get the actual co-ordinate.

example:

If the PDF displayed online is 800×900 and the text co-ordinate [(31,35),(40,35),(40,40),(31,40)] and the actual pdf size is 612×792 find the appropriate value of the area in actual pdf like this (612/(800 / 31)),(792/(900/35)) and do this way for all co-ordinate found in online, i.e, (40,35),(40,40),(31,40)

Searches related to pdf.js search highlight

You may also like

Halloween sale is live! 0 Days 19 Hours 3 Minutes 0 Seconds left to get your free search!
Sign up