I am using apple PDFKit to extract texts from PDF in a SwiftUI project. It is working well for most of the pdfs. But for some pdfs it is not returning any texts. I am getting empty string. I am using following codes:
if let pdf = PDFDocument(url: yourDocumentURL) {
let pageCount = pdf.pageCount
let documentContent = NSMutableAttributedString()
for i in 0 ..< pageCount {
guard let page = pdf.page(at: i) else { continue }
guard let pageContent = page.attributedString else { continue }
documentContent.append(pageContent)
}
}
I want to know what are the limitations of PDFKit. How can I extract texts from all the pdfs?