Expand description
XMP document metadata (ISO 32000-1 §14.3.2 / Adobe XMP). The catalog’s
/Metadata entry is a stream carrying an XMP packet — RDF/XML describing the
document with Dublin Core (dc:), XMP Basic (xmp:), and PDF-schema (pdf:)
properties. PDF 2.0 deprecates the /Info dictionary in favour of this, so
XMP is increasingly the only place some metadata lives.
This reads the common properties with a bounded tag/attribute scrape, not
a full XML parser. That is deliberate: an XML engine that resolves general
entities is vulnerable to “billion laughs” entity-expansion bombs, and a DOM
builder can blow the stack on deeply-nested input. Here no general entity is
ever resolved (only the five predefined XML entities and numeric character
references, each of which maps to exactly one character), every scan is
linear over the byte string, and every field and array is length-capped. Like
the other navigation/metadata readers it runs only when explicitly called —
never during open or rendering.
The trade-off: a producer that binds the schema namespaces to non-standard
prefixes (not dc/xmp/pdf) is not recognized. In practice these prefixes
are universal.
Structs§
- XmpMetadata
- Common document metadata read from the XMP packet. Every field is optional;
producers populate an arbitrary subset, and a field may be present in XMP but
not in
/Info(or vice-versa).
Functions§
- metadata_
bytes - Decode and return the raw bytes of the catalog’s
/MetadataXMP stream, orNonewhen the document carries none. Routes through the parser’s filter pipeline, so it respectsParseLimits. - parse_
xmp - Parse the catalog’s XMP
/Metadatapacket intoXmpMetadata. ReturnsNonewhen the document carries no/Metadata, it cannot be decoded, or it holds none of the recognized properties.