开发者

Highlight pdf line

开发者 https://www.devze.com 2023-01-28 12:53 出处:网络
Please can any one help me. I am really stuck I don\'t know how to highlight particular line o开发者_开发问答f pdf. It would be better if any one can provide me sample code or pseudo code

Please can any one help me. I am really stuck I don't know how to highlight particular line o开发者_开发问答f pdf. It would be better if any one can provide me sample code or pseudo code

Thanks


This is not trivial.

To do this, I'd render the PDF contents into one layer, and somehow get the position of the said line/object using the CoreGraphics PDF parser (or some other way). After that, you highlight the said object using your own drawing code.


Just highlighting a particular line is quite difficult.

If you need search and highlight, please try FastPDFKit. I played with it for a while and it's quite good as a pdf reader.

http://mobfarm.eu/fastpdfkit


I'm working on the same thing at the moment and it's not trivial indeed.

From what I can figure out you need to load the text and arrange it in lines first. If you are using Poppler, the Poppler.Page.textList() will provide you with a list of TextBoxes and a TextBox.hasSpaceAfter() will tell you the end of line when returning False.

I am using the Qt4 frontend, so the each TextBox has a QRect from which I can figure out where to highlight a word. Highlighting a line is more or less lirstWordOfLine.geometry().united(lastWordOfLine.geometry()) which will provide the geometry of the line to highlight.

Now what I can't figure out is how to save the coordinates of the highlights in the document.

0

精彩评论

暂无评论...
验证码 换一张
取 消