UKPDFReader is a simple framework for reading PDF in iOS
To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 11.0+
- Swift 4
UKPDFReader is available through CocoaPods.
To install it, simply add the following line to your Podfile:
pod 'UKPDFReader'
use_frameworks!
Then run pod install
with CocoaPods 1.0 or newer.
import UKPDFReader
Once the pdf file in NSBundle, get the bundle path
guard let path = Bundle.main.url(forResource: "swift", withExtension: "pdf") else {
print("failed to unwrap fileURL")
return
}
Create an instance of UKPDFViewController by providing 'path of pdf file' and passing self as delegate
let pdfViewController = UKPDFViewController(pdfUrl: path, delegate: self)
Customize the PDFReader by providing some values. All values are optional
pdfViewController.pdfDisplayDirection = .horizontal
pdfViewController.showContentsButton = true
pdfViewController.pdfTitle = "UKPdfReader"
pdfViewController.customizeNavBar(titleTextcolor: .red, titleFont: UIFont.boldSystemFont(ofSize: 24.0), buttonTextcolor: .blue, buttonFont: UIFont.boldSystemFont(ofSize: 18.0))
Then, Presenting the UKPDFViewController
let navController = UINavigationController.init(rootViewController: pdfViewController)
present(navController, animated: true, completion: nil)
UKPDFReader is available under the MIT license. See the LICENSE file for more info.