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 dacă PDF-ul criptat a fost scris cu succes în flux, sau False în caz de eșecSaveAsEncryptedToStream este omologul pentru fluxuri al SaveAsEncrypted — aplică criptarea AES-256-CBC conformă cu ISO 32000-2 §7.6, dar scrie rezultatele direct în orice TStream (cum ar fi TMemoryStream or TFileStream) în loc să le stocheze printr-o cale de fișier
Write, cât și SeeksaRemoveSecurity pentru a se asigura că obiectele text simplu sunt serializate corect înainte de a fi criptate de procesul de post-salvare
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;