Hello, how to extract text from pdfPage (pdf-document). Method ".string" incorrect parse book with footnotes. Maybe pdfKit have other method or parameters for fix this problem.
PDFKit extract text
Add a Comment
Hello, how to extract text from pdfPage (pdf-document). Method ".string" incorrect parse book with footnotes. Maybe pdfKit have other method or parameters for fix this problem.
Could you show the code you have presently ?
What is exactly the problem ? Is it you get the footnotes as well ?
Code should be like this
if let pdf = PDFDocument(url: url) {
let pageCount = pdf.pageCount
let documentContent = NSMutableAttributedString()
for i in 1 ..< pageCount {
guard let page = pdf.page(at: i) else { continue }
guard let pageContent = page.attributedString else { continue }
documentContent.append(pageContent)
}
}
Credit: h ttps://www.hackingwithswift.com/example-code/libraries/how-to-extract-text-from-a-pdf-using-pdfkit