The Arlington PDF Model
The PDF specification as data instead of a thousand pages of prose.
The Arlington PDF Model lists, for every dictionary type, which keys exist, which are required, what types they take and which PDF version added them. Checks derived from it cover keys nobody thought to test by hand.
The checks gopdfrab derives
- MissingRequiredKey A dictionary omits a required key.
- WrongValueType A key holds a type that isn't allowed there.
- DisallowedValue The type is right, but the value isn't permitted.
- IndirectRequired A value that must be an indirect reference was written directly.
- KeyIntroducedAfterPDF14 A key newer than the declared PDF version. Matters most for PDF/A-1, which is based on PDF 1.4.
- ConstraintViolated A required relationship between keys doesn't hold.
Valid PDF vs. valid PDF/A
A file with transparency is valid PDF but not PDF/A-1. A file missing a required key can still claim PDF/A in its metadata. The object-model profile answers the first question on its own:
// "Is this even valid PDF?" -- independent of any PDF/A conformance level
res, err := gopdfrab.VerifyObjectModel(path)
res, err = gopdfrab.VerifyObjectModelBytes(data)
res, err = doc.VerifyObjectModel()
// Equivalent to verifying with the object-model-only profile
res, err = doc.Verify(gopdfrab.ObjectModelOnly())
// Shorthand for VerifyObjectModel().Valid
ok, err := doc.IsPDF() On the CLI it's --profile pdf. See object model for ConvertObjectModel, the repair counterpart.
FAQ
What is the Arlington PDF Model?
A machine-readable description of every object, key and value constraint in ISO 32000, maintained by the PDF Association.
Is it the same as PDF/A validation?
No. Arlington describes valid PDF. PDF/A adds archival rules on top. A file can be valid PDF and fail PDF/A, or the other way round.
When would I run object-model checks?
When you care about correct PDF but not PDF/A: validating uploads, triaging files a parser rejected, or testing a generator's output.