pdfcpu

Logo

PDF tooling for Go and the command line.

View the Project on GitHub pdfcpu/pdfcpu


Changelog
Future Directions

About

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.

Real-world PDFs

The parser handles many files that violate the specification and repairs common issues while processing.

CLI and API

Use pdfcpu from scripts and terminals, or embed the same capabilities in Go applications.

Broad Processing

Validate, optimize, split, merge, watermark, encrypt, inspect, extract, and manipulate PDF files.

Modern PDF Work

pdfcpu supports PDF 1.7 and includes evolving support for PDF 2.0 validation and writing.

PDF 2.0

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.

Usage

pdfcpu has two primary entry points:

Command Line

Use the CLI to build PDF processing pipelines, including workflows for encrypted files.

Go Library

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.