Some test text!
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:
PTTabbedDocumentViewController. (It is accessible via the
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.)
sample.pdfhas been added to the project, and will be copied into the bundle.
Instantiate a new
// Get the path to document in the app bundle. let pdfPath: String? = Bundle.main.path(forResource: "sample", ofType: "pdf") // Instantiate a new PDFDoc with the path to the file. let docToOpen = PTPDFDoc(filepath: pdfPath)
Create a new
PTPDFViewCtrl and add it as a child to the current view:
// Create a new PDFViewCtrl. let pdfViewCtrl = PTPDFViewCtrl() // Set the document to display. pdfViewCtrl.setDoc(docToOpen) // Add the PDFViewCtrl to the current view controller's root view. self.view.addSubview(pdfViewCtrl) // Set the size of the PDFViewCtrl to that of its superview. // (Auto Layout is fully supported as well) pdfViewCtrl.frame = self.view.bounds pdfViewCtrl.autoresizingMask = [.flexibleWidth, .flexibleHeight]
Running the app will now display the PDF
sample.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.
PDFViewCtrl has a large API that can be used to control how the PDF is presented to the user. All of the APIs that you can use are well documented. This guide highlights some of the most commonly used functionality.
If you are using a
PTTabbedDocumentViewController), the contained
PTPDFViewCtrl can be accessed as a property:
let documentViewController = PTDocumentViewController() documentViewController.pdfViewCtrl
|Set how pages are presented and scrolled: in 1 or 2 columns, scrolled vertically or horizontally|
|Sets the zoom level relative to the page size, fit-width, fit-height or fit-page.|
|When a document is scrolled via horizontal swipes, use this method to control what zoom level new pages are rendered at.|
|Sets the color that is seen around pages.|
|Controls how low-resolution thumbnails are handled. Enlarged thumbnails are used in place of high-resolution content while the high-resolution content is being rendered.|
|This view is used for drawing system-content over the PDF.|
|Controls how frequently the high-resolution content is updated while it is being rendered.|
|Controls if annotations are visible.|
|Controls if form fields are shaded with light blue.|
|Controls how PDFs that use overprint colors are rendered.|
|Can be used to turn on night-mode and other color processing changes.|
The first is a general purpose delegate, the second was designed specifically for enabling the
Tools.framework functionality via its conforming object
PTToolManager. If you are using the tools framework, a
PTToolManager should always be assigned as the
toolDelegate object. If you are not using the
Tools.framework, it may be used for whatever purpose your app requires.
PTPDFViewCtrldelegates are used internally and cannot be reassigned to another object. To receive the delegate callbacks, create a subclass of
PTDocumentViewControllerand implement the required methods, being sure to call
Get the anwsers you need: Support