PDFium Component Docs

SaveAsPdfAToStream メソッド

この API エントリでは識別子、シグネチャ、コードブロック、PDF 用語を元の表記のまま保持します。
コンポーネント: TPdf  ·  ユニット: PDFium
In-memory variant of SaveAsPdfA — writes the PDF/A-1b output into any TStream without staging through disk.

構文

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

説明

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) は、まず基本の SaveAs を実行し、その後の増分更新で XMP メタデータストリーム (ISO 19005-1 6.7.3 / Cor.1 Table 1 に従って Document Information Dictionary を XMP 形式へ橋渡しし、6.7.8 で必要な pdfaid 拡張スキーマ記述を埋め込みます)、埋め込み ICC プロファイルを参照する OutputIntent (既定では sRGB、カスタムは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).

備考

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;

関連項目

SaveAsPdfA, ValidatePdfA, PdfAConformance, SaveAs