All Projects → uxmstudio → Uxmpdfkit

uxmstudio / Uxmpdfkit

Licence: mit
An iOS PDF viewer and annotator written in Swift that can be embedded into any application.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Uxmpdfkit

Cluster
Easy Map Annotation Clustering 📍
Stars: ✭ 1,132 (+335.38%)
Mutual labels:  annotations, cocoapods, carthage
Pdfgenerator
A simple generator of PDF written in Swift.
Stars: ✭ 629 (+141.92%)
Mutual labels:  pdf, cocoapods, carthage
Simplecheckbox
A simple Checkbox
Stars: ✭ 253 (-2.69%)
Mutual labels:  cocoapods, carthage
Localize
Localize is a framework writed in swift to localize your projects easier improves i18n, including storyboards and strings.
Stars: ✭ 253 (-2.69%)
Mutual labels:  cocoapods, carthage
Datez
📆 Breeze through Date, DateComponents, and TimeInterval with Swift!
Stars: ✭ 254 (-2.31%)
Mutual labels:  cocoapods, carthage
Alertift
Swifty, modern UIAlertController wrapper.
Stars: ✭ 242 (-6.92%)
Mutual labels:  cocoapods, carthage
Harpy
Harpy checks a user's currently installed version of your iOS app against the version that is currently available in the App Store. If a new version is available, an alert can be presented to the user informing them of the newer version, and giving them the option to update the application.
Stars: ✭ 2,619 (+907.31%)
Mutual labels:  cocoapods, carthage
Tppdf
TPPDF is a simple-to-use PDF builder for iOS
Stars: ✭ 444 (+70.77%)
Mutual labels:  pdf, cocoapods
Gifu
High-performance animated GIF support for iOS in Swift
Stars: ✭ 2,703 (+939.62%)
Mutual labels:  cocoapods, carthage
Swiftytexttable
A lightweight library for generating text tables.
Stars: ✭ 252 (-3.08%)
Mutual labels:  cocoapods, carthage
Pyhanko
pyHanko: sign and stamp PDF files
Stars: ✭ 77 (-70.38%)
Mutual labels:  pdf, signature
Rmanns
Remove annotations from the e-books downloaded from the pirate sites, such as www.it-ebooks.info, www.allitebooks.com and another ones.
Stars: ✭ 30 (-88.46%)
Mutual labels:  annotations, pdf
Sensor Visualizer Kit
Visualize iOS sensors for live presentations, iOS AppStore demos, Apple Store prototypes, design reviews.
Stars: ✭ 242 (-6.92%)
Mutual labels:  cocoapods, carthage
Swiftpagemenu
Customizable Page Tab Menu Controller 👍
Stars: ✭ 233 (-10.38%)
Mutual labels:  cocoapods, carthage
Wechatkit
一款快速实现微信第三方登录的框架(Swift版) SDK 1.8.5
Stars: ✭ 249 (-4.23%)
Mutual labels:  cocoapods, carthage
Swipycell
Easy to use UITableViewCell implementing swiping to trigger actions.
Stars: ✭ 230 (-11.54%)
Mutual labels:  cocoapods, carthage
Colorizeswift
Terminal string styling for Swift.
Stars: ✭ 253 (-2.69%)
Mutual labels:  cocoapods, carthage
Admozaiccollectionviewlayout
ADMozaicCollectionViewLayout is yet another UICollectionViewLayout subclass that implements "brick", "mozaic" or Pinterest style layout.
Stars: ✭ 226 (-13.08%)
Mutual labels:  cocoapods, carthage
Sync
JSON to Core Data and back. Swift Core Data Sync.
Stars: ✭ 2,538 (+876.15%)
Mutual labels:  cocoapods, carthage
Remarks
Extract highlights, scribbles, and annotations from PDFs marked with the reMarkable tablet. Export to Markdown, PDF, PNG, and SVG
Stars: ✭ 94 (-63.85%)
Mutual labels:  annotations, pdf

UXM Token Field

CI Status Version Swift Carthage Compatible License Platform

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:

pod "UXMPDFKit"

If you wish to use the Swift 2.3 version, use the following instead:

pod "UXMPDFKit", "~> 0.3.0"

Carthage

UXMPDFKit is also available through Carthage. To install just write into your Cartfile:

github "uxmstudio/UXMPDFKit"

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

let path = Bundle.main.path(forResource: "sample", ofType: "pdf")!
let document = try! PDFDocument(filePath: path, password: "password_if_needed")
let pdf = PDFViewController(document: document)

self.navigationController?.pushViewController(pdf, animated: true)

Objective-C

Although written in Swift, the core reader can be used in Objective-C.

NSError *error;
NSString *path = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"];
PDFDocument *document = [[PDFDocument alloc] initWithFilePath:path password:@"password_if_needed" error:&error];
PDFViewController *pdfVC = [[PDFViewController alloc] initWithDocument:document];

[self.navigationController pushViewController:pdfVC animated:true];

Single Page Collection View

This collection view renders a PDF in its entirety one page at a time in photo-slideshow style.

let collectionView = PDFSinglePageViewer(frame: self.view.bounds, document: self.document)
collectionView.singlePageDelegate = self

Its delegate methods are implemented as follows:

func singlePageViewer(collectionView: PDFSinglePageViewer, didDisplayPage page: Int)
func singlePageViewer(collectionView: PDFSinglePageViewer, loadedContent content: PDFPageContentView)
func singlePageViewer(collectionView: PDFSinglePageViewer, selectedAction action: PDFAction)

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.

let formController = PDFFormViewController(document: self.document)
formController.showForm(contentView)

PDF rewriting is not currently supported, but flattening inputed data onto the PDF is. To render the form information onto the document, call:

func renderFormOntoPDF() -> NSURL // Returns a temporary url
func save(url: NSURL) -> Bool // Writes 

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:

public protocol PDFAnnotation {

    /// The page number the annotation is located on
    var page: Int? { get set }

    /// Unique identifier to be able to select annotation by
    var uuid: String { get }

    /// Boolean representing if the annotation has been saved
    var saved: Bool { get set }

    var delegate: PDFAnnotationEvent? { get set }

    /// Force implementations to have an init
    init()

    /// A function to return a view composed of the annotations properties
    func mutableView() -> UIView

    /// Set of handlers to pass touches to annotation
    func touchStarted(_ touch: UITouch, point: CGPoint)
    func touchMoved(_ touch: UITouch, point: CGPoint)
    func touchEnded(_ touch: UITouch, point: CGPoint)

    /// Method to save annotation locally
    func save()
    func drawInContext(_ context: CGContext)

    func didEnd()

    func encode(with aCoder: NSCoder)
}

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.

public protocol PDFAnnotationButtonable: PDFAnnotation {

    /// Name for UIBarButtonItem representation of annotation
    static var name: String? { get }

    /// Image for UIBarButtonItem representation of annotation 
    static var buttonImage: UIImage? { get }
}

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:

protocol PDFRenderer {
    func render(page: Int, context:CGContext, bounds: CGRect)
}

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.

let renderer = PDFRenderController(document: self.document, controllers: [
    self.annotationController,
    self.formController
])
let pdf = renderer.renderOntoPDF()

Author

Chris Anderson:

License

UXMPDFKit is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].