constructor TPdfXmpPacket.Create;
class function TPdfXmpPacket.Parse(const Xml: TPdfXmpString): TPdfXmpPacket;
class function TPdfXmpPacket.ParseUtf8(const Data: TBytes): TPdfXmpPacket;
class function TPdfXmpPacket.ParseBytes(const Data: TBytes): TPdfXmpPacket;
class function TPdfXmpPacket.ParseBytesWithSourcePrefixes(const Data: TBytes): TPdfXmpPacket;
function PdfXmpPacketEncoding(const Data: TBytes): TPdfXmpPacketEncoding;
function PdfXmpPacketText(const Data: TBytes): TPdfXmpString;
function PdfXfaConfigRequiresDynamicRender(const Data: TBytes): Boolean;
function TPdfXmpPacket.Clone: TPdfXmpPacket;
function TPdfXmpPacket.TryGetSimpleValue(const NamespaceUri, Name: TPdfXmpString; out Value: TPdfXmpString): Boolean;
procedure TPdfXmpPacket.SetSimpleValue(const NamespaceUri, PreferredPrefix, Name, Value: TPdfXmpString);
procedure TPdfXmpPacket.SetArrayValues(const NamespaceUri, PreferredPrefix, Name: TPdfXmpString; ContainerKind: TPdfXmpContainerKind; const Values: array of TPdfXmpString);
procedure TPdfXmpPacket.SetLanguageAlternative(const NamespaceUri, PreferredPrefix, Name, Language, Value: TPdfXmpString);
function TPdfXmpPacket.ToXml(PaddingLength: Integer = -1): TPdfXmpString;
function TPdfXmpPacket.ToUtf8(PaddingLength: Integer = -1): TBytes;
function ReadPdfXmpPacket(const PdfData: TBytes; out PacketData: TBytes): Boolean;
function ParsePdfXmpPacket(const PdfData: TBytes): TPdfXmpPacket;
function WritePdfXmpPacketIncremental(const PdfData: TBytes; Packet: TPdfXmpPacket): TBytes;
function ComparePdfAInfoAndXmp(const Info: TPdfAMetadataValues; Packet: TPdfXmpPacket): TPdfAMetadataReport;
function SynchronizePdfAInfoToXmp(const Info: TPdfAMetadataValues; Packet: TPdfXmpPacket): TPdfAMetadataFields;
function TPdf.ReadXmpPacket: TPdfXmpPacket;
function TPdf.InspectPdfAMetadata: TPdfAMetadataReport;
function TPdf.NormalizePdfAMetadata(Stream: TStream; AllowSignedDocument: Boolean = False): Boolean;
function TPdf.SaveAsWithXmpPacket(Stream: TStream; Packet: TPdfXmpPacket; AllowSignedDocument: Boolean = False): Boolean;
| Type | Description |
|---|---|
EPdfXmpError | Exception raised for malformed, unsafe, or unsupported XMP and PDF metadata input |
TPdfXmpString / TPdfXmpStrings | Unicode XMP string and its dynamic-array form |
TPdfXmpContainerKind | pxckSimple for a simple property, pxckBag for an unordered bag, pxckSequence for an ordered sequence, pxckAlternative for a language alternative, or pxckResource for a nested resource |
TPdfXmpValueKind | Value kind of pxvkText, pxvkUri, or pxvkResource for a preserved nested RDF resource |
TPdfXmpNamespace / TPdfXmpNamespaces | Namespace Prefix and Uri pair and its dynamic-array form |
TPdfXmpQualifier / TPdfXmpQualifiers | Qualifier with NamespaceUri, Prefix, Name, and Value fields and its dynamic-array form |
TPdfXmpValue / TPdfXmpValues | Typed value with Kind, Text, Language, Qualifiers, RawXml, and ParseType fields and its dynamic-array form. ParseType keeps the source rdf:parseType verbatim (Resource, Literal, Collection) so a read-modify-write round trip preserves it; when it is empty, the writer infers rdf:parseType="Resource" for structured values whose raw markup starts with property elements |
TPdfXmpProperty / TPdfXmpProperties | Property with NamespaceUri, Prefix, Name, ContainerKind, Qualifiers, and Values fields and its dynamic-array form |
TPdfXmpPacketEncoding | Encoding an XMP packet arrived in: xpeUtf8, xpeUtf16Le, xpeUtf16Be, xpeUtf32Le or xpeUtf32Be, as classified by PdfXmpPacketEncoding. A PDF/A-1 metadata packet may use any of them; a PDF/A-4 one has to be UTF-8 |
TPdfXmpValueClass | Lexically constrained value type of a predefined property: pxvcText for every unconstrained string type, pxvcInteger, pxvcReal, pxvcRational, pxvcDate, or pxvcBoolean |
TPdfXmpPropertyShape | Container form a predefined property is declared with: pxpsSimple, pxpsBag, pxpsSequence, pxpsAlternative, or pxpsResource for a structured value |
TPdfXmpPredefinedType | Declaration of one predefined property: NamespaceUri, Name, Shape, Value, and LangAlt, which marks the language alternatives whose every item must carry xml:lang |
TPdfAMetadataValues | PDFium-decoded values plus an explicit presence set for the eight Info keys mapped by ISO 19005-1 |
TPdfAMetadataComparison / TPdfAMetadataReport | Per-field RDF type, value, and date evidence plus the aggregate mismatch set and XMP parse status |
| Member | Description |
|---|---|
Create | Creates an empty packet using safe wrapper and padding defaults |
Parse / ParseUtf8 | Parses Unicode XML or UTF-8 bytes into a bounded property tree |
ParseBytes | Parses a packet in the encoding it declares — UTF-8, UTF-16 or UTF-32, either byte order, with or without a byte order mark — by reading the mark or the NUL pattern of the leading token; PdfXmpPacketEncoding and PdfXmpPacketText expose the classification and the decoded text for callers that scan a packet rather than parse it |
ParseBytesWithSourcePrefixes | Decodes the same bounded multi-encoding packet as ParseBytes, but each parsed property keeps the prefix exactly as written in the source instead of the packet's registered namespace prefix; use it to inspect original property names before namespace normalisation |
Clone | Returns an independent deep copy of the packet |
NamespaceCount / PropertyCount | Return the number of registered namespaces or properties |
TryGetProperty | Finds a property by namespace URI and local name and returns its index |
TryGetSimpleValue | Returns the text of a simple property when present |
RegisterNamespace | Registers a preferred prefix for a namespace URI whilst avoiding prefix collisions |
RemoveProperty | Removes the matching namespace-aware property |
SetSimpleValue | Creates or replaces a scalar text property |
SetArrayValues | Creates or replaces a bag, sequence, or alternative from text values |
SetLanguageAlternative | Adds or replaces one language-tagged value in an alternative container |
ToXml / ToUtf8 | Serialises the packet as Unicode XML or UTF-8 bytes with optional padding |
HasPacketWrapper | Controls whether serialisation emits the XMP packet processing-instruction wrapper |
Namespaces / Properties | Expose the packet namespace and property arrays for inspection |
PacketEndMode / PacketId | Expose the packet wrapper end mode and packet identifier |
PaddingLength | Gets or sets the preserved default serialisation padding length |
| Function | Description |
|---|---|
PdfXmpPredefinedType | Looks up the declaration of a property of a predefined schema by namespace URI and local name, reporting whether the schema defines it at all. The optional PartNo selects the specification that names the declaration, since the XMP specification of 2004 and ISO 16684-1 do not always agree: part 1 reads the earlier one, and the default of 2 gives the current view that ISO 19005-2 6.6.2.3.1 and ISO 19005-3 defer to |
PdfXmpValueMatchesClass | Tests a value against a value class: an optionally signed decimal integer, decimal notation, a numerator/denominator rational, an ISO 8601 date, or True / False |
PdfXmpShapeMatches | Tests a parsed container kind against a declared shape |
| Function | Description |
|---|---|
ReadPdfXmpPacket | Extracts the metadata stream bytes from a complete PDF byte array |
ParsePdfXmpPacket | Extracts and parses the metadata packet, returning nil when none exists |
WritePdfXmpPacketIncremental | Returns PDF bytes with a new metadata stream and catalogue update appended as an incremental revision |
ComparePdfAInfoAndXmp | Compares all present ISO 19005-1 Table 1 Info entries against their typed XMP properties |
SynchronizePdfAInfoToXmp | Repairs only mismatched mapped properties and returns the fields it changed |
Unknown namespace declarations, property namespaces, qualifiers, RDF bags, sequences, alternatives, URI resources, nested resources, xml:lang values, packet IDs, end modes, and padding round-trip through the property tree
Property and array item qualifiers are written with prefixes bound to their namespace URIs. Unprefixed qualifiers keep an empty namespace even under a default element namespace
Packet wrapper metadata is taken from parsed xpacket processing instructions with exact attribute names; wrapper text hiding in comments or CDATA does not count, and read-only end="r" values and padding lengths survive cloning, CRLF input included
Nested resource serialisation keeps text and CDATA in their original order relative to child elements; duplicate attribute names, duplicate expanded names across namespace aliases and undeclared prefixes raise EPdfXmpError
Serialisation assigns collision-free prefixes whilst preserving known prefixes where possible and emits UTF-8 without locale-dependent conversions
ReadXmpPacket returns nil when a document has no metadata stream and rejects incomplete progressive sources
SaveAsWithXmpPacket writes a fresh native document and appends a metadata and catalogue update, then atomically replaces file destinations
PDF/A comparison resolves properties by namespace URI, requires rdf:Alt with x-default for Title and Subject, requires a one-item rdf:Seq for Author, and requires simple values for Keywords, Creator, Producer, CreationDate, and ModDate
Text equality is exact after PDFium decodes Info strings to Unicode; date equality compares matching local values without zones or the same UTC instant when both values carry zones
Synchronisation preserves unrelated properties, unknown namespaces, and non-default language alternatives, and emits canonical UTC XMP dates when an Info date carries a timezone
The predefined property table covers the ten schemas of XMP Specification Part 2 that PDF/A-1 refers to — Dublin Core, XMP Basic, Rights Management, Media Management, Basic Job Ticket, Paged-Text, Adobe PDF, Photoshop, EXIF for TIFF, and EXIF — together with the value class each property is declared with. Auxiliary field schemas such as stRef and stEvt only appear inside a structured value and are therefore not part of it: a structured property keeps its fields as raw XML. InstanceID is declared as a simple property even though PDF/A-1 does not treat its presence as a violation
PdfXfaConfigRequiresDynamicRender reads an XFA configuration packet, either a bare config element or one wrapped in an xdp root, and reports True only when acrobat/acrobat7/dynamicRender carries the text required; it shares the packet-encoding sniffing of the other byte helpers, applies the same decoded-input and allocation budgets, and reports False, rather than raising, for malformed or oversized input
AllowSignedDocument=True because any metadata update creates an unsigned revision
var
Packet: TPdfXmpPacket;
begin
Packet := Pdf1.ReadXmpPacket;
if Packet = nil then
Packet := TPdfXmpPacket.Create;
try
Packet.SetSimpleValue('http://ns.adobe.com/xap/1.0/', 'xmp', 'CreatorTool', 'PDFium Delphi Component');
Pdf1.SaveAsWithXmpPacket('C:\Output\metadata.pdf', Packet);
finally
Packet.Free;
end;
end;