我对 swift 非常陌生,所以请多多包涵。我想弄清楚如何在 PDF 文档中搜索特定字符串。我假设我需要使用 findString 函数。我只是不知道应该如何实现这些参数。我正在使用 Apple Docs.并且看不到对此的描述。
谢谢!=]
private func loadPDF(){
guard
let url = Bundle.main.url(forResource: pdfTitle, withExtension: "pdf"),
let document = PDFDocument(url:url)
else {fatalError()}
pdfView.document = document
}
func findString(_ string: String,
withOptions options: NSString.CompareOptions = []) -> [PDFSelection]
最佳答案
要获取匹配项列表,您可以执行以下操作:
let matches = document.findString("foo", withOptions: .caseInsensitive)
关于objective-c - 在 Swift 中使用 PDFKIT 搜索 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50575299/