Some test text!

Discord Logo

Chat with us

PDFTron is now Apryse, learn more here.

iOS / Guides / 2. View a document


PDFTron is now Apryse, learn more here.

View a document using PTDocumentController

Legacy Viewer
For the legacy PTDocumentViewController class, please see this guide .
  1. Open your ViewController file. This is either the ViewController.swift or ViewController.m file in the left pane depending on your choice of language. Import PDFNet and Tools libraries.

    import PDFNet
    import Tools
  2. Override the viewDidAppear() method in the ViewController class and then open the DocumentViewController using:

    override func viewDidAppear(_ animated: Bool) {
        // Create a PTDocumentController
        let documentController = PTDocumentController()
        // The PTDocumentController must be in a navigation controller before a document can be opened
        let navigationController = UINavigationController(rootViewController: documentController)
        navigationController.modalPresentationStyle = .fullScreen
        navigationController.navigationBar.isTranslucent = false
        navigationController.toolbar.isTranslucent = false
        // Open a file from URL.
        let fileURL: URL = URL(string:"")!
        documentController.openDocument(with: fileURL)
        // Show navigation (and document) controller.
        self.present(navigationController, animated: true, completion: nil)
  3. Click on the white play button on the top left of your window to launch the application in the Simulator.

Your app should look like this:

Final iOS get started

Next step


Get the answers you need: Support