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 IsRangeAvailable(Offset, Count: Int64): Boolean; virtual;
  function ReadAt(Offset: Int64; var Buffer;
    Count: Longint): Longint; virtual; abstract;
  function ReadAtCancellable(Offset: Int64; var Buffer;
    Count: Longint; CancellationToken: THPDFCancellationToken): Longint; virtual;
end;

function LoadFromRandomAccessSource(
  Source: THPDFRandomAccessSource;
  OwnsSource: Boolean = False): Integer; overload;

function LoadFromRandomAccessSource(
  Source: THPDFRandomAccessSource;
  const Password: AnsiString;
  OwnsSource: Boolean = False): Integer; overload;

Contract

The result is the loaded page count, matching LoadFromFile and LoadFromStream. Bounded password-key recovery is available since HotPDF v2.489.0, zero-reread delayed decryption is available since HotPDF v2.490.0, and automatic range coalescing is available since HotPDF v2.524.0

See also: Scalable Loading, THPDFCoalescingRandomAccessSource, LoadFromStream