PDFGenerator alternatives and similar libraries
Based on the "Utility" category.
Alternatively, view PDFGenerator alternatives based on common mentions on social networks and blogs.
-
SwifterSwift
:A handy collection of more than 360 native Swift 3 extensions to boost your productivity. -
SwiftGen
A collection of Swift tools to generate Swift code (enums for your assets, storyboards, Localizable.strings, …) -
R.swift
Tool to get strong typed, autocompleted resources like images, cells and segues. -
SwiftGen-Storyboard
A tool to auto-generate Swift enums for all your Storyboards, Scenes and Segues constants + appropriate convenience accessors. -
ExSwift
a set of Swift extensions for standard types and classes. -
swift-protobuf
A plugin and runtime library for using Google's Protocol Buffer. -
EZSwiftExtensions
How Swift standard types and classes were supposed to work. -
DifferenceKit
💻 A fast and flexible O(n) difference algorithm framework for Swift collection. -
Result
Swift type modelling the success/failure of arbitrary operations. -
LifetimeTracker
LifetimeTracker can surface retain cycle / memory issues right as you develop your application, and it will surface them to you immediately, so you can find them with more ease. -
Device
Light weight tool for detecting the current device and screen size written in swift. -
WhatsNew
Showcase new features after an app update similar to Pages, Numbers and Keynote. -
SwiftLinkPreview
It makes a preview from an url, grabbing all information such as title, relevant texts and images. -
Codextended
Extensions giving Codable API type inference super powers. -
Popsicle
Delightful, extensible Swift value interpolation framework. -
PinpointKit
An open-source iOS library in Swift that lets your testers and users send feedback with annotated screenshots and logs using a simple gesture. -
SwiftyJSONAccelerator
OSX app to generate Swift 3 code for models from JSON. -
Highlighter
Highlight whatever you want! Highlighter will magically find UI objects such as UILabel, UITextView, UITexTfield, UIButton in your UITableViewCell or other Class. -
Compass
Compass helps you setup a central navigation system for your application. -
Playbook
📘A library for isolated developing UI components and automatically snapshots of them. -
ReadabilityKit
Preview extractor for news, articles and full-texts in Swift -
ObjectiveKit
Swift-friendly API for Objective C runtime functions. -
Pythonic.swift
Pythonic tool-belt for Swift: a Swift implementation of selected parts of Python standard library. -
SwiftyUtils
All the reusable code that we need in each project. -
Prototope
Swift library of lightweight interfaces for prototyping, bridged to JS. -
Butterfly
A lightweight library for integrating bug-report and feedback features with shake-motion event.
Scout APM - Leading-edge performance monitoring starting at $39/month
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of PDFGenerator or a related project?
README
Features | Requirements | Installation | Usage | Communication | LICENSE
PDFGenerator
PDFGenerator
is a simple PDF generator that generates with UIView
, UIImage
, ...etc .
do {
let page: [PDFPage] = [
.whitePage(CGSize(width: 200.0, height: 100.0)),
.image(image1)
.image(image2)
.imagePath(lastPageImagePath)
.whitePage(CGSize(width: 200.0, height: 100.0))
]
let path = NSTemporaryDirectory().appending("sample1.pdf")
try PDFGenerator.generate(page, to: path, password: "123456")
} catch let error {
print(error)
}
Features
- Swift 5 is ready :pray:
- Multiple pages support.
- Also generate PDF with
image path
,image binary
,image ref (CGImage)
- Good memory management.
- UIScrollView support : If view is
UIScrollView
,UITableView
,UICollectionView
,UIWebView
, drawn whole content. - Outputs as binary(
Data
) or writes to Disk(in given file path) directly. - Corresponding to Error-Handling. Strange PDF has never been generated!!.
- DPI support. : Default dpi is 72.
- Password protection support.
Requirements
- iOS 9.0+
- Xcode 11+
- Swift 5.1
Installation
Carthage
- Add the following to your Cartfile:
github "sgr-ksmt/PDFGenerator" ~> 3.1
- Then run command:
$ carthage update
- Add the framework as described. Details: Carthage Readme
CocoaPods
PDFGenerator is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PDFGenerator', '~> 3.1'
and run pod install
Usage
Generate from view(s) or image(s)
- UIView → PDF
func generatePDF() {
let v1 = UIScrollView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 100.0))
let v2 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 200.0))
let v3 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 200.0))
v1.backgroundColor = .red
v1.contentSize = CGSize(width: 100.0, height: 200.0)
v2.backgroundColor = .green
v3.backgroundColor = .blue
let dst = URL(fileURLWithPath: NSTemporaryDirectory().appending("sample1.pdf"))
// outputs as Data
do {
let data = try PDFGenerator.generated(by: [v1, v2, v3])
try data.write(to: dst, options: .atomic)
} catch (let error) {
print(error)
}
// writes to Disk directly.
do {
try PDFGenerator.generate([v1, v2, v3], to: dst)
} catch (let error) {
print(error)
}
}
Also PDF can generate from image(s), image path(s) same as example.
Generate from PDFPage object
- (UIVIew or UIImage) → PDF
Use PDFPage
.
public enum PDFPage {
case whitePage(CGSize) // = A white view
case view(UIView)
case image(UIImage)
case imagePath(String)
case binary(Data)
case imageRef(CGImage)
}
func generatePDF() {
let v1 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 100.0))
v1.backgroundColor = .red
let v2 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 200.0))
v2.backgroundColor = .green
let page1 = PDFPage.View(v1)
let page2 = PDFPage.View(v2)
let page3 = PDFPage.WhitePage(CGSizeMake(200, 100))
let page4 = PDFPage.Image(UIImage(contentsOfFile: "path/to/image1.png")!)
let page5 = PDFPage.ImagePath("path/to/image2.png")
let pages = [page1, page2, page3, page4, page5]
let dst = NSTemporaryDirectory().appending("sample1.pdf")
do {
try PDFGenerator.generate(pages, to: dst)
} catch (let e) {
print(e)
}
}
Generate custom dpi PDF
// generate dpi300 PDF (default: 72dpi)
func generatePDF() {
let v1 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 100.0))
v1.backgroundColor = .red
let v2 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 200.0))
v2.backgroundColor = .green
let page1 = PDFPage.View(v1)
let page2 = PDFPage.View(v2)
let pages = [page1, page2]
let dst = NSTemporaryDirectory().appending("sample1.pdf")
do {
try PDFGenerator.generate(pages, to: dst, dpi: .dpi_300)
} catch (let e) {
print(e)
}
}
Password protection
// generate PDF with password: 123456
func generatePDF() {
let v1 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 100.0))
v1.backgroundColor = .red
let v2 = UIView(frame: CGRect(x: 0.0,y: 0, width: 100.0, height: 200.0))
v2.backgroundColor = .green
let page1 = PDFPage.view(v1)
let page2 = PDFPage.view(v2)
let pages = [page1, page2]
let dst = NSTemporaryDirectory().appending("sample1.pdf")
do {
try PDFGenerator.generate(pages, to: dst, password: "123456")
// or use PDFPassword model
try PDFGenerator.generate(pages, to: dst, password: PDFPassword("123456"))
// or use PDFPassword model and set user/owner password
try PDFGenerator.generate(pages, to: dst, password: PDFPassword(user: "123456", owner: "abcdef"))
} catch let error {
print(error)
}
}
Communication
- If you found a bug, please open an issue. :bow:
- Also, if you have a feature request, please open an issue. :thumbsup:
- If you want to contribute, submit a pull request.:muscle:
License
PDFGenerator is under MIT license. See the [LICENSE](LICENSE) file for more info.
*Note that all licence references and agreements mentioned in the PDFGenerator README section above
are relevant to that project's source code only.