PDFium Delphi Component Docs

SaveAsPdfX method

Enterprise edition: link FPdfEnterprise with Lib\Enterprise on the search path; otherwise this method raises EPdfEnterpriseRequired; see the edition matrix

Component: TPdf  ·  Unit: PDFium
Saves a PDF/X candidate with identification metadata and an embedded output profile for the selected ISO 15930 variant

Syntax

function SaveAsPdfX(const FileName: string): Boolean; overload;
function SaveAsPdfX(const FileName: string; const Options: TPdfXSaveOptions): Boolean; overload;

Description

SaveAsPdfX performs the regular SaveAs first, then layers an incremental update on top of the saved bytes for the selected PDF/X print-exchange variant. The post-processing injects five classes of bytes into the saved stream:

The trailer is rewritten to add an /ID array. The output stays byte-identical to the base SaveAs result up to the end of the original PDF; only the incremental update is appended. The two overloads differ only in how the configuration is passed in: the file-name-only form uses TPdfXSaveOptions.Default (PDF/X-4 + sRGB + /Trapped /False) with auto-population of Info / DocumentId fields from FPDF_GetMetaText and FPDF_GetFileIdentifier

Returns True once the prepared bytes have been written, or False if the document is inactive or the base save fails. Successful serialisation is not, of itself, a complete PDF/X conformance verdict

For pxc1a, IccProfileData must contain a structurally valid ICC v2 output profile with device class prtr, data colour space CMYK, a Lab or XYZ PCS, and the required bidirectional LUTs. Missing, RGB, truncated, incorrectly classified or unsupported profile data raises EArgumentException; there is no sRGB fallback for PDF/X-1a

For PDF/X-1a, OutputCondition, OutputConditionIdentifier and OutputIntentInfo values still equal to the built-in sRGB IEC61966-2.1 default are replaced with the checked profile description. If the profile has no description, supply a nonempty, nondefault OutputConditionIdentifier; it supplies the replacement label, or the call raises EArgumentException. Explicit caller labels are preserved

Serialisation and these profile checks finish in a temporary save store before the target file is opened for writing. An existing target therefore remains unchanged if profile validation raises or the base save fails. This is not an atomic file replacement guarantee: an I/O failure after the target is opened may leave partial output

Remarks

Example

// Simple PDF/X-4 with bundled sRGB OutputIntent
if Pdf1.SaveAsPdfX('C:\AdProof.pdfx.pdf') then
  ShowMessage('Saved PDF/X-4');

// PDF/X-1a with a custom CMYK ICC profile (e.g. FOGRA39)
var
  Opts: TPdfXSaveOptions;
begin
  Opts := TPdfXSaveOptions.Default;
  Opts.Conformance := pxc1a;
  Opts.IccProfileData := TFile.ReadAllBytes('C:\ICC\FOGRA39.icc');
  Opts.OutputCondition := 'Coated FOGRA39 (ISO 12647-2:2004)';
  Opts.OutputConditionIdentifier:= 'FOGRA39';
  Opts.RegistryName := 'http://www.color.org';
  Opts.Trapped := ptFalse;
  Pdf1.SaveAsPdfX('C:\AdProof.cmyk.pdfx.pdf', Opts);
end;

See Also

SaveAsPdfXToStream, ValidatePdfX, PdfXConformance, SaveAsPdfA, SaveAsPdfE