THotPDF.LoadFromStream

THotPDF

 

Top  Previous  Next

Loads an existing PDF file from stream.

 

Delphi syntax:

function LoadFromStream ( DocStream: TStream ): Integer;

function LoadFromStream ( DocStream: TStream; const Password: AnsiString ): Integer;

function LoadFromStream ( DocStream: TStream; AutoDecrypt: Boolean ): Integer;

 

C++ syntax:

int __fastcall LoadFromStream ( Classes::TStream* DocStream );

int __fastcall LoadFromStream ( Classes::TStream* DocStream, System::AnsiString Password );

int __fastcall LoadFromStream ( Classes::TStream* DocStream, bool AutoDecrypt );

 

Description

Call  LoadFromStream to load an existing PDF document from stream. Function LoadFromStream returns count of pages in the loaded document.

Use the password overload for supported RC4 and AES Standard encrypted PDFs. HotPDF validates the user or owner password, recovers the file key from bounded trailer, xref, document-ID, and encryption-dictionary ranges on seekable streams, decrypts loaded strings and streams in memory, clears the loaded encryption state, and lets SaveLoadedDocument write an unencrypted copy. Loading without a password captures the raw encryption object by its authoritative xref offset so a later DecryptLoadedDocument call can use exact binary security-handler values after the input stream is released. Unsupported encryption revisions raise an exception. Bounded key recovery is available since HotPDF v2.489.0, and zero-reread delayed decryption is available since HotPDF v2.490.0.

The AutoDecrypt overload opens documents the way viewers do. When AutoDecrypt is True and the document is encrypted with an empty user password, which is how documents that only restrict permissions are written, it is decrypted in memory exactly as the password overload would with an empty password, so its text can be extracted, rendered and exported; IsEncrypted is then False and a later SaveLoadedDocument writes an unencrypted copy. A document that needs a password, and an unencrypted one, loads as the plain overload loads it. Whether the empty password opens the document is checked first from the same bounded ranges, without loading the document twice. With AutoDecrypt False the overload is the plain one

When importing existing PDF objects, HotPDF decodes ISO 32000-1 PDF name #XX escape sequences before storing name values internally. Names such as /PANTONE#20216#20CVC, /lime#20Green, and /The_Key_of_F#23_Minor are preserved as their intended byte values when the document is later copied or saved.

 

 

 

See also: LoadFromFile, LoadFromRandomAccessSource, DecryptLoadedDocument