Get PDF/A Identification Metadata
A PDF/A file states which flavor of the standard it targets in the pdfaid: XMP
namespace: a part number and, for parts 1 to 3, a conformance letter.
Document.GetPdfAID returns both. This is how you find out what a file claims to
be before you decide whether to validate it or convert it.
Doing it
xmpDoc, err := xmputil.LoadDocument(stream.Stream)
if err != nil {
return err
}
pdfaID, ok := xmpDoc.GetPdfAID()
if !ok {
fmt.Println("no PDF/A ID namespace in this document")
return nil
}
fmt.Printf("Claims conformance with PDF/A-%d%s\n", pdfaID.Part, pdfaID.Conformance)Getting to stream.Stream is the usual three steps: reader.GetCatalogMetadata,
core.GetStream on the result, then xmputil.LoadDocument. See
get XMP metadata for that part.
xmputil.PdfAID has three fields. Part is the part number, Conformance the
letter, and Rev the revision year used by later parts. A PDF/A-1b file reads back
as Part: 1, Conformance: "B"; a PDF/A-4f file revised in 2025 as Part: 4, Conformance: "F", Rev: 2025.
Related namespaces
The same document object exposes the neighbouring conformance namespaces:
| Call | Returns |
|---|---|
GetPdfAID() | pdfaid:part, pdfaid:conformance, pdfaid:rev. |
GetPdfUAID() | The PDF/UA part, plus the optional amendment and corrigendum identifiers. |
GetPdfaExtensionSchemas() | The pdfaExtension schema descriptions a file declares for custom namespaces. |
Writing them is SetPdfAID(part, conformance), SetPdfAIDWithRev(part, conformance, rev), and the SetPdfUAID family.
Limitations
This reads a claim, not a fact. pdfaid:part is metadata anyone can write, and a
file carrying it may still fail validation. Use model/pdfa verification if you
need to know whether the document actually conforms.
GetPdfAID returns false when the namespace is missing, which is the common case:
most PDFs are not PDF/A and say nothing at all. Absent is not an error.
Conformance is empty for parts where the standard defines no conformance letter,
so do not treat an empty string as a parse failure.
Run the example
The example prints the claimed conformance of the file you pass it, or reports that the namespace is absent.
git clone https://github.com/unidoc/unipdf-examples.git
cd unipdf-examples/metadata
go run pdf_get_xmp_pdfaid_metadata.go input.pdfIf this is your first time using UniPDF, follow the getting started guide to create an API key and set up your development environment.