PDFiumVCL Docs

SaveAsPdfAToStream method

Bu API girdisi tanımlayıcıları, imzaları, kod bloklarını ve PDF terimlerini özgün biçiminde korur.
Component: TPdf  ·  Unit: PDFium
In-memory variant of SaveAsPdfA — writes the PDF/A-1b output into any TStream without staging through disk.

Syntax

function SaveAsPdfAToStream(Stream: TStream; const Options: TPdfASaveOptions): Boolean;

Description

SaveAsPdfAToStream is the streaming counterpart to SaveAsPdfA — it produces the same PDF/A-1b output, but writes the result into any seekable TStream the caller provides instead of going through a temporary file. Useful for HTTP upload pipelines, BLOB columns, in-memory cache layers, archive containers (ZIP / TAR), or any workflow where the PDF/A bytes never need to touch disk.

The post-processing logic is identical to SaveAsPdfA(FileName, Options): the base SaveAs runs first, then an incremental update injects the XMP metadata stream (which bridges the Document Information Dictionary into XMP form per ISO 19005-1 6.7.3 / Cor.1 Table 1 and embeds the pdfaid extension schema description required by 6.7.8), the OutputIntent referencing an embedded ICC profile (sRGB by default, custom through Options.IccProfileData), a catalog update that links them together, and a trailer /ID array required by 6.1.3. Options fields left empty are auto-populated from FPDF_GetMetaText and FPDF_GetFileIdentifier so the typical caller only sets Conformance.

Returns True on success. The output stream is left at the position after the last byte written. Returns False if the base SaveAs failed or if the PDF/A post-processing could not be attached (typically because the source PDF was encrypted, which PDF/A forbids).

Remarks

Example

var
  Stream: TMemoryStream;
  Opts: TPdfASaveOptions;
begin
  Stream := TMemoryStream.Create;
  try
    Opts := Default(TPdfASaveOptions);
    Opts.Conformance := pac1b;
    if Pdf1.SaveAsPdfAToStream(Stream, Opts) then
    begin
      Stream.Position := 0;
      UploadToArchive(Stream);
    end;
  finally
    Stream.Free;
  end;
end;

See Also

SaveAsPdfA, ValidatePdfA, PdfAConformance, SaveAs