pdfcpu /pdfcpu

PDF tooling for Go and the command line.

★ 8,909⑂ 650👁 81⑃ 289● 1,151▤ 77
GoApache-2.0Created 2017-06-18pdfcpu.io/
下载:v0.16.4v0.16.4 ↓0.16.42026-10-27
+1
日增长
8,909
stars
650
forks
81
watchers
289
prs
1,151
issues
77
releases

README

pdfcpu: PDF tooling for Go and the command line








  


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.

 Local images in create and form input

Local images in create, form fill, and JSON/CSV form multifill are confined to
an allowed directory. 
API callers must set conf.LocalImageRoot to enable them. The CLI defaults to its working
directory and localImageRoot in config.yml selects another root.

See local image access for configuration examples, path
restrictions, migration instructions and security limitations.

---

 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

 Project documentation: https://pdfcpu.io
 Changelog: https://pdfcpu.io/changelog
 Contributing guidelines
 Security policy

 CLI

 Command help: pdfcpu [command] --help

 Go API

 Package documentation: https://pkg.go.dev/github.com/pdfcpu/pdfcpu
 API documentation: https://pkg.go.dev/github.com/pdfcpu/pdfcpu/pkg/api
 Examples:

   https://github.com/pdfcpu/pdfc

Top issues

Discussions

Latest release

v0.16.4 v0.16.4 2026-10-27
pdfcpu v0.16.4

This is a security update for crafted PDFs and form or create data that could cause excessive CPU or memory use or terminate a
process. 

Additive Go API  Changes: types.DecodeStreamFunc and types.NewLazyObjectStreamObjectWithDecoder. 
Existing constructors and signatures remain unchanged.
Requires Go 1.26 or later.

Release binaries were built with Go 1.27.3, which includes security fixes for crypto/x509.

1) Unbounded object traversal — GHSA-2623-w998-vcr4:

Long chains of PDF objects could exhaust the Go stack and terminate the process during optimization while 

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON