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

Requirements

  • IOS 8.0 +

CocoaPods

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

pod 'PDFReader'Copy the code

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

use_frameworks!Copy the code

Then run pod install with CocoaPods 1.0 or newer.

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)Copy the code

Controller Title

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

Action Button Image and Action

Override the default backbutton

///Create a button to override the default behavior of the backbutton. In the below example we create a cancel button which  will call our myCancelFunc method on tap.
let myBackButton = UIBarButtonItem(title: "Cancel".style:.done.target: self.action:  #selector(self.myCancelFunc(_ :)))///Provide your button to createNew using the backButton parameter. The PDFViewController will then use your button instead  of the default backbutton.
PDFViewController.createNew(with: document, title: "Favorite Cupcakes".backButton: myBackButton)
Copy the code