Search a string/text from a PDF file and list all the matched string in iPhone/iPad application

旧时模样 提交于 2019-12-23 23:43:18

问题


I have implemented an iPad application which is actually read the PDF file(using quartz). Now I want to implement the Search Feature and for this I have checked some tutorial some where mentioned using quartz and some where mentioned FastPdfKit. But I don't know which one will be better. I have seen the quartz ( https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.html ). I have some doubt in this.

  1. the "Callbacks for Operators" what and why we use this?
  2. "Operators Table" what is the purpose of this? and
  3. Where we will put the search text.

Please suggest me in this regards or provide any other open source which I can use.

Thanks in advance.


回答1:


CGPDFScanner is a fairly low-level API which allows you to selectively scan for various PDF operators and invoke callbacks on each operator. It does require you to have some knowledge of PDF structure, but it will do the job. A PDF operator is a command in a PDF file which does some operation (usually manipulating the drawing state, e.g. writing text, drawing lines, changing graphics state, etc.).

Essentially, you tell the scanner what PDF operators you are interested in, and tell it what callback you want to invoke. In your case, you are interested in the text operators TJ, Tj; see this page for a working text search example using this API, and this question for some other answers on text search.




回答2:


You may get your answer at FastPdfKit. Please let me know if you still more information. I think this will solve your purpose.




回答3:


@Subodh S: At the momment, PDFKitten does not support multi-words query. Therefore, your keyword is not searched and highlighted. You must handle yourself in source code and even change some points in PDFKitten.



来源:https://stackoverflow.com/questions/12153811/search-a-string-text-from-a-pdf-file-and-list-all-the-matched-string-in-iphone-i

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