# gopdfrab

> A pure Go library and CLI for verifying and converting PDF documents to PDF/A-1b compliance, with zero runtime dependencies and WebAssembly support.

gopdfrab is an open-source Go library and command-line tool for PDF/A compliance, built by voidrab (IT-Dienstleistungen Thomas Karner e.U.). It provides PDF/A-1b verification and conversion with a small, predictable API, zero runtime dependencies, and cross-platform support including WebAssembly. The project reached stable API status at v1.0, released in August 2026, and is dual-licensed under AGPL 3.0 with a commercial license option for closed-source use.

## What It Is

gopdfrab is a PDF/A processing library for the Go programming language. It handles two core jobs: verifying whether a PDF document conforms to the ISO 19005-1 (PDF/A-1b) standard, and converting non-conformant PDFs into PDF/A-1b documents. The library exposes four primary concepts — a document, a verification profile, a result, and a conversion — and ships the same engine as both a Go package and a static CLI binary. A browser-based validator and converter are also available on the project website, running the same engine compiled to WebAssembly entirely client-side.

## Architecture and Design

gopdfrab is written in pure Go with no external runtime dependencies beyond the standard library. Key architectural properties include:

- **Pure Go, zero deps**: Cross-compiles anywhere Go does, including `js/wasm` for browser use.
- **Customizable profiles**: Verification profiles are immutable and goroutine-safe; checks can be added, removed, or built from scratch.
- **Damage recovery**: Broken cross-reference tables trigger a full-file object scan; individual corrupt objects are re-located or nulled and reported rather than causing hard failures.
- **Encrypted PDF support**: Decrypts RC4 40/128, AES-128, and AES-256 with empty or supplied passwords.
- **Fidelity checking**: An optional `CheckFidelity` mode renders both input and output to detect content loss during conversion.
- **Streaming and batching**: `ConvertEach` streams large batches without holding all outputs in memory; `VerifyAll`/`ConvertAll` run concurrently with bounded worker pools.

The conversion pipeline runs pre-emptive fixups, then a verify/fix loop, and falls back to page rasterization as a last resort. Anything unresolvable is reported as a residual and never silently passed as valid.

## Conformance Suite Coverage

The homepage states that gopdfrab passes all tests in the Isartor and veraPDF conformance suites:

- **204/204** Isartor test suite passes
- **569/569** veraPDF test suite passes
- **159 checks** across 11 groups covering structure, colour, image, transparency, font, annotation, action, metadata, form, object model, and logical structure

A `Legacy1B` profile provides the strict, spec-literal Isartor reading for applications that require it, while the default `PDFA1B` profile matches veraPDF's interpretation where the two diverge.

## Performance Characteristics

The project publishes benchmark results comparing gopdfrab against veraPDF and PDFBox Preflight on a 773-file corpus (the combined Isartor and veraPDF corpora). Per the project's own benchmarks: the full batch verifies in approximately 0.27–0.29 seconds at around 67–80 MB peak RSS; cold single-file verification of the median corpus file takes roughly 9.5 ms including process startup. The project attributes the JVM startup overhead of veraPDF and PDFBox Preflight as a significant factor in cold-start comparisons.

## Robustness and Fuzzing

gopdfrab's test suite covers hostile and malformed input extensively:

- An internal generator (`internal/pdfgen`) builds structurally-valid PDFs deliberately corrupted with truncation, bad xref offsets, negative stream lengths, dangling and circular references, and deep nesting.
- Native Go fuzz targets operate at three levels: whole pipeline, isolated decoders and parsers, and semantic oracles (determinism, round-trip validity, convergence).
- Named `TestCrasher_*` reproducers guard each previously-fixed crash.
- Race detection and time-bounded corpus tests run on every build.

## Update: v1.0.0

The GitHub repository records v1.0.0 as the latest release, published on 2026-08-26. The README states the API is stable as of 1.0, with a versioning and stability policy documented in `CHANGELOG.md`. The roadmap notes that PDF/A-1b is complete and that PDF/A-2, -3, and -4 are next. The repository was last pushed to on 2026-09-01.

## Features
- PDF/A-1b verification against ISO 19005-1
- PDF to PDF/A-1b conversion with verify/fix loop and raster fallback
- Pure Go with zero runtime dependencies
- WebAssembly support for browser-based validation and conversion
- CLI binary with directory recursion, JSON output, and CI-friendly exit codes
- Customizable and immutable verification profiles
- Encrypted PDF support (RC4 40/128, AES-128, AES-256)
- Damage recovery for broken cross-reference tables and corrupt objects
- Batch processing with bounded concurrency (VerifyAll, ConvertAll, ConvertEach)
- Fidelity checking to detect content loss during conversion
- Object-model verification via Arlington PDF Model (ISO 32000)
- JSON-serializable results for CLI, service, and CI integration
- Typed errors for programmatic error handling
- Resource limits for decompression bomb protection
- Legacy Isartor profile for strict spec-literal PDF/A-1b checking
- 204/204 Isartor and 569/569 veraPDF conformance suite passes
- Goroutine-safe profiles safe to share across concurrent calls
- Context-based cancellation for all verify and convert operations

## Integrations
Go modules (go get), WebAssembly (js/wasm), CI/CD pipelines (exit codes 0/1/2), veraPDF (cross-checked in CI), Arlington PDF Model (ISO 32000 object model)

## Platforms
LINUX, WEB, API, DEVELOPER_SDK, CLI

## Pricing
Open Source, Free tier available

## Version
v1.0.0

## Links
- Website: https://gopdfrab.voidrab.com
- Documentation: https://gopdfrab.voidrab.com/docs
- Repository: https://github.com/voidrab/gopdfrab
- EveryDev.ai: https://www.everydev.ai/tools/gopdfrab
