PDFiumVCL Docs

SaveAsPdfUaToStream method

Denna API-post behåller identifierare, signaturer, kodblock och PDF-termer i ursprunglig form.
Component: TPdf  ·  Unit: PDFium
In-memory variant of SaveAsPdfUa — writes the PDF/UA-1 output into any TStream without staging through disk.

Syntax

function SaveAsPdfUaToStream(Stream: TStream; const Options: TPdfUaSaveOptions): Boolean;

Description

SaveAsPdfUaToStream is the streaming counterpart to SaveAsPdfUa — it produces the same PDF/UA-1 output but writes the result into any seekable TStream the caller provides. Useful for HTTP upload pipelines, BLOB columns, in-memory cache layers, archive containers (ZIP / TAR), or any workflow where the PDF/UA bytes never need to touch disk.

The post-processing logic is identical to SaveAsPdfUa(FileName, Options): the base SaveAs runs first, then an incremental update injects the XMP metadata stream (with mandatory dc:title per ISO 14289-1 §7.1 and the pdfuaid extension schema description), catalog /MarkInfo and /ViewerPreferences when the source has none, catalog /Lang when the caller supplied a BCP 47 tag, and a trailer /ID array. Options fields left empty are auto-populated from PDFium readers (FPDF_GetMetaText, FPDF_GetFileIdentifier, FPDFCatalog_GetLanguage) so the typical caller only sets DocumentTitle or Language if needed.

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 post-processing could not be attached (typically an encrypted source).

Remarks

Example

var
  Stream: TMemoryStream;
  Opts: TPdfUaSaveOptions;
begin
  Stream := TMemoryStream.Create;
  try
    Opts := TPdfUaSaveOptions.Default;
    Opts.DocumentTitle := 'Quarterly Report';
    Opts.Language := 'en';
    if Pdf1.SaveAsPdfUaToStream(Stream, Opts) then
    begin
      Stream.Position := 0;
      UploadToArchive(Stream);
    end;
  finally
    Stream.Free;
  end;
end;

See Also

SaveAsPdfUa, ValidatePdfUa, PdfUaConformance, SaveAs