简体   繁体   English

从PDF文件中搜索字符串/文本,并在iPhone / iPad应用程序中列出所有匹配的字符串

[英]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). 我已经实现了一个iPad应用程序,实际上可以读取PDF文件(使用石英)。 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. 现在,我想实现搜索功能,为此,我检查了一些教程,其中一些使用Crystal提到,某些提到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 ). 我看过石英( 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. CGPDFScanner是一个相当低级的API,可让您有选择地扫描各种PDF运算符并在每个运算符上调用回调。 It does require you to have some knowledge of PDF structure, but it will do the job. 它确实需要您具有PDF结构的一些知识,但是它将可以完成工作。 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.). PDF运算符是PDF文件中的命令,它执行某些操作(通常是操纵绘图状态,例如,编写文本,绘图线,更改图形状态等)。

Essentially, you tell the scanner what PDF operators you are interested in, and tell it what callback you want to invoke. 本质上,您可以告诉扫描程序您对哪些PDF运算符感兴趣,并告诉它要调用的回调。 In your case, you are interested in the text operators TJ , Tj ; 在您的情况下,您对文本运算符TJTj感兴趣; see this page for a working text search example using this API, and this question for some other answers on text search. 有关使用此API的有效文本搜索示例,请参见此页面 ;有关文本搜索的其他一些答案,请参见此问题

You may get your answer at FastPdfKit . 您可以在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. @Subodh S:目前,PDFKitten不支持多字查询。 Therefore, your keyword is not searched and highlighted. 因此,不会搜索和突出显示您的关键字。 You must handle yourself in source code and even change some points in PDFKitten. 您必须处理源代码,甚至更改PDFKitten中的某些要点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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