简体   繁体   中英

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

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.

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, eg 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.

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

@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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM