Latest 1.0
License MIT
Platforms ios 10.0

This generates PDF (iOS 10 and above) from UIViewController using native code. This can also helps to edit PDF (iOS 11 and above) using UIView and Images. It can generate Single Page and Multipage PDF (iOS 11 and above).



CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate MBPDFGenerator into your Xcode project using CocoaPods, specify it in your Podfile:

target '<Your Target Name>' do
    pod 'MBPDFGenerator'

How to Use

// Generate single page PDF
let url = try? MBSinglePagePDFGenerator.exportPDF(controller: self)

// you can use keepPDFPageSize as fasle to use actual UIViewController layout
let url = try? MBSinglePagePDFGenerator.exportPDF(controller: self, keepPDFPageSize: false)
// Generate mutli page PDF, it uses datasouece to generate PDF

   let pdf = MBPDFGenerator(dataSource: self)

   // set if you can actual UIViewController layout vs actula PDF page sie
   pdf.keepPDFPageSize = false

   // Generate PDF
   let url = try? pdf.exportPDF()

// Data source for PDFGenerator
 MBPDFGeneratorDataSource {

    func numberOfPages() -> Int {
        return //number of pages for PDF

    func page(at index: Int) -> UIViewController {
        return //UIViewConoller for give page index

Edit PDF

// You can edit any existing PDF
    let anyView = UIView()

    // Create location to add on PDF
    let viewBounds = CGRect(x: 10, y: 20, width: anyView.bounds.width, height: anyView.bounds.height)

    // Create view annomation from view that need to add
    let viewAnnotation = MBPDFAnnotationView(view: anyView, bounds: viewBounds, withProperties: nil)

    // Create PDF object from existing PDF url
    let pdf = MBPDFGenerator(url: <Existing PDF URL>)

    // Somply add annonation at specified page index
    if pdf?.addAnnotation(viewAnnotation, atPage: 0) {
        // Generate New edited PDF
        controller.url = try? pdf?.exportPDF()



Latest podspec

    "name": "MBPDFGenerator",
    "version": "1.0",
    "summary": "This generates PDF from UIViewController using native code.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Swifty-iOS": "[email protected]"
    "platforms": {
        "ios": "10.0"
    "source": {
        "git": "",
        "tag": "1.0"
    "source_files": "Source/*.swift",
    "swift_version": "5.0"

Pin It on Pinterest

Share This