TStream to PDFium's FPDF_FILEACCESS callback structure
constructor Create(AStream: TStream; AOwnsStream: Boolean = False);
constructor Create(AStream: TStream; AFileSize: UInt64; AOwnsStream: Boolean);
destructor Destroy; override;
property Stream: TStream read FStream;
property OwnsStream: Boolean read FOwnsStream;
property FileSize: UInt64 read FFileSize;
property FileAccess: FPDF_FILEACCESS read FFileAccess;
| Member | Description |
|---|---|
Create | Wrap a seekable TStream, optionally supply a logical file size that differs from current storage and optionally transfer stream ownership to the adapter |
Destroy | Releases adapter state and frees Stream when OwnsStream is True |
Stream | Underlying stream passed to the constructor |
OwnsStream | True when the adapter should free the stream in Destroy |
FileSize | Logical size exposed through FPDF_FILEACCESS, including bytes not yet present during progressive loading |
FileAccess | PDFium callback record suitable for FPDF_LoadCustomDocument |
TPdfStreamAdapter lets PDFium request byte ranges from a stream on demand rather than copying the whole PDF into memory before loading
The stream must support seeking and must remain alive for as long as the loaded FPDF_DOCUMENT can read from the adapter
TPdf.LoadCustomDocument uses the same adapter path for the high-level component API
Adapter := TPdfStreamAdapter.Create(FileStream, True);
Document := FPDF_LoadCustomDocument(@Adapter.FileAccess, nil);