PDFium Delphi Component Docs

SaveAsPdfXToStream 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
Writes a PDF/X candidate to a caller-owned seekable stream using the same profile rules as SaveAsPdfX

Syntax

function SaveAsPdfXToStream(Stream: TStream; const Options: TPdfXSaveOptions): Boolean;

Description

SaveAsPdfXToStream is the streaming counterpart to SaveAsPdfX — same output bytes, written into any seekable TStream the caller provides. Useful for prepress workflow integration where PDF/X payloads are pushed straight into print submission portals, MIS / job-ticketing systems, BLOB columns, ZIP containers, or HTTP upload pipelines

The post-processing is identical to SaveAsPdfX: XMP injection with the pdfxid identifier and extension schema description, Document Information Dictionary rewrite with GTS_PDFXVersion / GTS_PDFXConformance / Trapped, catalog update with /Metadata and /OutputIntents references, OutputIntent dictionary with /S /GTS_PDFX and embedded ICC profile, and a trailer /ID array Options fields left empty are auto-populated from FPDF_GetMetaText / FPDF_GetFileIdentifier

Returns True after serialization, leaving the output stream after the last byte written Returns False for an inactive document or failed base save; a successful return is not a complete PDF/X conformance verdict

For pxc1a, supply a structurally valid ICC v2 prtr output profile with CMYK data, a Lab or XYZ PCS, and the required bidirectional LUTs in Options.IccProfileData Missing or unsuitable data raises EArgumentException before the destination stream is modified

PDF/X-1a replaces output-condition labels still equal to the built-in sRGB default with the checked ICC description If that description is absent, an explicit nonempty, nondefault OutputConditionIdentifier is required and supplies the replacement label Explicit labels are preserved; see SaveAsPdfX for the affected fields

Remarks

Example

var
  Stream: TMemoryStream;
  Opts: TPdfXSaveOptions;
begin
  Stream := TMemoryStream.Create;
  try
    Opts := TPdfXSaveOptions.Default;
    Opts.Conformance := pxc4;
    Opts.Title := 'Spring Catalogue 2026';
    if Pdf1.SaveAsPdfXToStream(Stream, Opts) then
    begin
      Stream.Position := 0;
      SubmitToPrinter(Stream);
    end;
  finally
    Stream.Free;
  end;
end;

See Also

SaveAsPdfX, ValidatePdfX, PdfXConformance, SaveAs