PDFium Delphi Component Docs

SaveAsEncryptedToStream メソッド

コンポーネント: TPdf  ·  ユニット: PDFium
SaveAsEncrypted のメモリ内バリアント — ディスクを経由せずに、暗号化された PDF 出力をシーク可能な任意の TStream に書き込みます

Syntax

function SaveAsEncryptedToStream(Stream: TStream; const Options: TPdfEncryptOptions): Boolean;

StreamTStream. The target stream that receives the encrypted bytes
OptionsTPdfEncryptOptions. Configuration record defining passwords, permissions, metadata encryption flags, and the encryption revision

Return Value

Returns True if the encrypted PDF was successfully written to the stream, or False on failure

Description

SaveAsEncryptedToStream is the streaming counterpart to SaveAsEncrypted — it applies AES-256-CBC encryption conforming to ISO 32000-2 §7.6, but writes the results directly into any seekable TStream (such as TMemoryStream or TFileStream) instead of staging through a file path

Remarks

Example

var
  Stream: TMemoryStream;
  Opts: TPdfEncryptOptions;
begin
  Stream := TMemoryStream.Create;
  try
    Opts := TPdfEncryptOptions.Default;
    Opts.UserPassword := 'user123';
    Opts.OwnerPassword := 'owner123';
    Opts.Permissions := $FFFFFFF0;
    Opts.EncryptMetadata := True;
    Opts.Revision := erR6;
    if Pdf1.SaveAsEncryptedToStream(Stream, Opts) then
    begin
      Stream.Position := 0;
      SendToNetwork(Stream);
    end;
  finally
    Stream.Free;
  end;
end;

See Also

SaveAsEncrypted, SaveAs