ConvertToPDFA

PDF/A

Description

Turns the open document into an archival one and checks the result.

Syntax

Delphi

Function TPDFlib.ConvertToPDFA(TargetMode: Integer): Integer;

Parameters

TargetModeThe part and level to convert to, using the same numbering as SetPDFAMode.

Return values

1The document now conforms.
0It does not, or TargetMode was outside 1 to 11. Read GetPDFAConversionReport for what stands in the way.

Remarks

The call removes scripts and the actions that run them, removes embedded files where the chosen part forbids them, adds an sRGB output intent if the document has none, applies the annotation and form fixes the writer applies to a document authored in a PDF/A mode, brings the metadata into agreement, and states the part the document claims.

It then writes the document and checks what came out. The claim is only reported as met when the check passes: a file that says it is archival and is not passes through the very systems that would otherwise have caught it, so the verdict comes from the check rather than from the attempt.

Some faults cannot be repaired from inside the document. A font that was never embedded cannot be reconstructed, and an encrypted document whose password is not known cannot be read at all. Both are reported rather than worked around.

Example

PDF.LoadFromFile('invoice.pdf', '');
if PDF.ConvertToPDFA(3) = 1 then      // PDF/A-2b
  PDF.SaveToFile('invoice-pdfa.pdf')
else
  ShowMessage(PDF.GetPDFAConversionReport);

See also

GetPDFAConversionReport, SetPDFAMode, RepairDocumentMetadata, CheckFileCompliance