Skip to content

sumitjagdev/SJSwiftPDFCreator

Repository files navigation

SJPDFCreator

SJPDFCreator framwork is to rendering PDF file by calling several simple methods. You can easily export your pdf by calling an simple method which returns the path.

Installation

  • pod 'SJPDFCreator', '~> 2.2' //xcframeworks - Xcode 12
  • pod 'SJPDFCreator', '~> 2.1' //xcframeworks

OR

  1. pod 'SJPDFCreator', '~> 1.2.2' //Swift 5.1.3 compiler
  2. pod 'SJPDFCreator', '~> 1.3.5' //Swift 5
  3. pod 'SJPDFCreator', '~> 1.3.6' //Swift 5.1

Usage

Start creating PDF using static methods.

  1. Draw line
    SJPDFCreator.drawLine(lineColor: UIColor.blue)

  2. Draw text
    SJPDFCreator.writeText(text: "Rendering Dynamic PDF", bold: true, alignment: .center, fontSize: 20, textColor: UIColor.red)


  1. Draw Key value data
    let dataDict = NSMutableDictionary()
    dataDict.setObject("Sumit_Jagdev", forKey: "User Name" as NSCopying)
    dataDict.setObject("Sumit", forKey: "First Name" as NSCopying)
    dataDict.setObject("Jagdev", forKey: "Last Name" as NSCopying)

    <br /> *SJPDFCreator.writeKeyValueData(dataDict: dataDict)*
    

  1. Draw Ordered Key value data
    let paramDict = NSMutableDictionary()
    paramDict.setValue("Sumit_Jagdev", forKey: "User Name", atIndex: 0)
    paramDict.setValue("Sumit", forKey: "First Name", atIndex: 1)
    paramDict.setValue("Jagdev", forKey: "Last Name", atIndex: 2)
    paramDict.setValue("sumitjagdev12@gmail.com", forKey: "E-Mail", atIndex: 3)
    paramDict.setValue("+91 5656565656", forKey: "Contact Number", atIndex: 4)
    paramDict.setValue("India", forKey: "Address", atIndex: 5)
    SJPDFCreator.writeOrderedKeyValueData(dataDict: paramDict)

  2. Draw Table
    SJPDFCreator.writeTableData(dataArray: dataArray) //Pass an Array of dictionary


  1. Draw Table with total key to draw Items and total of items table
    SJPDFCreator.writeTableData(dataArray: dataArray, addTotal: true, keyForTotal: "Price")

  1. Draw Image
    SJPDFCreator.writeImage(imageName: "iOS10a.jpg", type: nil, width: 200, height: 300, alignment: .center)
    SJPDFCreator.writeImage(imageName: "iOS", type: "png", width: 200, height: 300, alignment: .right)

  1. Finaly export created pdf
    SJPDFCreator.exportWithFileName(fileName: "SJ_DemoPDF") { (isSuccess, error, pdfURL) in
    if isSuccess == true && pdfURL != nil {
    let req = NSURLRequest(url: pdfURL as! URL)
    let webView = UIWebView(frame: self.view.frame)
    webView.loadRequest(req as URLRequest)
    self.view.addSubview(webView)
    }
    }

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

Credits

License

About

SJPDFCreator framwork is to rendering PDF file by calling several simple methods. You can easily export your pdf by calling an simple method which returns the path.

Resources

License

Stars

Watchers

Forks

Packages

No packages published