
PDF tooling for Go and the command line.
View the Project on GitHub pdfcpu/pdfcpu
pdfcpu is PDF tooling for Go and the command line. It is built for command-line workflows, server-side automation, and Go applications that need direct control over PDF files without pulling in a heavyweight runtime.
The parser handles many files that violate the specification and repairs common issues while processing.
Use pdfcpu from scripts and terminals, or embed the same capabilities in Go applications.
Validate, optimize, split, merge, watermark, encrypt, inspect, extract, and manipulate PDF files.
pdfcpu supports PDF 1.7 and includes evolving support for PDF 2.0 validation and writing.
PDF 2.0 support is ongoing and grows from practical use cases.
New features are implemented when there is enough real-world material to test against. If you need support for a specific feature, please open an issue and include a sample file where possible.
pdfcpu has two primary entry points:
Use the CLI to build PDF processing pipelines, including workflows for encrypted files.
Use the API to integrate PDF processing into Go applications. Most operations are available in file-based and stream-based forms:
func OptimizeFile(inFile, outFile string, conf *pdf.Configuration) error
func Optimize(rs io.ReadSeeker, w io.Writer, conf *pdf.Configuration) error
More examples are available at pkg.go.dev.
For complete, real-world usage scenarios, see the API tests.