THotPDF.DecryptLoadedDocument

THotPDF

Top

Decrypts a loaded Standard-security PDF object graph in memory

 

Delphi syntax:

procedure DecryptLoadedDocument(const Password: AnsiString);

 

Description

DecryptLoadedDocument validates the supplied user or owner password for a PDF already loaded with LoadFromFile or LoadFromStream. It supports RC4-40, RC4-128, AES-128, AES-256, and AESV4 Standard security handlers, decrypts loaded strings and streams, clears the loaded encryption state, and allows SaveLoadedDocument to write an unencrypted copy

For V=4 documents, independent StrF and StmF defaults are resolved separately. A stream-level Crypt filter can override StmF through an aligned DecodeParms entry whose Name selects Identity, V2, or AESV2. After decryption, the consumed filter and its aligned parameters are removed so later stream decoding starts with the next declared filter

Password-derived file keys, per-object keys, AES contexts, and temporary plaintext are explicitly overwritten on success and exception paths. The password overloads of LoadFromFile and LoadFromStream call this method automatically, while unsupported encryption revisions raise an exception before output is written

Code Example

PDF.LoadFromFile('Protected.pdf', 'user-password');
PDF.SaveLoadedDocument('Unencrypted.pdf');