Errors

Match failures with errors.Is. Damaged files are reported as issues, not returned as errors.

Error Meaning
ErrNotPDFthe input is not a PDF (no %PDF- header)
ErrDamageda PDF whose cross-reference or trailer structure could not be parsed
ErrEncryptedan encryption scheme gopdfrab does not implement
ErrPasswordRequireda correct password is required to open the file
ErrUnresolvableGraphConvert could not resolve the object graph, so no output was produced
ErrInternala defect in gopdfrab, recovered from a panic; please report it with the file
errors.go
res, err := gopdfrab.Verify(path, gopdfrab.PDFA1B)

switch {
case errors.Is(err, gopdfrab.ErrNotPDF):
	log.Println("not a PDF -- no %PDF- header")
case errors.Is(err, gopdfrab.ErrPasswordRequired):
	log.Println("a correct password is required")
case errors.Is(err, gopdfrab.ErrEncrypted):
	log.Println("unsupported encryption scheme")
case errors.Is(err, gopdfrab.ErrDamaged):
	log.Println("xref or trailer structure could not be parsed")
case err != nil:
	log.Println(err)
default:
	fmt.Println(res.Valid)
}

Damage is reported, not fatal

An object that fails to parse is re-located by scanning for its N G obj header, or resolved to null. That is reported as a 6.1.6 issue, and every other check still runs. A missing or unusable startxref triggers a full object scan that rebuilds the cross-reference table (a 6.1.4 issue).

A conversion that had to drop an unrecoverable object keeps that loss in Residual() and never reports the result as valid.