RepairDocumentMetadata
Metadata
Description
Brings the document information dictionary and the XMP packet into agreement, and completes the identification a claimed standard needs.
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');