CLI
The library as a single binary. Verify files and directories, convert, and gate CI on the exit code.
terminal
go install github.com/voidrab/gopdfrab/cmd/gopdfrab@latestterminal
$ gopdfrab verify --profile pdfa2b invoice.pdfFAIL issues=5 invoice.pdf 6.1.3/1 trailer does not contain the required ID keyword 6.2.4.3 device colour (rgb) used without matching OutputIntent 6.2.11.4.1/1 font Helvetica is not embedded 6.2.11.4.1/1 font Helvetica-Bold is not embedded 6.6.2.1/1 document catalog lacks a Metadata entrysummary: pass=0 fail=1 error=0 files=1$ gopdfrab convert --profile pdfa2b invoice.pdf invoice-a2b.pdfoutput: invoice-a2b.pdfiterations: 3result: conformant$ gopdfrab verify --profile pdfa2b invoice-a2b.pdfPASS invoice-a2b.pdfsummary: pass=1 fail=0 error=0 files=1
Usage
verify takes any mix of files and directories and walks directories recursively. convert rewrites a single input.
terminal
gopdfrab verify docs/ # verify every PDF under a directory
gopdfrab verify --json report.pdf # machine-readable output
gopdfrab verify --detail report.pdf # every page and object per issue
gopdfrab convert in.pdf out.pdf # rewrite towards PDF/A-1b
gopdfrab convert --profile pdfa2b in.pdf # or towards PDF/A-2b
gopdfrab convert --dpi 300 in.pdf # tune the raster fallback
gopdfrab verify --max-decoded-mb 64 x.pdf # cap decoded stream output at 64 MBExit codes
| 0 | Conformant — every file passed. |
|---|---|
| 1 | Non-conformant — at least one file failed. |
| 2 | Error — usage, open, or I/O failure. |
Flags
Accepted by both verify and convert.
| --profile | pdfa1b | legacy1b | pdfa2b | pdf | Default pdfa1b. legacy1b is the strict Isartor reading; pdf runs object-model checks only. |
|---|---|---|
| --password | string | For encrypted input. Prefer GOPDFRAB_PASSWORD, since flags show up in ps. |
| --max-decoded-mb | int | Max decoded size of one stream. Default 256. |
| --max-resident-mb | int | Max cache memory per document. Default 64. |
| --json | bool | JSON output. |
| --detail | bool | List every page and object per issue instead of grouping. |
convert flags
| --dpi | int | Raster fallback resolution. Default 150. |
|---|---|---|
| --max-iterations | int | Max verify/fix passes. Default 4. |
| -o | path | Output path. Default: input with .pdfa.pdf (or .fixed.pdf for the pdf profile). |
--profile pdf skips PDF/A and runs only the ISO 32000 object-model checks. convert prints rasterized:, dropped: and lost: lines for anything the conversion cost. A conformant result can still have lost content, so read them.
JSON
terminal
# verify --json emits an array of {path, error?, result?}
gopdfrab verify --json docs/ | jq -r '.[] | select(.result.valid == false) | .path'report.json
CI
check-pdfa.sh
#!/usr/bin/env bash
# Fail the build when any PDF under docs/ is not PDF/A-1b conformant.
set -euo pipefail
if gopdfrab verify docs/; then
echo "all documents are conformant"
else
status=$?
if [ "$status" -eq 1 ]; then
echo "::error::one or more documents are not PDF/A-1b conformant"
else
echo "::error::gopdfrab failed to run"
fi
exit "$status"
fi