View a document using PTDocumentViewController

Legacy Viewer

This guide is for the legacy PTDocumentViewController class. This class is no longer being updated. For the best viewing experience and to take advantage of new developments, the PTDocumentController should be used. Please see this guide for information.

  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 PTDocumentViewController
3 let documentController = PTDocumentViewController()
4 // The PTDocumentViewController must be in a navigation controller before a document can be opened
5 let navigationController = UINavigationController(rootViewController: documentController)
6 navigationController.modalPresentationStyle = .fullScreen
7 // Open a file from URL.
8 let fileURL: URL = URL(string:"https://pdftron.s3.amazonaws.com/downloads/pl/sample.pdf")!
9 documentController.openDocument(with: fileURL)
10 // Show navigation (and document) controller.
11 self.present(navigationController, animated: true, completion: nil)
12}
  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