/iOS-PDF-Reader

PDF Reader for iOS written in Swift

Primary LanguageSwiftMIT LicenseMIT

iOS-PDF-Reader

Version License Platform Carthage compatible

PDF Reader for iOS written in Swift

  • Fast and lightweight
  • Thumbnail bar on the bottom to navigate to a specific page
  • Print button on the top right

Example

Example

Requirements

  • iOS 8.0+

Installation

CocoaPods

To install it, simply add the following line to your Podfile:

pod 'PDFReader'

You will also need to make sure you're opting into using frameworks:

use_frameworks!

Then run pod install with CocoaPods 1.0 or newer.

Carthage

To install it, simply add the following line to your Cartfile:

github "Alua-Kinzhebayeva/iOS-PDF-Reader"

Run carthage update to build the framework and drag the built PDFReader.framework into your Xcode project.

Usage

let documentURL = Bundle.main.url(forResource: "Cupcakes", withExtension: "pdf")!
let document = PDFDocument(fileURL: documentURL)!

let readerController = PDFViewController.createNew(with: document)
navigationController?.pushViewController(readerController, animated: true)

Customizations

Controller Title

PDFViewController.createNew(with: document, title: "Favorite Cupcakes")

Background Color

controller.backgroundColor = .white

Action Button Image and Action

Available Action Styles
/// Action button style
public enum ActionStyle {
    /// Brings up a print modal allowing user to print current PDF
    case print

    /// Brings up an activity sheet to share or open PDF in another app
    case activitySheet

    /// Performs a custom action
    case customAction((Void) -> ())
}
let actionButtonImage = UIImage(named: "cupcakeActionButtonImage")
PDFViewController.createNew(with: document, title: "Favorite Cupcakes", actionButtonImage: actionButtonImage, actionStyle: .activitySheet)

Acknowledgements

Inspired by PDF Reader https://github.com/vfr/Reader and Apple's example on TiledScrollView