How to search text in pdf document with quartz

前端 未结 4 1262
清酒与你
清酒与你 2021-02-03 16:01

I\'m using quartz to display pdf. I need to get the indexes of pages where my searching text exists. Anyone can help me? Thanks.

Solution: There is a sa

相关标签:
4条回答
  • 2021-02-03 16:33

    If you use PDFDocument, instead of CGPDFDocument, that API has text search operations, such as findString:withOptions

    0 讨论(0)
  • 2021-02-03 16:44

    There's nothing to do this inside of Quartz. Quartz is for graphics display - it doesn't need to know, or care about, searching a PDF for string matches. You will have to use the Core Graphics PDF parsing methods to pull out the data, search for the string yourself, and then get the page it occurs on.

    0 讨论(0)
  • 2021-02-03 16:51

    Use CGPDFDocument, CGPDFPage and CGPDFScanner to scan and parse the contents of the page into NSString. Then use NSString function to find the text on that page. If it exists store the corresponding pagenumber in some array. Repeat this scanning and parsing in for loop for number of pages in the pdf

    0 讨论(0)
  • 2021-02-03 16:53

    http://www.random-ideas.net/posts/42%22

    check out the above link its working.

    0 讨论(0)
提交回复
热议问题