Documentation

Document helper methods

Shortcuts on an open document: PDF/A compliance, claimed conformance, page count, version, Info dictionary and raw XMP metadata.

Shortcuts on an open document for the most common questions: whether it's PDF/A compliant or even valid PDF, what conformance it claims, its page count and version, and its Info-dictionary and raw XMP metadata.

helpers.go
ok, err := doc.IsPDFA()   // shorthand for Verify(PDFA1B).Valid

ok, err = doc.IsPDF()     // shorthand for VerifyObjectModel().Valid

part, level, err := doc.ClaimedConformance() // e.g. "1", "B" -- what the file claims, not whether it's valid

n, err := doc.PageCount()   // number of pages

version, err := doc.Version()  // PDF version from the header, e.g. "1.7"

info, err := doc.Metadata()    // Info dictionary entries (Title, Author, ...)

xmp, err := doc.XMPMetadata()  // raw XMP packet bytes, decoded to UTF-8

Note the difference between what a document claims and what it is. The PDF/A identifier in the XMP metadata is self-reported by whatever produced the file, and plenty of documents assert a conformance level they do not meet. The claim is worth reading — it tells you what the producer intended — but only verification tells you whether it is true.

These helpers are conveniences over data the document already holds, so they are cheap. They do not re-run verification.