RepairDocumentMetadata
Metadata
Description
Brings the document information dictionary and the XMP packet into agreement, and completes the identification a claimed standard needs
Date repair converts between PDF Info dates and XMP date representations while retaining available precision and explicit time-zone offsets; equivalent dates with explicit offsets do not cause repeated repairs
Invalid XMP dates and fractional seconds that cannot be represented in a PDF Info date remain in XMP without creating an invalid or truncated Info date
Syntax
Delphi
Function TPDFlib.RepairDocumentMetadata: Integer;Return values
| Count | How many entries were repaired |
|---|---|
| 0 | The two halves already agreed and nothing was missing |
Remarks
A PDF says who wrote it twice: once in the document information dictionary and once in the XMP packet. A validator reads both and rejects a file where they disagree, and most files that fail on this point simply never had the XMP half written
The information dictionary is taken as the document's own word, since that is the half nearly every producer sets. Where only the XMP half carries a value, the information dictionary is filled from it instead, so nothing already recorded is thrown away. Title, author, subject, keywords, creator, producer and both dates are covered
When the document is set to a PDF/A mode with SetPDFAMode, the standards identification is restored if it is missing — which happens whenever a caller supplies a packet of its own with SetDocumentMetadata. Without it a validator reads the file as an ordinary PDF and reports every rule of the claimed part as unmet. A document opened from a file carries no mode of its own, so call SetPDFAMode first if the file should claim one
The packet is also made to say that it describes a PDF, which a validator checks
Example
PDF.LoadFromFile('report.pdf', '');
Repaired := PDF.RepairDocumentMetadata;
PDF.SaveToFile('report-fixed.pdf');Unknown creation and modification dates remain absent; empty XMP date properties are removed rather than replaced with an invented creation timestamp