Open a document with Apryse iOS SDK
You have a few options to open a document such as with a document view controller, tabbed document view controller or an embedded view.
Document view controller
The PTDocumentController shows a PDF viewer and annotator complete with controls such as an annotation toolbar, page layout controls, bookmarks, thumbnail viewer, etc. All of its component pieces are part of the Tools framework, and this class packages them into one easy to use view controller.
For a version of PTDocumentController that supports multiple documents, see PTTabbedDocumentViewController.

The document viewer includes a convenient document interaction and annotation toolbar at the top as well as convenient access to a number of powerful built-in components.
The PTDocumentController is a subclass of the PTDocumentBaseViewController from which it inherits much of its functionality.
Show a document
The document viewer is part of the Tools library, so make sure you have added the Tools library to your project.
The following shows how to create a document viewer, set the document to display, and present it on screen.
Respond to Opening Events
openDocumentWithURL: is an asynchronous method. To respond to errors or other events that occur during opening, assign an object that conforms to the PTDocumentControllerDelegate to the PTDocumentController's delegate property and implement the following optional methods:
documentControllerDidOpenDocument:to respond to successfully opening a document.documentController:didFailToOpenDocumentWithError:to respond to an error during document opening.documentController:destinationURLForDocumentAtURL:to control where remote or converted documents are saved.
Show Documents in a Tabbed ViewController
The PTTabbedDocumentViewController class is a container view controller that hosts multiple PTDocumentControllers with a tabbed interface. For more information about the PTDocumentController class, please see this guide.

On iPads or other devices with a Regular horizontal size class then the tabs will be shown in a bar along the top of the view, for Compact size classes the tabs will be accessible in the UIToolbar at the bottom of the view.
The tabbed viewer control is part of the Tools library, so make sure you have added the Tools library to your project.
Show a tabbed viewer controller
The following sample demonstrates how to show a tabbed viewer controller with a document from another UIViewController:
The openDocumentWithURL: method will create a new tab if the URL is not already being displayed, otherwise it will switch to the existing tab.
The tabbed viewer controller currently relies on the UINavigationController to supply a navigation bar for the buttons.
Tab management
For more control over how tabs are added to the tabbed viewer controller, the addTabWithURL:selected:error: and insertTabWithURL:atIndex:selected:error: methods can be used:
Configure the tab bar
The behavior of the tabbed viewer controller can be customized with several properties. The tabsEnabled and maximumTabCount properties can be used to disable the tab bar and limit the number of tabs, respectively. By default, tabs are enabled in the tabbed viewer controller and there is no limit on the number of tabs.
Tab bar visibility
The tab bar's visibility is controlled by the tabBarHidden property. To animate the change in visibility, the setTabBarHidden:animated: method can be used.
When the containing navigation controller's navigation bar is hidden, the tabbed viewer also hides its tab bar.
Tabbed viewer controller delegate
To configure a document view controller before it is displayed, conform to and implement the PTTabbedDocumentViewControllerDelegate method tabbedDocumentViewController:willAddDocumentViewController:. Note that it is permissible to assign the internal PTDocumentController's delegate to an external object.
You can set a delegate to be notified by the tabbed viewer controller when tabs are removed with the PTTabbedDocumentViewControllerDelegate protocol's tabbedDocumentViewController:willRemoveTabAtIndex: method.
The tabbedDocumentViewController:willRemoveTabAtIndex: delegate method can be used to close the tabbed viewer controller when the last tab is closed:
PTPDFViewCtrl
About PTPDFViewCtrl
The PTPDFViewCtrl is a UIView that displays a PDF.
If your app is displaying a PDF, a PTPDFViewCtrl will be used in one of two ways:
Directly, by adding it as a subview to another view in your app.
As a component piece of a
PTDocumentControllerorPTTabbedDocumentViewController. (It is accessible via thepdfViewCtrlproperty.)
Use PTPDFViewCtrl as a stand-alone component
These instructions assume that you've initialized Apryse.
Add a PDF to your project, by dragging it into the project's left side panel. Ensure that it will be copied into the bundle's resources by checking that it is listed under the Copy Bundle Resources section of the project's Build Phases. (If it is not present here, add it using the '+' button.)The file
sample.pdfhas been added to the project, and will be copied into the bundle.

Instantiate a new
PTPDFDoc:
Create a new
PTPDFViewCtrland add it as a child to the current view:Running the app will now display the PDFsample.pdf. However, it will not support annotation creation, editing, text selection, or any other UI aspect that is handled by Tools.framework . To add support for annotations and text selection you need to incorporate the tools framework .
Last updated
Was this helpful?