Skip to content

Installation

huzpsb edited this page Oct 25, 2026 · 1 revision

Installation

pdfcpu2 is a single static binary built from pure Go. No runtime dependencies, no cgo, no system libraries.

From source

git clone https://github.com/huzpsb/pdfcpu2.git
cd pdfcpu2
go mod vendor   # vendor/ is not committed; regenerate before building
go build ./cmd/pdfcpu2

The resulting pdfcpu2 (or pdfcpu2.exe) is fully self-contained: fonts, core PDF resources and the embedded OCR models are compiled in. Cross-compile anywhere Go runs:

GOOS=linux   GOARCH=amd64 go build -o pdfcpu2_linux_amd64       ./cmd/pdfcpu2
GOOS=darwin  GOARCH=arm64 go build -o pdfcpu2_darwin_arm64      ./cmd/pdfcpu2
GOOS=windows GOARCH=amd64 go build -o pdfcpu2_windows_amd64.exe ./cmd/pdfcpu2

Offline build environments need a populated module cache before go mod vendor succeeds.

Using it as a Go library

go get github.com/huzpsb/pdfcpu2
import (
	"github.com/huzpsb/pdfcpu2/pkg/api"
	"github.com/huzpsb/pdfcpu2/pkg/pdfcpu/model"
)

See Go API for the package layout and coding patterns.

Shell completion

pdfcpu2 completion bash       # bash
pdfcpu2 completion zsh        # zsh
pdfcpu2 completion fish       # fish
pdfcpu2 completion powershell # PowerShell

Example (bash, persistent):

pdfcpu2 completion bash > /etc/bash_completion.d/pdfcpu2

Example (PowerShell, current session):

pdfcpu2 completion powershell | Out-String | Invoke-Expression

First run

Most commands work out of the box with zero configuration. On first use pdfcpu2 may create a small configuration directory (config.yml, user fonts, trusted certificates) — see Configuration to control, relocate or disable that.

pdfcpu2 validate in.pdf

To run fully stateless without touching the file system:

pdfcpu2 --conf disable validate in.pdf

Verify your build

pdfcpu2 version
pdfcpu2 paper          # lists supported paper sizes
pdfcpu2 fonts list     # lists usable fonts incl. the 14 core fonts

Clone this wiki locally