Requirements
- iOS 9 or above
- Xcode 8 or above
- Swift 3.0
Note
This project is still in early stages. Right now the PDF reader works both programmatically and through interface builder. This PDF reader supports interactive forms and provides methods for overlaying text, signature and checkbox elements onto the page, as well as rendering a PDF with the elements burned back onto the PDF. See the example project for how to implement.
Installation
CocoaPods
UXMPDFKit is available through CocoaPods. To install
it, simply add the following line to your Podfile:
If you wish to use the Swift 2.3 version, use the following instead:
Carthage
UXMPDFKit is also available through Carthage.
To install just write into your Cartfile:
Run carthage update
to build the framework and drag the built UXMPDFKit.framework
into your Xcode project.
Usage
Simple Usage
UXMPDFKit comes with a single page PDF reader with many features implemented right out of the box. Simply create a new PDFViewController, pass it a document and display it like any other view controller. It includes support for forms, a page scrubber and page scrolling.
Swift
Objective-C
Although written in Swift, the core reader can be used in Objective-C.
Single Page Collection View
This collection view renders a PDF in its entirety one page at a time in photo-slideshow style.
Its delegate methods are implemented as follows:
Forms
User-interactable forms are supported by UXMPDFKit, but only partially. Currently only PDF's versions 1.6 & 1.7 render correctly.
Form features implemented:
- [x] Signatures
- [x] Text Fields
- [x] Checkboxes
- [ ] Radio Buttons
- [ ] Choice Boxes
Form parsing and handling is taken care of by the PDFFormViewController. It takes a document, and then is passed a PDFPageContentView to render form elements onto.
PDF rewriting is not currently supported, but flattening inputed data onto the PDF is. To render the form information onto the document, call:
Annotations
User annotations are supported at a basic level, however instead of being written onto the PDF, are burned on at the time of saving.
Current annotation types available:
- Pen
- Highlighter
- Textbox
All annotations are stored in memory until being rendered back onto the PDF by the PDFRenderer.
To create a new annotation type, you must extend the following protocol:
An annotation should be an object that contains its position and value, not a view. Because annotations are written onto temporary objects, they should be created, not passed by reference each time mutableView()
is called.
Additionally, it is recommended that the view passed by mutableView()
extend ResizableView
as this allows the annotation to be moved, resized and deleted individually.
In order for annotations to be able to be listed inside of the toolbar, they must also extend PDFAnnotationButtonable
.
Actions
Partial action support was added in version 0.3.0 and will be increased upon in future versions.
Currently supported actions:
- [x] External URL
- [x] Go To (internal jump to page index)
- [ ] Remote Go To
- [ ] Named
- [ ] Launch
- [ ] Javascript
- [ ] Rich Media
Tapped actions are passed to your view controller by the PDFSinglePageViewer in its contentDelegate
Renderer
In order to perform write operations back onto a PDF in an efficient format, a renderer is used. Each type of form, annotation, etc that needs to be rendered back onto the PDF should extend the following protocol:
Controllers or objects that extend this protocol can then be passed to the PDFRenderer to be written onto a temporary document or saved permanently onto the document.
Author
Chris Anderson:
License
UXMPDFKit is available under the MIT license. See the LICENSE file for more info.