PDFBlocks is a powerful but easy to use PDF document and report generation library written in Swift for Apple platforms. Inspired by SwiftUI, it allows documents to be expressed with a declarative syntax. You just declare what you want printed within appropriate layout structures, and PDFBlocks takes care of positioning, pagination, and all the rest.
These sample documents and accompanying code provide examples of some of some of the layout capabilities of PDFBlocks.
Columns | Stack Layout | Report |
---|---|---|
Code | Code | Code |
Vector Drawing | Gradient Fill | Custom Components |
---|---|---|
Code | Code | Code |
PDFBlocks works very well with Xcode Previews. Instantly see your document rendered as a PDF as you code.
Xcode Previews ia also a great way to get a quick start with PDFBlocks before installing it into your own project.
- Download the PDFBlocks project.
- Open Package.swift in Xcode.
- Navigate to Examples directory
- Select scheme PDFBlocks-Package or PDFBlocksExamples
- Puruse the example documents. Modify them if you wish and see the results within Xcode.
PDFBlocks is distributed using the Swift Package Manager. To install it into a project, add it as a dependency within your Package.swift
manifest:
let package = Package(
...
dependencies: [
.package(url: "https://github.com/dkyowell/pdfblocks.git", from: "0.2.4")
],
...
)
Then import PDFBlocks wherever you’d like to use it:
import PDFBlocks
This is a beta release. The API and layout heuristics could change up until the 1.0 release.
Open an issue with questions or feature requests. I am actively developing this project and will try to accomodate requests that fit within the goals of the project. You can also send me an email at dkyowell.opensource@gmail.com.