function SaveAsEncryptedToStream(Stream: TStream; const Options: TPdfEncryptOptions): Boolean;
| Stream | TStream. The target stream that receives the encrypted bytes |
| Options | TPdfEncryptOptions. Configuration record defining passwords, permissions, metadata encryption flags, and the encryption revision |
True se il PDF crittografato è stato scritto correttamente nello stream, o False in caso di erroreSaveAsEncryptedToStream è la controparte di streaming di SaveAsEncrypted — applica la crittografia AES-256-CBC conforme a ISO 32000-2 §7.6, ma scrive i risultati direttamente in qualsiasi TStream ricercabile (come TMemoryStream o TFileStream) invece di passare attraverso un percorso di file
Write che SeeksaRemoveSecurity per garantire che gli oggetti in testo normale siano serializzati in modo pulito prima di essere crittografati dalla scansione post-salvataggio
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;