LoadFromStream

Document management

Description

This function, only available in the Delphi versions of the library, allows a PDF document to be loaded from a TStream object. If the function succeeds, the loaded document will be selected and its DocumentID can be retrieved using the SelectedDocument function.

If the supplied password is rejected and OnPassword is assigned, the handler may provide another credential or cancel the load

Byte-distance searches in the stream buffer continue after a short read until the stream returns zero bytes, so later matches are not skipped when a custom stream supplies data in smaller chunks

Syntax

Delphi

Function TPDFlib.LoadFromStream(InStream: TStream; Const Password: WideString): Integer;

Parameters

InStreamThe TStream object containing the PDF document data
PasswordThe password to load the file

Return values

0A PDF document could not be read from the stream. Use the LastErrorCode
1A PDF document was successfully read from the stream. Use the SelectedDocument function to obtain the Document ID which can be used later to select this specific document.

Remarks

The input bytes are copied so the caller may release or reuse InStream immediately after this function returns; use LoadFromRangeSource when a large or remote source should remain callback-backed and load on demand

PDF MAC protected input is authenticated after password verification and before document pages are exposed