TStream 桥接到 PDFium 的 FPDF_FILEACCESS 回调结构
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 | 包装一个可寻址的 TStream,可选地提供与当前存储不同的逻辑文件大小,并可选地把流所有权移交给适配器 |
Destroy | 释放适配器状态;当 OwnsStream 为 True 时释放 Stream |
Stream | 传递给构造函数的底层流 |
OwnsStream | 为 True 时适配器会在 Destroy 中释放该流 |
FileSize | 通过 FPDF_FILEACCESS 公开的逻辑大小,包含渐进加载时尚未就绪的字节 |
FileAccess | 适用于 FPDF_LoadCustomDocument 的 PDFium 回调记录 |
TPdfStreamAdapter 让 PDFium 可以按需从流中请求字节区间,而不必在加载前把整个 PDF 复制进内存
流必须支持寻址,并且在已加载的 FPDF_DOCUMENT 仍可能从适配器读取期间保持存活
TPdf.LoadCustomDocument 在高层组件 API 中使用相同的适配器路径
Adapter := TPdfStreamAdapter.Create(FileStream, True);
Document := FPDF_LoadCustomDocument(@Adapter.FileAccess, nil);