Repository navigation
Validate
huzpsb edited this page Oct 25, 2026
·
1 revision
Check PDFs for specification compliance — the first command to run on any unknown file. Validates against PDF 32000-1:2008 (PDF 1.7) plus basic PDF 2.0 checks.
pdfcpu2 validate [-m strict|relaxed] [-l] [--opt] inFile...
| Flag | Meaning |
|---|---|
-m, --mode |
relaxed (default): tolerates common spec violations; strict: pedantic |
-l, --links |
check for broken links |
--opt |
optimize resources (fonts, forms, images) during validation |
--progress |
print each input before validating it |
inFile... |
multiple files; - reads from stdin |
pdfcpu2 validate in.pdf
pdfcpu2 validate -m strict in.pdf
pdfcpu2 validate -l *.pdf
cat in.pdf | pdfcpu2 validate -package main
import (
"context"
"github.com/huzpsb/pdfcpu2/pkg/api"
"github.com/huzpsb/pdfcpu2/pkg/pdfcpu/model"
)
func main() {
ctx := context.Background()
conf := model.NewDefaultConfiguration()
// Simple pass/fail
if err := api.ValidateFile(ctx, "in.pdf", conf, nil); err != nil {
panic(err)
}
// Structured report you can inspect programmatically
report, err := api.ValidateFileWithReport(ctx, "in.pdf", conf, nil)
if err != nil {
panic(err)
}
_ = report
// Batch
_ = api.ValidateFiles(ctx, []string{"a.pdf", "b.pdf"}, conf, nil)
}Lower-level: api.ReadContextFile(ctx, inFile) + api.ValidateContext(ctx, ctxObj) give you full control over the parsed document — see Go API.
pdfcpu2 wiki
Getting started
Fork features
Inspect
Document
Pages
Content
Extract
Resources
Security
Viewer
Trust
Developers