THotPDF.LoadFromRandomAccessSource
Loads a PDF through a caller-defined seekable byte source without requiring a TStream implementation
Declarations
THPDFRandomAccessSource = class
public
function GetSize: Int64; virtual; abstract;
function ReadAt(Offset: Int64; var Buffer;
Count: Longint): Longint; virtual; abstract;
end;
function LoadFromRandomAccessSource(
Source: THPDFRandomAccessSource;
OwnsSource: Boolean = False): Integer; overload;
function LoadFromRandomAccessSource(
Source: THPDFRandomAccessSource;
const Password: AnsiString;
OwnsSource: Boolean = False): Integer; overload;
Contract
GetSizereturns the stable byte length and must not return a negative valueReadAtreads at the supplied zero-based offset and returns a count from zero through the requested count- The source must remain valid whilst the loaded document is in use unless
- Passing an existing
THPDFCoalescingRandomAccessSourcepreserves caller-selected block, cache, ownership, and prefetch settings - Override
ReadAtCancellableisTrue - With ownership enabled, HotPDF frees the source when another source is loaded, when loading fails, or when the component is destroyed
OwnsSourceisTrue - With ownership enabled, HotPDF frees the source when another source is loaded, when loading fails, or when the component is destroyed
- The password overload first reads bounded trailer and cross-reference ranges, then fetches the referenced encryption dictionary by its authoritative object offset so RC4 and AES password loading does not require a complete-source request on valid files
- Loading without a password captures the bounded raw encryption object and first trailer ID while the source is available; a later
DecryptLoadedDocumentcall uses the exact binaryO,U,OE, andUEvalues without rereading the source - The password overload may stage encrypted source bytes for security-handler compatibility
The result is the loaded page count, matching LoadFromFile and LoadFromStream
See also: Scalable Loading, THPDFCoalescingRandomAccessSource, LoadFromStream