THPDFRenderDocAccess 记录
把渲染器绑定到文档服务,用于解析引用、读取流、解码图像、定位字体和评估图层可见性
声明
THPDFRenderDocAccess= record
Context: Pointer;
SharedCache: THPDFRendererSharedCache;
ShareRenderCaches: boolean;
// v2.375.0 generic indirect-ref resolver (any object type). The typed
// Resolve* fields below predate it and return nil for non-matching
// types, which silently dropped indirect refs to arrays (e.g. a
// /ColorSpace entry pointing at a [/Separation ...] array object)
ResolveObject: function(Context: Pointer; Obj: THPDFObject): THPDFObject;
ResolveDictionary: function(Context: Pointer; Obj: THPDFObject): THPDFDictionaryObject;
ResolveStream: function(Context: Pointer; Obj: THPDFObject): THPDFStreamObject;
ReadDecodedStreamBytes: function(Context: Pointer; Stream: THPDFStreamObject; out Bytes: TBytes): boolean;
AcquireDecodedImageStream: function(Context: Pointer;
Stream: THPDFStreamObject): IHPDFDecodedBitmapHandle;
DecodeImageStream: function(Context: Pointer; Stream: THPDFStreamObject): TBitmap;
BeginProgressiveImageDecode: function(Context: Pointer;
Stream: THPDFStreamObject;
CancellationToken: THPDFCancellationToken): IHPDFProgressiveImageDecoder;
DecodeImageRegion: function(Context: Pointer; Stream: THPDFStreamObject;
RegionLeft, RegionTop, RegionRight, RegionBottom,
DesiredWidth, DesiredHeight: Integer): TBitmap;
AcquireDecodedImageRegion: function(Context: Pointer;
Stream: THPDFStreamObject; RegionLeft, RegionTop, RegionRight,
RegionBottom, DesiredWidth,
DesiredHeight: Integer): IHPDFDecodedBitmapHandle;
// v2.425.0 inline-image decoder: builds a throwaway stream from the raw
// ID..EI bytes and the normalised BI key set, then decodes it without the
// ObjectNumber-keyed cache (inline images have no object number). Returns
// a TBitmap the caller owns, or nil on failure. Nil hook = inline images
// are not rendered (legacy behaviour)
DecodeInlineImage: function(Context: Pointer; const Bytes: TBytes;
const Keys: THPDFInlineImgKeys): TBitmap;
// Colour-key /Mask array of an image XObject as a soft mask, white where
// the image shows and black where it is masked out. Returns a TBitmap the
// caller owns, or nil when the image has no usable colour-key mask; a nil
// hook draws such images unmasked
DecodeColorKeyMask: function(Context: Pointer;
Stream: THPDFStreamObject): TBitmap;
// Look up a font dictionary by resource key in a Resources dict, following
// indirect refs at both /Resources and /Font levels. Returns nil if absent
ResolveFontDict: function(Context: Pointer; PageObj: THPDFDictionaryObject;
const FontKey: AnsiString): THPDFDictionaryObject;
// v2.377.0 optional-content visibility oracle: evaluates an /OC property
// object (OCG or OCMD) against the document's layer states. Nil hook or
// a True result means the content is drawn
EvalOCVisibility: function(Context: Pointer; PropObj: THPDFObject): boolean;
CancellationToken: THPDFCancellationToken;
ColourIntent: Integer;
FallbackPolicy: THPDFRenderFallbackPolicy;
FallbackDiagnosticLimit: Integer;
OverprintPreview: boolean;
ProofICCProfile: TBytes;
OutputICCProfile: TBytes;
BlackPointCompensation: boolean;
SeparationPlate: AnsiString;
end;
单元
HPDFPageRenderer
字段
| 字段 | 用途 |
|---|---|
Context | 调用方提供的上下文指针,作为每个回调的第一个参数传入;文档在此绑定自身 |
SharedCache | 当启用 ShareRenderCaches 时,可供多个页面共享的渲染器缓存 |
ShareRenderCaches | 文档允许并发渲染器共享解码缓存时为 True |
ResolveObject | 适用于任意对象类型的通用间接引用解析器;因类型化解析器对不匹配的类型返回 nil 而补充 |
ResolveDictionary | 把间接引用解析为字典对象,其他类型返回 nil |
ResolveStream | 把间接引用解析为流对象 |
ReadDecodedStreamBytes | 把流完全解码后读入字节数组 |
AcquireDecodedImageStream | 把图像 XObject 解码为共享的引用计数位图句柄 |
DecodeImageStream | 把图像 XObject 解码为调用方持有的位图 |
BeginProgressiveImageDecode | 为大型图像流启动可取消的渐进解码器 |
DecodeImageRegion | 按请求的像素尺寸解码图像的子区域 |
AcquireDecodedImageRegion | 区域变体,返回共享的引用计数位图句柄 |
DecodeInlineImage | 从原始 ID..EI 字节和规范化 BI 键集解码内联图像,绕过按对象号索引的缓存;钩子为 nil 表示不渲染内联图像 |
DecodeColorKeyMask | 把图像 XObject 的 color-key /Mask 数组变成图像尺寸的黑白软掩码;图像没有可用的 color-key 掩码时为 nil,钩子为 nil 时这类图像不带掩码绘制 |
ResolveFontDict | 按资源键查找字体字典,跟随 /Resources 和 /Font 两级的间接引用;不存在时为 nil |
EvalOCVisibility | 对照文档图层状态评估 /OC 属性对象;钩子为 nil 或结果为 True 都表示绘制该内容 |
CancellationToken | 长时间解码操作期间检查的取消令牌 |
ColourIntent | 应用到渲染图形状态的颜色处理意图 |
FallbackPolicy | 选择忽略、报告不支持的功能,还是把它们当作严格失败 |
FallbackDiagnosticLimit | 限制回退期间收集的诊断消息数量 |
OverprintPreview | 启用叠印预览模拟 |
ProofICCProfile | 用于色彩管线校样侧的 ICC profile 字节 |
OutputICCProfile | 描述输出设备的 ICC profile 字节 |
BlackPointCompensation | 在 ICC 变换中启用黑点补偿 |
SeparationPlate | 要隔离的分色印版名称;为空时正常渲染 |
使用说明
- THotPDF 通过内部的
MakeRenderDocAccess辅助方法绑定所有钩子,应用拿到的是现成记录,无需自行填写 - 自定义渲染后端从
THPDFPageRenderBackendRequest读取这些钩子,而不是直接深入文档 - 把
DecodeInlineImage或EvalOCVisibility留为 nil,即可恢复跳过内联图像、绘制全部可选内容的传统行为