I'd like to be able to find the location of a text string in a PDF file from the clipboard.
I'd like to do this so I can provide some Javascript code that would highlight/annotate and provide postit-like notes capability in a browser. (The Javascript is a separate problem we don't need to deal with here, although suggestions are welcome. I'm looking for something like iText in Javascript). Basically, the user drags the cursor across some text, hits the 'highlight' button, and the server returns a new PDF with the text highlighted. Or she hits a 'postit' button that pops up a text box they can drag around the document, stick it on the doc, then write a note in the box. When done, the doc is posted, then returned with the postit embedded.
My current path is to try and use Perl to insert something like XMP to insert little invisible location information bits between the characters in the text in the PDF, which I can then read from the clipboard in Javascript in the browser. The Perl script will run offline or on the server to create the PDF.
Tips on how to do this, or a better approach will be rewarded with posted code on how to do this if I figure it out.
My fallback is to use the location in the clipboard to try and figure where in the file the text came from, but I dread reversing the PDF -> screen coordinate transform.
And no, the text is not unique, it is completely arbitrary.
Oh, and if anyone has tips on a package to annotating/highlighting or inserting text box into the PDF that would be great.
emike
In reply to PDF highlight/annotate and postit by emike
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |