PDFium Delphi Component Docs

SaveAsPdfRToStream method

Requires Small Business or Enterprise since 3.266.0; link FPdfSmallBusiness to register the PDF/R engine

Component: TPdf  ·  Unit: PDFium
In-memory variant of SaveAsPdfR — writes PDF/R-1 output into any TStream without staging through disk

Syntax

function SaveAsPdfRToStream(Stream: TStream; const Options: TPdfRSaveOptions): Boolean;

Description

SaveAsPdfRToStream is the streaming counterpart to SaveAsPdfR — same output bytes, written into any seekable TStream the caller provides. Useful for document capture / archival pipelines that take scanner output, attach PDF/R-1 markers, and push the result to a content store without touching disk

The post-processing is identical to SaveAsPdfR: catalog stripped to the §6.3 white list, Info dictionary stripped to the §6.4.3 white list, an XMP stream derived from the surviving Info entries per §6.4.4 Table 1 and encoded as UTF-8, %PDF-raster-1.0 footer comment, and trailer /ID. Only the four allowed Info entries (Creator / Producer / CreationDate / ModDate) auto-populate from FPDF_GetMetaText; Title / Author / Subject / Keywords are deliberately NOT bridged because PDF/R prohibits them in the Info dictionary. An unencrypted %PDF-2.0 source has its header rewritten to %PDF-1.7 for the same reason as SaveAsPdfR, and the single complete cross-reference table leaves no /Prev behind

Returns True on success

Remarks

Example

var
  Stream: TMemoryStream;
  Opts: TPdfRSaveOptions;
begin
  Stream := TMemoryStream.Create;
  try
    Opts := TPdfRSaveOptions.Default;
    Opts.Producer := 'PDFium Delphi Component scan pipeline';
    if Pdf1.SaveAsPdfRToStream(Stream, Opts) then
    begin
      Stream.Position := 0;
      ArchiveScan(Stream);
    end;
  finally
    Stream.Free;
  end;
end;

See Also

SaveAsPdfR, ValidatePdfR, PdfRConformance, SaveAs