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.
1import PDFNet
2import Tools
  1. Override the viewDidAppear() method in the ViewController class and then open the DocumentViewController using:
1override func viewDidAppear(_ animated: Bool) {
2 // Create a PTDocumentController
3 let documentController = PTDocumentController()
4 // The PTDocumentController must be in a navigation controller before a document can be opened
5 let navigationController = UINavigationController(rootViewController: documentController)
6 navigationController.modalPresentationStyle = .fullScreen
7 navigationController.navigationBar.isTranslucent = false
8 navigationController.toolbar.isTranslucent = false
9 // Open a file from URL.
10 let fileURL: URL = URL(string:"https://pdftron.s3.amazonaws.com/downloads/pl/sample.pdf")!
11 documentController.openDocument(with: fileURL)
12 // Show navigation (and document) controller.
13 self.present(navigationController, animated: true, completion: nil)
14}
  1. 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:

Apryse Docs Image

Next step

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales