|
PDF 过滤器支持
概述
PDF 流和嵌入图像通过过滤器名称标识编码方式。HotPDF 在生成文档或解码外部内容时,主要使用以下过滤器系列
Common Filters
- FlateDecode:生成流的主要压缩过滤器,也是基于 zlib 的主要解压路径
- LZWDecode:通过 HPDFLZW.pas 支持旧文件和兼容性场景
- DCTDecode: Used for standard JPEG image data handled by HotPDF image loading paths
- CCITTFaxDecode: Common in monochrome TIFF and fax-style image data
- ASCIIHexDecode / ASCII85Decode / RunLengthDecode:自 HotPDF v2.4.0 起由 HPDFTypes.pas 暴露编码辅助函数(
_ASCIIHexEncode、_ASCII85Encode、_RunLengthEncode)。适合为 7-bit 通道包装任意二进制内容,或显式支持 PDF 1.7 7.4 往返处理
- JBIG2Decode / JPXDecode: Filter names defined by PDF 1.7 7.4.7 / 7.4.9. JBIG2 encode and decode default to a built-in high-performance backend, and backend registration points remain for custom implementations; JPEG 2000 decoding goes through HotPDF's helper units. Earlier builds returned a fake 100×100 JBIG2 success which produced unreadable images; this is now corrected
Practical Notes
- Not every filter is exposed through a single generic API; some are reached through dedicated image or stream helper units
- 对于生成的 PDF 内容,THotPDF.Compression 仍然是面向用户的核心设置
- 加载外部数据时,适用的过滤器取决于源文件格式以及正在使用的辅助类
- Encrypted PDFs combine these filters with the security handler; see CryptKeyLength for the supported AES‑128 (V=4 R=4 / CFM=AESV2) and RC4 (V=1/V=2) options
- 经
ConfigureCryptFilterDefaults 可为字符串、普通流和嵌入文件流独立选择保留的 crypt filter 策略。口令安全接受 StdCF 或 Identity,公钥安全接受 DefaultCryptFilter 或 Identity。SetStreamCryptFilter 可添加或清除显式的前置 Crypt 过滤器,不影响既有解码管线。逐流覆盖要求加密字典 /V 4 或更高
- 加密负载包装 让普通页面流保持可见,同时通过
EFOpen crypt filter 保护嵌入文件的元数据与字节;显式的已加载文档检查与解锁 API 自 HotPDF v2.715.0 起可用
- 口令保护的附件流使用
/EFF,且当 /EFF 与 /StmF 不同时会获得显式 Crypt 过滤器。公钥加密的显式流过滤器采取失败即拒绝策略,因为它们需要流专属的收件人信封
- 已加载文档通过
THPDFCryptFilterInfo 暴露原始 /CF、/StrF、/StmF 和 /EFF 策略,包括大小写敏感的外部命名过滤器、显式或省略的 /CFM /None、认证事件和有效密钥长度。标准处理器 V2 过滤器长度按字节读,公钥 V2 过滤器长度按位读,且只接受 40-bit 与 128-bit V2 密钥。明文 object-stream 容器仍经 /StrF 解密打包的成员字符串,加密容器则避免二次成员解密。增量更新保留已加载策略。自 HotPDF v2.675.0 起可用
- Interactive form fields are emitted as Widget annotations that the viewer paints; see AcroForm 支持
- 文本标记注释(Highlight、Underline、Squiggly、StrikeOut)和文档内跳转链接(
GoTo, GoToR, Launch) are exposed as THPDFPage.Add*Annotation / AddGoToLink / AddGoToRLink / AddLaunchLink methods
- DeviceCMYK 输出可通过
THPDFPage.SetCMYKColor / SetCMYKFillColor / SetCMYKStrokeColor 使用;ICC 管理的颜色空间经 THotPDF.RegisterICCProfile 注册,并自 HotPDF v2.7.0 起通过 SetFillColorSpace / SetStrokeColorSpace + SetFillColor / SetStrokeColor 应用
- 保存前把
THotPDF.UseXRefStream 设为 true,可输出单个经 FlateDecode 压缩的 /Type /XRef 交叉引用流,取代文本式 xref / trailer / startxref 序列(PDF 1.7 7.5.8);自 HotPDF v2.8.0 起可用
- 把
THotPDF.EnableXMPMetadata 设为 true,可向 Catalog 附加 XMP /Type /Metadata /Subtype /XML 流(PDF 1.7 14.3.2);由 Info 字典字段自动生成,也可经 CustomXMP 提供手写数据包。自 HotPDF v2.9.0 起可用
- 按方法进行 PDF 版本门控(自 HotPDF v2.24.0 起)。v2.4.0 之后引入的每个功能方法都会在输出前查询
RequirePDFVersion;StrictVersionLock=false(默认)时,文档 Version 会静默提升到该功能所需的最低版本;StrictVersionLock=true 时,调用会被拒绝,以便保存的文件严格符合所选 1.3 / 1.4 / 1.5 / 1.6 / 1.7 参考规范。
- 用于 FlateDecode 压缩图像数据的 PNG 和 TIFF predictor 编码器(PDF 1.7 7.4.4.4):
_PNGPredictorEncode 应用 libpng 的最小绝对差过滤启发式(Predictor=15),_TIFFPredictor2Encode 应用水平差分(Predictor=2)。自 HotPDF v2.10.0 起可用
- Tagged PDF entry points (PDF 1.7 14.7-14.8):
THotPDF.Lang populates /Lang in the Catalog, EnableTaggedPDF emits /MarkInfo <</Marked true>> and a stub /StructTreeRoot, and the new THPDFPage.BeginMarkedContent / BeginMarkedContentMCID / EndMarkedContent methods write the BMC / BDC / EMC content-stream operators. Available since HotPDF v2.11.0
- Axial and radial gradients (PDF 1.7 7.10 / 8.7):
THotPDF.RegisterAxialGradient / RegisterRadialGradient build the full Function Type 2 / Shading Type 2-3 / Pattern Type 2 stack and return a stable pattern name; THPDFPage.SetFillPattern / SetStrokePattern install it onto the page. Component count of the start / end colour selects DeviceGray (1) / DeviceRGB (3) / DeviceCMYK (4). Available since HotPDF v2.13.0; multi-stop axial gradients via Function Type 3 are exposed through RegisterMultiStopAxialGradient自 v2.18.0 起可用,RegisterMultiStopRadialGradient 自 v2.686.0 起可用
- 经
THPDFPage.DrawInlineImage 支持 inline image(PDF 1.7 8.9.7);未提供 Filter 时,原始字节会自动用 ASCIIHex 包装,使内容流保持 7-bit 安全。自 HotPDF v2.18.0 起可用
- 经
THotPDF.AddOutputIntent 支持 OutputIntents(PDF 1.7 14.11);每次调用都会向 Catalog 附加一个 /Type /OutputIntent 字典,并可用 /DestOutputProfile 引用已注册的 ICC profile。自 HotPDF v2.18.0 起可用
- AcroForm appearance stream 自动生成(PDF 1.7 12.5.5 / 12.7.3.3 / 8.10):添加交互式表单字段前把
THotPDF.AutoFormAppearances 设为 true,HotPDF 会为每个 widget 的 /AP /N 项预生成 /Subtype /Form Form XObject(按钮包含 Yes / Off 子字典),用 Helvetica / ZapfDingbats 间接字体字典填充 AcroForm /DR 默认资源,并把 /NeedAppearances 切换为 false,使渲染器采用嵌入的 appearance stream。自 HotPDF v2.28.0 起可用
- ViewerPreferences /ViewArea 和 /ViewClip(PDF 1.4 12.2 Table 152)现在通过
THotPDF.ViewArea / THotPDF.ViewClip 属性公开,并配有对应的 vpViewArea / vpViewClip 集合成员。二者均接受 THPDFPageBoundary 值(MediaBox / CropBox / BleedBox / TrimBox / ArtBox),补齐 HotPDF 对四个 PDF 1.4 页面边界 ViewerPreferences 的覆盖。自 HotPDF v2.29.0 起可用
- 页面转场(PDF 1.1 / 1.5 12.4.4):
THPDFPage.SetPageTransition 会在页面上写入 /Trans 字典,使 PDF 阅读器在 /PageMode /FullScreen 下以动画方式导航。THPDFTransitionStyle 枚举公开 PDF 1.1 样式(Split、Blinds、Box、Wipe、Dissolve、Glitter、R)和 PDF 1.5 样式(Fly、Push、Cover、Uncover、Fade),并同时公开配套的 /Dm、/M 和 /Di 子选项。THPDFPage.SetPageDuration 写入以秒计的 /Dur 自动翻页延迟。自 HotPDF v2.30.0 起可用
- 页面级透明度组(PDF 1.4 11.6.6 / 7.5.5):
THPDFPage.SetTransparencyGroup 附加 /Group 字典(/Type /Group /S /Transparency),使渲染器可预测地合成带 alpha 的内容。经 THPDFGroupColorSpace 枚举选择设备颜色空间(DeviceGray / DeviceRGB / DeviceCMYK 或省略),或调用 THPDFPage.SetTransparencyGroupICC 使用先前经 THotPDF.RegisterICCProfile 注册的 ICC profile 名称。可选 /I(Isolated)和 /K(Knockout)标志控制合成器;THPDFPage.ClearTransparencyGroup 移除先前附加的项。自 HotPDF v2.32.0 起可用
- 增量更新(PDF 1.7 ISO 32000-1 7.5.6):
THotPDF.BeginIncrementalUpdate(SourceFile) 以 append-only 模式加载现有 PDF;后续 CreateIndirect* 调用自动把新对象标脏,THotPDF.MarkDirty(Obj) 标记需重新输出的既有加载对象。THotPDF.SaveIncrementalUpdate(TargetFile) 逐字节保留原始源文件,只追加 dirty 对象并保留其对象编号,输出新的 xref subsection,并以带 /Prev 指向前一个 xref 的 trailer 收尾。与既有 AddSignedSignatureField + PreparePDFForSigning + InsertSignatureHex 管线结合,可为已签名文档追加签名字段而不破坏早期签名(原始字节不变,其 /ByteRange 摘要保持有效)。自 HotPDF v2.35.0 起可用
- 嵌入式 TrueType 字体名称规范化:HotPDF 读取嵌入 TrueType name table,并将
/BaseFont、/FontDescriptor /FontName、/FontFamily 以及后代 CID 字体名称与字体程序的 PostScript 名称对齐。这样可避免 PDF 字体字典与嵌入 TTF 载荷不一致导致的 Adobe Acrobat Font Capture 失败。自 HotPDF v2.35.1 起可用
- TrueType font subsetting (PDF 1.7 ISO 32000-1 9.6.4 / 9.8.2): set
THotPDF.EnableFontSubsetting to true before BeginDoc and HotPDF rebuilds the embedded TrueType payload to contain only the glyphs actually used by the document. Typical Latin documents see ~90% reduction in embedded font weight (1 MB Arial -> ~70 KB on a one-line "Hello, world."). Composite-glyph dependencies are tracked recursively, GID numbering is preserved (so existing Type0 / Identity-H content streams keep working), and the new /BaseFont automatically gains the spec-mandated six-letter "+"-suffixed prefix (e.g. /BaseFont /AAAAAA+ArialMT). Off by default; enable opt-in to keep full-font embedding for editing workflows. Available since HotPDF v2.36.0
- Compact Font Format (CFF) subsetter (PDF 1.7 ISO 32000-1 9.7.4 / 9.9): companion to the TrueType subsetter for OpenType-CFF (.otf, sfntVersion
OTTO) and Type 1 / Type 1C fonts. The unit-exported HPDFSubsetCFF(CFFBytes, KeepGlyph) function rebuilds the CharStrings INDEX with un-kept glyphs replaced by the minimal 1-byte endchar stub, preserving GID numbering byte-for-byte. Available since HotPDF v2.37.0.
- OpenType-CFF (.otf) 嵌入路径已接入
StoreFont(PDF 1.6+ 9.7.4 Table 117)。当 GDI 加载的字体二进制是 sfnt OTTO 容器时,HotPDF 会通过 HPDFSubsetOTFContainer 对嵌入的 'CFF ' 子表做子集化,经 /FontFile3 /Subtype /OpenType 输出字体程序,并把后代字体字典写为 /Subtype /CIDFontType0 而不是 /CIDFontType2。TrueType 字体继续走既有 /FontFile2 + /CIDFontType2 路径,行为不变。自 HotPDF v2.38.0 起可用。
- CFF 子程序端到端子集化(PDF 1.7 9.7.4 §6 / Adobe Tech Note #5177 §3.1):CFF subsetter 现在会从 Global Subr INDEX(位于 CFF 二进制中 String INDEX 之后)和 Local Subr INDEX(嵌在 Private DICT 下,经 Top DICT operator 18 + Private DICT operator 19 到达)两者中剥离未使用项。单个定点闭包沿
callsubr(op 0x0A)和 callgsubr(op 0x1D)链传递跟踪,因此 CharString 调用 Local Subr、再调 Global Subr、又调另一个 Local Subr 的链路会在一次迭代中收齐。每个未使用项替换为 1-byte return stub,INDEX 原地重写并把尾部空隙填零。该行为经公共 HPDFSubsetCFF 与 HPDFSubsetOTFContainer 辅助函数暴露;更低层的 CFF 扫描器保持内部实现。自 HotPDF v2.39.0 起可用。
- CID-keyed CFF 子集化(PDF 1.7 ISO 32000-1 9.7.4 / Adobe Tech Note #5176 §18-19):CFF subsetter 现在识别标记 CID-keyed OpenType-CFF 字体的 Top DICT
ROS operator(12-30),并遍历由 Font DICT 组成的 FDArray(12-36)INDEX;每个 Font DICT 都带有自己的 Private DICT + Local Subr INDEX。FDSelect(12-37)glyph-to-FD 映射逐字节保留。子程序闭包扫描会跟踪每个保留 CharString 的 FD 上下文,因此 FD #5 中的 glyph 只标记 FD #5 的 Local Subrs——global subrs 仍在各 FD 间共享。每个 FD 的 Local Subr INDEX 原地重写,未使用项折叠为 1-byte return stub。CJK / Indic / Arabic OTF 字体(Adobe Fan/Gothic/Heiti/Ming/Myungjo/Song Std、Kozuka Pr6N、Source Han Sans 等)现在走完整子集化管线,而不是整体嵌入。自 HotPDF v2.40.0 起可用。
- 对象流(PDF 1.5 ISO 32000-1 7.5.7):在
UseXRefStream 之外再把 THotPDF.UseObjectStreams 设为 true,SaveToStream 会把符合条件的间接对象(除 stream、加密字典以及 trailer 指向的 Catalog 和 Info 字典外)打包进一个或多个 /Type /ObjStm 容器流。交叉引用流随后经 type-2 条目引用打包对象(field-2 = 宿主 ObjStm 对象号;field-3 = 流内条目索引)。对含大量小字典的 PDF(多页文档、注释、AcroForm 控件、结构树元素、Optional Content 图层),文件体积显著下降——30 页纯图形冒烟样例从 14502 字节缩到 8488 字节(小 41.5%)。UseXRefStream 关闭时静默降级为 false(文本 xref 表按规范无法表示 type-2 条目),Version 低于 PDF 1.5 时同样降级。自 HotPDF v2.41.0 起可用。
- Soft-mask image / SMask(PDF 1.4 ISO 32000-1 8.9.5.4):
THotPDF.AddImageWithSMask(Width, Height, RGB, Alpha) 输出一个颜色图像 XObject 加一个 8-bit DeviceGray soft-mask image XObject,并自动接好 /SMask 交叉引用,使每个像素携带完整的逐通道透明度,摆脱旧 /ImageMask 路径的二值开关限制。便捷重载 THotPDF.AddImageWithSMask32(Bitmap32) 从 32-bit BGRA TBitmap 取出 RGB 与 alpha 平面,一次调用即可嵌入带 alpha 的 PNG。AddImageWithTransparency 与 AddImageWithTransparency32 以图像为中心的命名暴露同一工作流。两个调用点都经 RequirePDFVersion(pdf14) 门控,strict-mode 1.3 输出保持合规。自 HotPDF v2.42.0 起可用
- 图像蒙版便捷辅助:
AddImageAsMask 输出二值 /ImageMask,AddImageWithMask 经 /Mask 把得到的蒙版附加到彩色图像,两者都返回供 THPDFPage.ShowImage 使用的常规图像索引
- 逐图像压缩控制:
AddImageWithJpegQuality 一次调用指定 JPEG 质量而不改 JpegQuality;AddMonochromeImageAuto 与 icAutoMono 为 1-bit 位图输入自动选择 Flate、CCITT Group 4 或 JBIG2
- 无着色 Tiling Pattern 绘制(PDF 1.7 ISO 32000-1 8.6.6.1):
THotPDF.RegisterTilingPattern 自 v2.19.0 起已能输出 /PaintType 1(colored)与 /PaintType 2(uncolored),但配套的页面侧 operator 序列此前只对 colored 变体正确。六个新的 THPDFPage 方法——SetFillPatternRGB / SetStrokePatternRGB / SetFillPatternGray / SetStrokePatternGray / SetFillPatternCMYK / SetStrokePatternCMYK——通过在页面 Resources/ColorSpace 字典自动注册匹配的 [/Pattern /BaseCS] tinting 颜色空间,并输出规范要求的 tint_components /Pn scn 序列来驱动 uncolored 路径。tile 自带颜色的 colored 变体继续用原来的 SetFillPattern / SetStrokePattern。自 HotPDF v2.43.0 起可用。
- 完整的 tiling pattern 渲染现在相对父内容流的默认坐标系应用 pattern 矩阵,实现全部三种
/TilingType 放置规则,支持负 /XStep 与 /YStep,每个单元格以隔离路径开始,把 uncoloured pattern 的基色 tint 同时应用于填充与描边,并保留有界的嵌套 pattern 执行。扩展的 RegisterTilingPattern 重载与 THPDFTilingPatternBuilder.TilingType / Matrix 属性为生成 PDF 暴露同样的已验证控制。自 HotPDF v2.542.0 起可用
- CIELab 颜色空间(PDF 1.3+ ISO 32000-1 8.6.5.3):
THotPDF.RegisterLabColorSpace(Xw, Yw, Zw, aMin, aMax, bMin, bMax) builds an inline [/Lab << /WhitePoint /BlackPoint /Range >>] colour space array, stores it under an auto-generated name (Lab1, Lab2, ...) and returns that name for use with the regular THPDFPage.SetFillColorSpace / SetStrokeColorSpace + SetFillColor([L, a, b]) / SetStrokeColor([L, a, b]) pipeline. Drop in a D50 illuminant [0.9505, 1.0, 1.089] for ICC print workflows or a D65 illuminant [0.95047, 1.0, 1.08883] for sRGB-equivalent display, then paint with L* in [0..100] and a*, b* in the chosen range (typically [-128..127]). Available since HotPDF v2.44.0.
- 用于专色的 Separation 颜色空间(PDF 1.3+ ISO 32000-1 8.6.6.4):
THotPDF.RegisterSeparation(ColorantName, AlternateCS, TintC1) 声明单分量专色油墨,其 [0..1] 范围内的单个 tint 操作数驱动内部构建的线性 Function Type 2 tint transform。可将返回名称(Sep1、Sep2 等)用于常规 SetFillColorSpace / SetStrokeColorSpace + SetFillColor([tint]) / SetStrokeColor([tint]) 流程。AlternateCS 接受 DeviceGray、DeviceRGB 或 DeviceCMYK;TintC1 提供 tint = 1.0 时的 alternate-CS 分量。Pantone 及其他带空格的油墨名称可直接接受——HotPDF 写颜色空间名称时会按 PDF 1.7 7.3.5 把空格转义为 #20。自 HotPDF v2.45.0 起可用。
- AcroForm 多行与 comb 文本 appearance stream(PDF 1.7 ISO 32000-1 12.7.4.3):
THotPDF.AutoFormAppearances 开启时,Flags 含 ffMultiline 的文本字段会得到自动换行的 /AP /N Form XObject(Td + T* + /TL leading 布局,遵循 CR / LF / CRLF 分隔符并在可见行数处截断)。Flags 含 ffComb 且 MaxLen 为正的字段,会用每 glyph 一个绝对 Tm matrix 把每个字符绘入等宽单元格。无这些标志的字段逐字节保留 v2.28.0 的单行布局。初始值中的国际字符仍回退到阅读器的 /NeedAppearances 重算路径——完整的嵌入 CID 字体 appearance 生成仍是后续工作。自 HotPDF v2.46.0 起可用。
- AcroForm /AP Unicode font (PDF 1.7 ISO 32000-1 12.7.2 + 12.7.4.3):
THotPDF.SetFormUnicodeFontDict(LogicalName, FontDict) registers a caller-supplied Type 0 / CIDFontType2 + Identity-H composite font in the AcroForm /DR/Font default-resources dict. Once registered, the AcroForm-level /DA, every Tx widget's /DA, and the /AP /N stream produced by AutoFormAppearances for non-ASCII Tx initial values all switch to the logical name; the Form XObject's /Resources/Font sub-dict also references the same indirect font so the AP is self-contained without depending on /DR resolution at render time. The companion helper THotPDF.CreateIndirectFontDict returns a fresh empty THPDFDictionaryObject registered as an indirect PDF object so callers can build custom font dicts (or any other dict requiring "N G R" indirect serialisation) without touching internal helpers. Pass empty LogicalName and nil FontDict to revert to the v2.46.0 ASCII-only /Helv behaviour. ASCII Tx fields continue to use /Helv with byte-identical output to v2.46.0 / v2.55.0. Multi-line + comb non-ASCII /AP and RTL bidi shaping (UAX #9 + Arabic contextual joining) remain future work. Available since HotPDF v2.56.0; ffMultiline non-ASCII /AP support (per-line UTF-16BE hex Tj with Td / T* / /TL leading and CJK-aware word-wrap) since v2.57.0; ffComb non-ASCII /AP support (per-CID equal-width absolute Tm cells + single-cell Tj per code point with UTF-16 surrogate-pair handling) since v2.58.0; THotPDF.FormUnicodeRTL property for right-to-left direction (reverses UTF-16 order in /AP Tj hex while keeping /V in logical order; caller pre-shapes Arabic to Unicode presentation forms U+FB50..U+FDFF + U+FE70..U+FEFF; full UAX #9 + automatic GSUB shaping pending) since v2.59.0.
- AcroForm rich-text Tx widget(PDF 1.5+ ISO 32000-1 12.7.4.3 + Annex L):
THPDFPage.AddRichTextField(FieldName, InitialValue, RichValue, DefaultStyle, Rectangle, [MaxLen], [Flags]) 输出带 /RV(rich-text XHTML body)、/DS(CSS 风格默认样式)的文本 widget,自动置入 ffRichText /Ff bit 26 标志,并提供不解析 /RV 的阅读器所用的纯文本 /V + /DV 回退。RichText bit 打开时,Acrobat 和 Foxit 直接从 /RV 渲染,并从阅读器已安装的 Unicode 字体做字体回退——因此多字节内容(CJK / 西里尔 / 阿拉伯 / 带变音符的拉丁文)无需 HotPDF 在 /DR Resources 嵌入 CID 字体即可正确显示。/V 与 /RV 会在需要时自动检测多字节输入并切换到 UTF-16BE hex-string 编码(FE FF BOM + 大端码元)。HotPDF 自身 /AP 路径的 CID 字体 appearance-stream 生成仍是后续工作;支持 rich text 的阅读器不需要它。自 HotPDF v2.55.0 起可用。
- DeviceN colour space for multi-colorant spot-ink workflows (PDF 1.3+ ISO 32000-1 8.6.6.5):
THotPDF.RegisterDeviceN(ColorantNames, AlternateCS, TintC1Matrix) generalises RegisterSeparation from a single spot ink to N. The tint transform is a PostScript-calculator Function Type 4 emitting a linear weighted-blend over the supplied N x M matrix (row n column m is colorant n's contribution to AlternateCS channel m when colorant n is 1.0 alone). Returns a colour-space name (DevN1, DevN2, ...) that drives the regular SetFillColorSpace + SetFillColor([t0, t1, ..., t_{N-1}]) pipeline. AlternateCS accepts DeviceGray, DeviceRGB or DeviceCMYK; ink names with spaces are escaped to #20 per PDF 1.7 7.3.5; the special name None marks an unused colorant slot. Available since HotPDF v2.47.0.
- Free-form Gouraud-shaded triangle mesh (PDF 1.3+ ISO 32000-1 8.7.4.5.4):
THotPDF.RegisterFreeFormGouraudShading(XMin, YMin, XMax, YMax, NumComponents, Vertices) declares a /ShadingType 4 stream with /BitsPerCoordinate 16 + /BitsPerComponent 8 + /BitsPerFlag 8, wraps it in an inline Pattern Type 2 entry on the page Resources/Pattern dict, and returns the auto-generated pattern name (Sh1, Sh2, ...) for the regular SetFillPattern / SetStrokePattern pipeline. Each vertex is packed as 1 flag byte (always 0 for independent triangles) + 2 big-endian X bytes + 2 big-endian Y bytes + NumComponents 8-bit colour components. The NumComponents argument accepts 1 (DeviceGray), 3 (DeviceRGB) or 4 (DeviceCMYK); each vertex contributes 2 + NumComponents Extended values to Vertices in (X, Y, c1...cN) order; vertex count must be a multiple of 3. /Decode maps the 16-bit coordinates back to [XMin, XMax] x [YMin, YMax] and the colour components to [0, 1]. Type 5 (lattice), Type 6 (Coons patch) and Type 7 (tensor product) mesh shadings remain future work. Available since HotPDF v2.48.0.
- Lattice-form Gouraud 着色三角网格(PDF 1.3+ ISO 32000-1 8.7.4.5.5):
THotPDF.RegisterLatticeFormGouraudShading(XMin, YMin, XMax, YMax, NumComponents, VerticesPerRow, Vertices) 声明 /ShadingType 5 流,把顶点排成 M 行 x N 列网格,渲染器把相邻两行自动三角化为 triangle strip。不同于 RegisterFreeFormGouraudShading(Type 4),它没有 per-vertex flag byte;shading 字典不含 /BitsPerFlag,每个顶点只占 4 + NumComponents 字节(2 字节大端 X + 2 字节大端 Y + N 个颜色分量)。shading 字典改为携带必需的 /VerticesPerRow N 条目。适合已经位于规则采样网格上的源数据(地形、FEA 结果、科学热力图)——应用按行优先给出顶点,渲染管线自动组装 triangle strip 拓扑。VerticesPerRow 至少为 2,总顶点数必须是 VerticesPerRow 的倍数且至少两行。自 HotPDF v2.49.0 起可用。
- Coons patch mesh shading(PDF 1.3+ ISO 32000-1 8.7.4.5.6):
THotPDF.RegisterCoonsPatchMesh(XMin, YMin, XMax, YMax, NumComponents, Patches) 声明由 Coons patches 组成的 /ShadingType 6 流,每个 patch 由四条三次 Bezier 曲线围成,每个角携带一个颜色。渲染器在四条边之间拟合 Coons 曲面,得到任意弯曲的带颜色四边形——适合弯曲路径上的烫印与金属渐变、SVG 派生的渐变网格,以及任何弯边、否则需要大量小三角形逼近的四边形。每个 patch 贡献 12 个控制点(24 个 X+Y Extended 值,沿边界按 c1..c12 顺时针排列,c1 / c4 / c7 / c10 位于四角,其余 8 个为内部 Bezier 手柄),后接 4 个角颜色(4 * NumComponents 个 Extended 值),因此 Patches 步长为 24 + 4 * NumComponents。shading 字典携带 /BitsPerCoordinate 16 + /BitsPerComponent 8 + /BitsPerFlag 8(与 Type 4 相同;与 Type 5 不同,/VerticesPerRow 不存在)。每个输出的 patch 都带 flag = 0(独立 patch);本便捷重载不暴露连续 flag 1 / 2 / 3(边共享)。自 HotPDF v2.50.0 起可用。
- Separation colour space with sampled LUT tint transform (PDF 1.3+ ISO 32000-1 8.6.6.4 + 7.10.2):
THotPDF.RegisterSeparationLUT(ColorantName, AlternateCS, Samples) wraps RegisterSampledFunction so callers can express a full non-linear tint -> alt-CS curve as a flat byte stream of 8-bit (M-tuple) samples without manually constructing a Function Type 0 dictionary. Use the LUT variant when the colour transition is non-linear - PANTONE Hexachrome-style tint ramps, gamma-corrected density curves, hand-drawn tone curves matching a press characterisation, sRGB-to-spot conversion ICC LUTs without the full ICC profile machinery; the v2.45.0 RegisterSeparation entry point still covers the linear single-endpoint case. AlternateCS accepts DeviceGray, DeviceRGB or DeviceCMYK; Samples length must be a positive multiple of M with at least 2 * M bytes so the function has interpolable range, and the grid-point count S is inferred from Length(Samples) / M. Linear interpolation is the default per PDF 1.7 /Order 1. Returns the registered colour-space name (Sep1, Sep2, ...) for use with the regular SetFillColorSpace + SetFillColor([tint]) pipeline. Available since HotPDF v2.53.0.
- Function Type 0 (Sampled) registration (PDF 1.3+ ISO 32000-1 7.10.2):
THotPDF.RegisterSampledFunction(Domain, Range, Size, BitsPerSample, Samples, [Order]) declares an indirect /FunctionType 0 stream that expresses an arbitrary input-to-output mapping as a regular N-dimensional grid of M-dimensional output samples, interpolated between grid points. Use it where ICC profile machinery is overkill but a hand-tuned colour LUT is desired - tone curves for /TransferFunction (ExtGState /TR), sampled tint transforms for /Separation / /DeviceN beyond the linear Type 2 / arithmetic Type 4 paths, halftone threshold curves, or any other PDF construct that takes a Function dictionary. Domain is 2N entries (one [min, max] pair per input dimension); Range is 2M entries (one pair per output dimension); Size is N grid-point counts; BitsPerSample accepts 1, 2, 4, 8, 12, 16, 24, or 32 per PDF 1.7 Table 38; Samples is the raw bit-packed sample stream (MSB-first within each sample, no padding between samples beyond the final-byte zero-fill, with input 0 varying fastest per spec sample-order rules); Order defaults to 1 (linear) and accepts 3 (cubic-spline interpolation, since v2.54.0) per PDF 1.7 Table 38. HotPDF validates the sample-byte count against ceil(GridPoints * M * BitsPerSample / 8). Returns the indirect THPDFStreamObject so callers can attach it wherever a Function dictionary is expected. Available since HotPDF v2.52.0; cubic /Order 3 + end-to-end multi-input / multi-output coverage since v2.54.0.
- 张量积 patch mesh shading(PDF 1.3+ ISO 32000-1 8.7.4.5.7):
THotPDF.RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax, NumComponents, Patches) 声明由张量积 patch 组成的 /ShadingType 7 流,每个 patch 由完整的 4 x 4 双三次 Bezier 控制点网格 p[i][j] 加每个角一个颜色定义。它在 RegisterCoonsPatchMesh(Type 6)的 12 个边界点之上增加 4 个显式内部控制点(p[1][1]、p[1][2]、p[2][2]、p[2][1]),对 patch 内部的控制比 Coons 混合拟合更精细。适合 SVG mesh-gradient 往返以及需要张量积 Bezier 曲面的图稿。每个 patch 贡献 16 个控制点(32 个 X+Y Extended 值,按规范 Table 88 流顺序排列:p[0][0..3]、p[1][3]、p[2][3]、p[3][3]、p[3][2..0]、p[2][0]、p[1][0],然后是 4 个内部点 p[1][1]、p[1][2]、p[2][2]、p[2][1]),后接 4 个角颜色(p[0][0] / p[0][3] / p[3][3] / p[3][0] 处的 4 * NumComponents 个 Extended 值),因此 Patches 步长为 32 + 4 * NumComponents。每个输出的 patch 都带 flag = 0(独立 patch)。自本版本起,ISO 32000-1 8.7.4.5 的整个 mesh shading 家族(Type 4 / 5 / 6 / 7)全部覆盖。自 HotPDF v2.51.0 起可用。
- Annotation border style and Popup linkage (PDF 1.7 12.5.4 / 12.5.6.14):
THPDFPage.SetAnnotationBorderStyle(Annot, Width, Style, DashPattern) attaches a /BS dictionary with the chosen THPDFAnnotBorderStyle (absSolid / absDashed / absBeveled / absInset / absUnderline). THPDFPage.AddPopupAnnotationFor(ParentAnnot, Rect, Open) emits a /Popup annotation that is wired in both directions (parent /Popup -> popup, popup /Parent -> parent) so the viewer can render the speech-balloon connector. The new THPDFPage.LastAnnotation property feeds either helper without changing the signature of the existing Add*Annotation procedures. Available since HotPDF v2.34.0
- 公钥安全处理器(ISO 32000-1 7.6.4、ISO 32000-2 7.6.5):
THotPDF.EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) + THotPDF.AddPubKeyRecipient(envelope) 输出 /Filter /Adobe.PubSec 加密字典(V=1 RC4-40 用 /SubFilter /adbe.pkcs7.s4,V=2 RC4-128 与 V=4 AESV2 用 /adbe.pkcs7.s5)。调用方提供 20 字节随机 seed 和每个收件人一个 PKCS#7 envelopedData 二进制 blob(外部用 Windows CryptoAPI、OpenSSL 或 pycryptodome 构建)。HotPDF 按 ISO 32000-1 7.6.4.3 的描述派生文件加密密钥(seed 与每个 envelope 拼接后取 SHA-1),并复用标准的逐对象密钥派生处理 AES-128 / RC4 流。自 HotPDF v2.33.0 起可用
- 已加载页面渲染解码 Shading Type 4 到 7,支持全部标准坐标、分量与 flag 位宽、字节对齐记录、Type 4 三角形与 Type 6 / 7 patch 连续 flag、可选 Function 数组、声明的 ColorSpace 转换、BBox 与 Background 处理、clip 剔除、分批 Gouraud 填充,以及有界的自适应 Coons 与 tensor-product 镶嵌。自 HotPDF v2.488.0 起可用
另请参阅
|