PDF/A validation in CI
Fail the build when a document isn't PDF/A.
- Install the CLI go install the gopdfrab binary on the runner. Nothing else is needed.
- Verify the documents Point gopdfrab verify at a file or a directory. Directories are walked recursively.
- Let the exit code fail the job 0 when every file conforms, 1 when one does not, 2 on a usage or I/O error.
- Keep a report Add --json and store the output as a build artifact.
GitHub Actions
.github/workflows/pdfa.yml
name: pdfa
on: [push, pull_request]
jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Install gopdfrab
run: go install github.com/voidrab/gopdfrab/cmd/gopdfrab@latest
# Exits 1 when any document under docs/ is non-conformant, which
# fails the job. Exit 2 means the tool itself could not run.
- name: Verify PDF/A-1b
run: gopdfrab verify docs/GitLab CI
The report is kept as an artifact, so a failure can be inspected afterwards.
.gitlab-ci.yml
pdfa:
image: golang:1
script:
- go install github.com/voidrab/gopdfrab/cmd/gopdfrab@latest
- gopdfrab verify --json docs/ > pdfa-report.json
artifacts:
when: always
paths:
- pdfa-report.jsonAny shell
verify-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"
fiExit codes and flags are on the CLI page, and the JSON shape under JSON.
Uploads
CI only checks documents you commit. For user uploads, call Verify in your service, or in a serverless function.
FAQ
Is it fast enough for every commit?
Yes. The full conformance corpus verifies in under a second.
Can I check only some rules?
Yes. --profile picks pdfa1b, pdfa2b, legacy1b or pdf (object model only). The library can add or remove individual checks.
What about documents that are known to fail?
Only verify the directory that must conform.