PDFium Delphi Component Docs

TPdfStreamAdapter class

Unit: PDFium
Bridge from a seekable Pascal TStream to PDFium's FPDF_FILEACCESS callback structure

Syntax

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;

Members

MemberDescription
CreateWrap a seekable TStream, optionally supply a logical file size that differs from current storage, and optionally transfer stream ownership to the adapter
DestroyReleases adapter state and frees Stream when OwnsStream is True
StreamUnderlying stream passed to the constructor
OwnsStreamTrue when the adapter should free the stream in Destroy
FileSizeLogical size exposed through FPDF_FILEACCESS, including bytes not yet present during progressive loading
FileAccessPDFium callback record suitable for FPDF_LoadCustomDocument

Description

TPdfStreamAdapter lets PDFium request byte ranges from a stream on demand instead of 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

Example

Adapter := TPdfStreamAdapter.Create(FileStream, True);
Document := FPDF_LoadCustomDocument(@Adapter.FileAccess, nil);

See Also

TPdf.LoadCustomDocument