mozilla/pdf.js — pull request #1078 by devietti (2012-01-13 20:39:09+00:00)
Title: Extract text for highlight/underline annotations

I added some code to extract the text that is highlighted or underlined in PDF documents. It works by adding a bit of processing during rendering, testing during each text rendering call whether it's inside the bounding box for an annotation.

I've run the tests on Mac OS X Lion with Firefox 9.0.1 and Chrome 16.0.912.75. There are 3 tests that don't work on Chrome due to some Javascript errors but everything works on Firefox.

There are still a few warts:
1. One of the test annotations (a highlight inside a figure from the TraceMonkey paper) doesn't get extracted correctly. I think it's an issue with a PDF figure nested inside a larger PDF document.
2. The annotation tests don't work for me in chrome 16.0.912.75 on Mac OS X Lion if they are run as the *last* tests, but they run fine if they go first. They also run fine if they are run on their own. I'm not sure why!

Let me know what you think!
joe