Batch PDF operations for Swift
MIT License
Batch PDF utilities with simple API for Swift. Declarative API for:
[!NOTE] Currently this package is only a Swift library. A CLI tool and/or GUI frontend may be added in future.
import PDFGadget
let sources = [URL, URL, URL, ...] // URLs to one or more PDF files
let outputDir = URL.desktopDirectory
The steps of loading source PDFs, performing operations, and saving the resulting PDFs can be performed individually:
let pdfGadget = PDFGadget()
try pdfGadget.load(pdfs: sources)
try pdfGadget.perform(operations: [
// one or more operations
])
// access the resulting PDF documents in memory
pdfGadget.pdfDocuments // [PDFDocument]
// or save them as PDF files to disk
try pdfGadget.savePDFs(outputDir: outputDir)
Or a fully automated batch operation can be run with a single call to run()
by passing in a populated instance of PDFGadget.Settings
.
let settings = try PDFGadget.Settings(
sourcePDFs: sources,
outputDir: outputDir,
operations: [
// one or more operations
],
savePDFs: true
)
try PDFGadget().run(using: settings)
The following are single operations that may be used in a batch sequence of operations.
Note: More to be added in future, including: page cropping, more sophisticated annotation editing/filtering/removal.
import PDFGadget
Coded by a bunch of 🐹 hamsters in a trenchcoat that calls itself @orchetect.
Licensed under the MIT license. See LICENSE for details.
If you enjoy using PDFGadget and want to contribute to open-source financially, GitHub sponsorship is much appreciated. Feedback and code contributions are also welcome.
Planned and in-progress features can be found in Issues. Any help is welcome and appreciated.