iosswiftswift2pdfkitquartz-core

QuartzCore PDFKit


So basically I'm trying to count the pages of a PDF, but I'm having a little trouble... I imported QuartzCore in order to use PDFKit to count the pages.

The error I'm getting says PDFDocument is an unresolved identifier.

import UIKit
import QuartzCore

class Recht: UIViewController, ENSideMenuDelegate, UIWebViewDelegate {
    @IBOutlet var pdfView: UIWebView!
    override func viewDidLoad() {
        super.viewDidLoad()
        pdfView.delegate = self

        let url = NSBundle.mainBundle().URLForResource(String(lawNumberToPresent), withExtension: "pdf")
        let pdfDoc = PDFDocument(URL: url)
        pdfDoc.pageCount()
    }     
}

Solution

  • UPDATE

    If your deployment target is iOS 11 or later, you can use PDFKit.

    ORIGINAL

    PDFKit is only available on Mac OS X, not on iOS. You will need to use a third-party framework like FastPdfKit or PSPDFKit, or write your own PDF parser.