Highlight pdf line

痞子三分冷 提交于 2019-12-24 11:48:04

问题



Please can any one help me. I am really stuck I don't know how to highlight particular line of pdf. It would be better if any one can provide me sample code or pseudo code
Thanks


回答1:


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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/4306028/highlight-pdf-line

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!