pdfcpu

module
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: Apache-2.0

README

pdfcpu: PDF tooling for Go and the command line

Test Coverage Status Go Reference License Sponsor

pdfcpu is a PDF processing library and command-line tool written in Go. It supports validation, optimization, encryption, signing, document assembly, content extraction, and other common PDF operations.

pdfcpu supports PDF versions through PDF 2.0 (ISO 32000-2). PDF 2.0 validation support is basic and continuously improving.

  Horst Rutter, the maintainer of pdfcpu, is a member of the PDF Association.


Installation

Command-line interface Go API
CLI Installation instructions API Installation instructions

Usage

CLI

Validate a PDF:

pdfcpu validate input.pdf

Merge two PDFs:

pdfcpu merge merged.pdf in1.pdf in2.pdf
Go API

See API documentation for usage examples.


Features

  • Validate, optimize, split, trim, and merge PDFs
  • Extract and manipulate images, fonts, and metadata
  • Encrypt and decrypt PDFs
  • Resize and rotate pages
  • Add and remove stamps and watermarks
  • Validate signature integrity, report signature evidence, and remove signatures
  • Manage attachments and portfolios

Examples

Selected examples:

         

       

 


Commands

Complete list of supported commands:

annotations attachments booklet
bookmarks boxes certificates
change owner password change user password collect
config create crop
cut decrypt encrypt
extract fonts form
grid images import
info keywords merge
ndown nup optimize
pagelayout pagemode pages
permissions portfolio poster
properties resize rotate
signatures split stamp
trim validate viewerpref
watermark zoom

Motivation

pdfcpu aims to provide comprehensive PDF processing capabilities implemented in Go for both individual files and automated batch processing.

It focuses on correctness, robustness and independence from external dependencies.


Focus

  • comprehensive PDF processing functionality
  • minimal external dependencies
  • predictable and stable behavior

Documentation

CLI
  • Command help: pdfcpu [command] --help
Go API

Contributing

Contributions are welcome. See the contributing guidelines and the complete list of contributors.

Reporting PDF issues

For triage, we use Adobe Acrobat Reader and macOS Preview as practical compatibility references.
Reports are especially helpful when a PDF opens in either application but cannot be processed by pdfcpu, as these cases may reveal opportunities to improve validation or parser compatibility.
If neither application can open the PDF, it is unlikely that pdfcpu will be able to process it reliably.

Start by validating the file:

pdfcpu validate -vv <file.pdf>

Include the command, its verbose output, and a sample PDF with the report.
Please submit only files that you have permission to share and that contain no confidential information or personal data.


Security

Please do not report security vulnerabilities through public GitHub issues.
See the security policy for private reporting instructions.


Code of Conduct

This project is released with a Contributor Code of Conduct. By participating, you agree to abide by its terms.


Disclaimer

Use of pdfcpu assumes compliance with all applicable copyrights for any processed PDF content, including embedded resources such as fonts and images.

Gopher artwork by Renee French


License

Apache License 2.0


Directories

Path Synopsis
cmd
pdfcpu command
Package main provides the command line for interacting with pdfcpu.
Package main provides the command line for interacting with pdfcpu.
internal
corefont/metrics
Package metrics provides font metrics for the PDF standard fonts.
Package metrics provides font metrics for the PDF standard fonts.
fileutil
Package fileutil provides internal cross-platform filesystem operations.
Package fileutil provides internal cross-platform filesystem operations.
filter/lzw
Package lzw is an enhanced version of compress/lzw.
Package lzw is an enhanced version of compress/lzw.
pkg
api
Package api lets you integrate pdfcpu's operations into your Go backend.
Package api lets you integrate pdfcpu's operations into your Go backend.
cli
Package cli provides pdfcpu command line processing.
Package cli provides pdfcpu command line processing.
filter
Package filter contains PDF filter implementations.
Package filter contains PDF filter implementations.
font
Package font provides support for TrueType fonts.
Package font provides support for TrueType fonts.
log
Package log provides a logging abstraction.
Package log provides a logging abstraction.
pdfcpu
Package pdfcpu is a PDF processing library written in Go supporting encryption.
Package pdfcpu is a PDF processing library written in Go supporting encryption.
pdfcpu/pkcs7
Package pkcs7 implements parsing and generation of some PKCS#7 structures.
Package pkcs7 implements parsing and generation of some PKCS#7 structures.
pdfcpu/validate
Package validate implements validation against PDF 32000-1:2008.
Package validate implements validation against PDF 32000-1:2008.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL