Documentation

Verify a PDF for PDF/A in Go

Run PDF/A-1b verification on a path, on in-memory bytes, or across a batch of files concurrently, and read the resulting issues.

doc.Verify runs the full PDF/A-1b profile and returns a Result with a single Valid flag and a list of issues. gopdfrab implements that profile as 159 checks across 11 groups, covering ISO 19005-1 clauses 6.1 through 6.9 plus generic ISO 32000 object-model conformance.

verify.go
v, _ := doc.Verify(gopdfrab.PDFA1B)

if v.Valid {
	fmt.Println("Document is PDF/A-1b compliant")
} else {
	fmt.Println("Issues:")
	for i, issue := range v.Issues {
		fmt.Printf("#%v: %v\n", i+1, issue)
	}
}

You can skip the open step and pass a path directly.

verify.go
// Verify opens, verifies, and closes a file in one call
result, err := gopdfrab.Verify(path, gopdfrab.PDFA1B)
if err != nil {
	log.Fatal(err)
}
fmt.Println(result.Valid)

VerifyBytes is Verify for an in-memory PDF — useful when the document arrived over the network and never touched disk.

verify.go
// VerifyBytes is Verify for an in-memory PDF
result, err := gopdfrab.VerifyBytes(data, gopdfrab.PDFA1B)

VerifyAll opens, verifies, and closes a batch of files concurrently. Verification holds no shared mutable state, so this scales across cores — the reference corpus of 773 files completes in well under a second on one machine.

verify_all.go
results, err := gopdfrab.VerifyAll(paths, gopdfrab.PDFA1B)
if err != nil {
	log.Fatal(err)
}
for _, r := range results {
	if r.Err != nil {
		log.Println(r.Path, r.Err)
		continue
	}
	fmt.Println(r.Path, r.Result.Valid)
}

A Result that is not valid carries every issue found, not just the first — see inspecting issues for reading them, and conversion for fixing them.