Git Product home page Git Product logo

simplepdfviewer's Introduction

SimplePDFViewer

An easy to use UIViewController that renders local & remote PDF's with basic customization and functionality.

Version License Platform

Introduction

SimplePDFViewer lets you show PDF documents when very little customization/advanced functionality is required. The library is built on top of Apple's PDFKit.

Standard VC Error VC Dialog

Features include:

  • Initialization from local/remote URL, raw data, or PDFDocument
  • Jump-to-page dialog
  • Page tracking
  • Export file using standard iOS sharesheet
  • Basic customization (tint, error message, VC title, etc.)

The library was created to provide basic PDF functionality for another application. It will be maintained by myself, Frank Jia. If there is demand, I'm open to adding functionality and additional customization. Don't hesistate to reach out at [email protected].

Usage

SimplePDFViewer is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SimplePDFViewer'

To use SimplePDFViewer, import SimplePDFViewer. You can then instantiate an instance of the VC like so:

let pdfVC = SimplePDFViewController(urlString: ViewController.TEST_PDF_URL)
pdfVC.viewTitle = "Test View Title" // Custom view title on top bar
pdfVC.tint = .red // Tint applies to all views in the VC
pdfVC.exportPDFName = "TestExportPDF" // File name for sharing, default is "Document"
pdfVC.errorMessage = "Uh oh!" // Custom error message if PDF fails to load
pdfVC.dismissalDelegate = self // Customize what happens when close button is pressed

There are also constructors for the VC from a URL, PDFDocument, or raw Data. You can then present the VC using:

present(pdfVC, animated: true, completion: nil) // Presents modally
navigationController?.pushViewController(pdfVC, animated: true) // Pushes onto navigation stack

Delegates

There is currently one delegate: SimplePDFViewOnDismissDelegate Here's an example implementation:

func didDismiss(_ sender: SimplePDFViewController) {
// It is your responsibility to dismiss the VC
sender.dismiss(animated: true, completion: nil)
// Do whatever else you want to do
print("Hello!")
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

License

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

simplepdfviewer's People

Contributors

frankfka avatar

Stargazers

West avatar Maher Saad Tag avatar  avatar Mr.Sanchez avatar MohsinAli avatar

Watchers

MohsinAli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.