PDF search on the iPhone

后端 未结 3 2096
感动是毒
感动是毒 2020-11-29 19:35

After two days trying to read annotations from a PDF using Quartz, I\'ve managed to do it and posted my code.

Now I\'d like to do the same for another frequently as

3条回答
  •  渐次进展
    2020-11-29 20:00

    So now in iOS 11 we have PDFKit with which searching text is a breeze

    if #available(iOS 11.0, *) {
         let pdfDocument = PDFDocument(url: fileUrl)!
         let allText = pdfDocument.string /// Gets all text in pdf separated by /n
    
         let s: PDFSelection = pdfDocument.findString("Hello", withOptions: [])
         let sWithFormatting = s!.first!.attributedString
    }
    

提交回复
热议问题