|
PDF 篩選器支援
總覽
PDF streams 與嵌入影像會透過 filter 名稱標示其編碼方式。HotPDF 在產生檔案或解碼外部內容時,主要使用下列 filter 家族
常見 filter
- FlateDecode:產生 streams 時的主要壓縮 filter,也是以 zlib 為基礎的主要解壓縮路徑
- LZWDecode:透過 HPDFLZW.pas 支援舊版與相容性情境
- DCTDecode: 用於 HotPDF 影像載入路徑處理的標準 JPEG 影像資料
- CCITTFaxDecode: 常見於單色 TIFF 與傳真式影像資料
- ASCIIHexDecode / ASCII85Decode / RunLengthDecode:自 HotPDF v2.4.0 起在 HPDFTypes.pas 公開的 encoder helpers(_ASCIIHexEncode、_ASCII85Encode、_RunLengthEncode)。在需要將任意二進位內容包裝給 7-bit 通道,或需要明確支援 PDF 1.7 7.4 round-trip 時很有用
_ASCIIHexEncode、_ASCII85Encode、_RunLengthEncode) 自 HotPDF v2.4.0 起提供。將任意二進位內容包裝給 7-bit 通道,或需要明確的 PDF 1.7 7.4 往返支援時很有用
- JBIG2Decode / JPXDecode:PDF 1.7 7.4.7 / 7.4.9 定義的 filter 名稱。HotPDF 隨附的 JBIG2 與 JPEG 2000 helpers 目前是 stubs,在連結真正的 OpenJPEG / JBIG2 backend 前會回報不支援(return False)。較早的 builds 會回傳假的 100×100 成功結果並產生無法讀取的影像;這點現在已修正
實務備註
- 對產生的 PDF 內容而言,THotPDF.Compression 仍是主要的使用者可見設定
- 載入外部資料時,適用的 filter 取決於來源檔案格式與正在使用的 helper class
- 加密 PDF 會將這些 filters 與 security handler 搭配使用;支援的 AES‑128(V=4 R=4 / CFM=AESV2)與 RC4(V=1/V=2)選項請參閱 CryptKeyLength
- 互動式表單欄位會輸出成由檢視器繪製的 widget 標註;參閱 AcroForm 支援
- 文字標記標註(Highlight、Underline、Squiggly、StrikeOut)與文件內跳轉連結(
GoTo、GoToR、Launch)自 HotPDF v2.6.0 起以新的 THPDFPage.Add*Annotation / AddGoToLink / AddGoToRLink / AddLaunchLink 方法提供/V 4 or newer
- Encrypted payload wrappers keep ordinary page streams visible while protecting embedded-file metadata and bytes through an
EFOpen crypt filter, with explicit loaded-document inspection and unlock APIs available since HotPDF v2.715.0
- Password-protected attachment streams use
/EFF and receive an explicit Crypt filter whenever /EFF differs from /StmF. Public-key encrypted explicit stream filters fail closed because they require a stream-specific recipient envelope
- Loaded documents expose the original
/CF, /StrF, /StmF, and /EFF policy, including case-sensitive external named filters, explicit or omitted /CFM /None, authentication events, and effective key length through THPDFCryptFilterInfo. Standard-handler V2 filter lengths are read as bytes, public-key V2 filter lengths are read as bits, and only 40-bit and 128-bit V2 keys are accepted. Plaintext object-stream containers still decrypt packed member strings through /StrF, while encrypted containers avoid a second member decrypt. Incremental updates retain the loaded policy. Available since HotPDF v2.675.0
- DeviceCMYK 輸出可透過 THPDFPage.SetCMYKColor / SetCMYKFillColor / SetCMYKStrokeColor 使用;自 HotPDF v2.7.0 起,ICC-managed color spaces 透過 THotPDF.RegisterICCProfile 註冊,並經由 SetFillColorSpace / SetStrokeColorSpace + SetFillColor / SetStrokeColor 套用
- 儲存前將 THotPDF.UseXRefStream 設為 true,即可輸出單一 /Type /XRef、以 FlateDecode 壓縮的 cross-reference stream,而不是文字形式的 xref / trailer / startxref 序列(PDF 1.7 7.5.8);自 HotPDF v2.8.0 起提供
GoTo, GoToR, Launch) are exposed as new THPDFPage.Add*Annotation / AddGoToLink / AddGoToRLink / AddLaunchLink methods since HotPDF v2.6.0
- 將 THotPDF.EnableXMPMetadata 設為 true,即可將 XMP /Type /Metadata /Subtype /XML stream 附加到 Catalog(PDF 1.7 14.3.2);內容可由 Info dict 欄位自動建立,也可透過 CustomXMP 提供手寫 packet。自 HotPDF v2.9.0 起提供
THPDFPage.SetCMYKColor / SetCMYKFillColor / SetCMYKStrokeColor; ICC-managed color spaces are registered with THotPDF.RegisterICCProfile and applied via SetFillColorSpace / SetStrokeColorSpace + SetFillColor / SetStrokeColor since HotPDF v2.7.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 reference spec
THotPDF.UseXRefStream to true before saving to emit a single /Type /XRef FlateDecode-compressed cross-reference stream instead of the textual xref / trailer / startxref sequence (PDF 1.7 7.5.8); available since HotPDF v2.8.0
- 用於 FlateDecode 壓縮影像資料的 PNG 與 TIFF predictor encoders(PDF 1.7 7.4.4.4):_PNGPredictorEncode 套用 libpng minimum-absolute-difference filter heuristic(Predictor=15),_TIFFPredictor2Encode 套用 horizontal differencing(Predictor=2)。自 HotPDF v2.10.0 起提供
THotPDF.EnableXMPMetadata to true to attach an XMP /Type /Metadata /Subtype /XML stream to the Catalog (PDF 1.7 14.3.2); auto-built from the Info dict fields, or supply a hand-authored packet via CustomXMP. Available since HotPDF v2.9.0
- Per-method PDF version gating (since HotPDF v2.24.0). Every feature method introduced in v2.4.0+ consults
RequirePDFVersion before emitting; with StrictVersionLock=false (the default) the document Version is silently auto-bumped to the minimum the feature requires, and with StrictVersionLock=true the call is refused so the saved file strictly conforms to the chosen 1.3 / 1.4 / 1.5 / 1.6 / 1.7 reference spec.
- PNG and TIFF predictor encoders for FlateDecode-compressed image data (PDF 1.7 7.4.4.4):
_PNGPredictorEncode applies the libpng minimum-absolute-difference filter heuristic (Predictor=15), _TIFFPredictor2Encode applies horizontal differencing (Predictor=2). Available since 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 color selects DeviceGray (1) / DeviceRGB (3) / DeviceCMYK (4). Available since HotPDF v2.13.0; Function Type 3 multi-stop gradients are exposed through RegisterMultiStopAxialGradient since v2.18.0 and RegisterMultiStopRadialGradient since v2.686.0
- Inline images (PDF 1.7 8.9.7) via
THPDFPage.DrawInlineImage; raw bytes are auto-wrapped with ASCIIHex when no Filter is supplied so the content stream stays 7-bit-clean. Available since HotPDF v2.18.0
- OutputIntents (PDF 1.7 14.11) via
THotPDF.AddOutputIntent; each call appends a /Type /OutputIntent dict to the Catalog with optional /DestOutputProfile referencing a registered ICC profile. Available since HotPDF v2.18.0
- AcroForm appearance-stream auto-generation (PDF 1.7 12.5.5 / 12.7.3.3 / 8.10): set
THotPDF.AutoFormAppearances to true before adding interactive form fields and HotPDF will pre-build a /Subtype /Form Form XObject for each widget's /AP /N entry (Yes / Off sub-dicts for buttons), populate the AcroForm /DR default resources with Helvetica / ZapfDingbats indirect font dicts, and switch /NeedAppearances to false so renderers honor the embedded streams. Available since HotPDF v2.28.0
- ViewerPreferences /ViewArea and /ViewClip (PDF 1.4 12.2 Table 152) are now exposed through
THotPDF.ViewArea / THotPDF.ViewClip properties (with the matching vpViewArea / vpViewClip set members). Both accept the THPDFPageBoundary values (MediaBox / CropBox / BleedBox / TrimBox / ArtBox) and complete HotPDF's coverage of the four PDF 1.4 page-boundary ViewerPreferences. Available since HotPDF v2.29.0
- Page transitions (PDF 1.1 / 1.5 12.4.4):
THPDFPage.SetPageTransition writes a /Trans dictionary on the page so PDF readers in /PageMode /FullScreen animate navigation. PDF 1.1 styles (Split, Blinds, Box, Wipe, Dissolve, Glitter, R) and PDF 1.5 styles (Fly, Push, Cover, Uncover, Fade) are exposed through the THPDFTransitionStyle enumeration; companion /Dm, /M and /Di sub-options are also exposed. THPDFPage.SetPageDuration writes the /Dur auto-advance delay in seconds. Available since HotPDF v2.30.0
- Page-level transparency group (PDF 1.4 11.6.6 / 7.5.5):
THPDFPage.SetTransparencyGroup attaches a /Group dictionary (/Type /Group /S /Transparency) so renderers composite alpha-bearing content predictably. Choose a device color space through the THPDFGroupColorSpace enumeration (DeviceGray / DeviceRGB / DeviceCMYK or omit), or call THPDFPage.SetTransparencyGroupICC with the name of an ICC profile previously registered through THotPDF.RegisterICCProfile. Optional /I (Isolated) and /K (Knockout) flags steer the compositor; THPDFPage.ClearTransparencyGroup removes a previously-attached entry. Available since HotPDF v2.32.0
- Incremental update (PDF 1.7 ISO 32000-1 7.5.6):
THotPDF.BeginIncrementalUpdate(SourceFile) loads an existing PDF in append-only mode; subsequent CreateIndirect* calls auto-mark new objects dirty, and THotPDF.MarkDirty(Obj) tags pre-existing loaded objects for re-emission. THotPDF.SaveIncrementalUpdate(TargetFile) writes the original source bytes verbatim, appends only dirty objects with their object numbers preserved, emits a new xref subsection, and finishes with a trailer carrying /Prev pointing at the previous xref. Combine with the existing AddSignedSignatureField + PreparePDFForSigning + InsertSignatureHex pipeline to add subsequent signature fields to an already-signed document without invalidating earlier signatures (their /ByteRange digests remain valid because none of the original bytes mutate). Available since HotPDF v2.35.0
- Embedded TrueType font-name normalization: HotPDF reads the embedded TrueType name table and aligns
/BaseFont, /FontDescriptor /FontName, /FontFamily, and descendant CID font names with the font program's PostScript name. This avoids Adobe Acrobat Font Capture failures caused by a mismatch between the PDF font dictionary and the embedded TTF payload. Available since 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.
- Tagged PDF 進入點(PDF 1.7 14.7-14.8):
THotPDF.Lang 填入 Catalog 裡的 /Lang;EnableTaggedPDF 輸出 /MarkInfo <</Marked true>> 與 stub 的 /StructTreeRoot;新的 THPDFPage.BeginMarkedContent / BeginMarkedContentMCID / EndMarkedContent 方法負責寫出 BMC / BDC / EMC 內容串流運算子。自 HotPDF v2.11.0 起提供
- 軸向與放射狀漸層(PDF 1.7 7.10 / 8.7):
THotPDF.RegisterAxialGradient / RegisterRadialGradient 會建立完整的 Function Type 2 / Shading Type 2-3 / Pattern Type 2 堆疊,並傳回穩定的 pattern 名稱;再用 THPDFPage.SetFillPattern / SetStrokePattern 套用到頁面。起訖顏色的 component 數決定選用 DeviceGray (1) / DeviceRGB (3) / DeviceCMYK (4)。自 HotPDF v2.13.0 起提供;透過 Function Type 3 的多站點軸向漸層自 v2.18.0 起由 RegisterMultiStopAxialGradient 提供
- Inline images(PDF 1.7 8.9.7)透過 THPDFPage.DrawInlineImage 輸出;未提供 Filter 時,raw bytes 會自動以 ASCIIHex 包裝,讓 content stream 保持 7-bit-clean。自 HotPDF v2.18.0 起提供
ROS operator (12-30) that marks a CID-keyed OpenType-CFF font and walks the FDArray (12-36) INDEX of Font DICTs, each carrying its own Private DICT + Local Subr INDEX. The FDSelect (12-37) glyph-to-FD map is preserved byte-for-byte. The subroutine-closure scan tracks each kept CharString's FD context so a glyph in FD #5 marks Local Subrs in FD #5 only - global subrs remain shared across FDs. Each FD's Local Subr INDEX is rewritten in place with unused entries collapsed to 1-byte return stubs. CJK / Indic / Arabic OTF fonts (Adobe Fan/Gothic/Heiti/Ming/Myungjo/Song Std, Kozuka Pr6N, Source Han Sans, etc.) now go through the full subsetting pipeline instead of being embedded as-is. Available since HotPDF v2.40.0.
- OutputIntents(PDF 1.7 14.11)透過 THotPDF.AddOutputIntent 建立;每次呼叫都會將 /Type /OutputIntent dict 附加到 Catalog,並可選擇以 /DestOutputProfile 參照已註冊的 ICC profile。自 HotPDF v2.18.0 起提供
THotPDF.UseObjectStreams to true in addition to UseXRefStream and SaveToStream packs eligible indirect objects (everything except streams, the encryption dictionary, and the trailer-pointed Catalog and Info dictionaries) into one or more /Type /ObjStm container streams. The cross-reference stream then references the packed objects through type-2 entries (field-2 = host ObjStm object number; field-3 = entry index inside the stream). Cuts file size substantially on PDFs with many small dictionaries (multi-page documents, annotations, AcroForm widgets, structure-tree elements, Optional Content layers) - a 30-page graphics-only smoke shrinks from 14502 to 8488 bytes (41.5% smaller). Silently downgrades to false when UseXRefStream is off (type-2 entries are not representable in the textual xref table per spec) or when Version is below PDF 1.5. Available since HotPDF v2.41.0.
- AcroForm appearance-stream 自動產生(PDF 1.7 12.5.5 / 12.7.3.3 / 8.10):加入互動式表單欄位前將 THotPDF.AutoFormAppearances 設為 true,HotPDF 會為每個 widget 的 /AP /N entry 預先建立 /Subtype /Form Form XObject(按鈕會建立 Yes / Off sub-dicts),在 AcroForm /DR default resources 中填入 Helvetica / ZapfDingbats indirect font dicts,並將 /NeedAppearances 切換為 false,讓 renderers 採用內嵌 streams。自 HotPDF v2.28.0 起提供
THotPDF.AddImageWithSMask(Width, Height, RGB, Alpha) emits a color image XObject plus an 8-bit DeviceGray soft-mask image XObject and wires the /SMask cross-reference automatically, so each pixel can carry full per-channel transparency instead of the binary on/off limit of the legacy /ImageMask path. The convenience overload THotPDF.AddImageWithSMask32(Bitmap32) pulls the RGB and alpha planes out of a 32-bit BGRA TBitmap for one-call PNG-with-alpha embedding. AddImageWithTransparency and AddImageWithTransparency32 expose the same workflow with image-centric naming. Both call sites gate through RequirePDFVersion(pdf14) so strict-mode 1.3 output stays compliant. Available since HotPDF v2.42.0
- TrueType 字型子集化(PDF 1.7 ISO 32000-1 9.6.4 / 9.8.2):在
BeginDoc 之前把 THotPDF.EnableFontSubsetting 設為 true,HotPDF 會重建嵌入的 TrueType 資料,只保留文件實際用到的字形。典型拉丁文字文件的嵌入字型體積約可減少 90%(一行 "Hello, world." 的 1 MB Arial 縮到約 70 KB)。複合字形的依賴會遞迴追蹤,GID 編號原樣保留(既有的 Type0 / Identity-H 內容串流因此照常運作),新的 /BaseFont 也會自動加上規格要求的六字母 "+" 前綴(例如 /BaseFont /AAAAAA+ArialMT)。預設關閉;需要完整嵌入字型的編輯工作流程可以不開。自 HotPDF v2.36.0 起提供
- Compact Font Format(CFF)子集化(PDF 1.7 ISO 32000-1 9.7.4 / 9.9):TrueType 子集化的姊妹功能,適用 OpenType-CFF(.otf,sfntVersion
OTTO)與 Type 1 / Type 1C 字型。單元匯出的 HPDFSubsetCFF(CFFBytes, KeepGlyph) 函式會重建 CharStrings INDEX,未保留的字形改以最小的 1 位元組 endchar stub 取代,GID 編號逐位元組保留。自 HotPDF v2.37.0 起提供icAutoMono 為 1-bit 點陣輸入選擇 Flate、CCITT Group 4 或 JBIG2
- CIELab 色彩空間(PDF 1.3+ ISO 32000-1 8.6.5.3):
THotPDF.RegisterLabColorSpace(Xw, Yw, Zw, aMin, aMax, bMin, bMax) 會建立內嵌的 [/Lab << /WhitePoint /BlackPoint /Range >>] 色彩空間陣列,存成自動命名的名稱(Lab1、Lab2、...),並傳回該名稱供一般 THPDFPage.SetFillColorSpace / SetStrokeColorSpace + SetFillColor([L, a, b]) / SetStrokeColor([L, a, b]) 管線使用。ICC 列印工作流程放 D50 光源 [0.9505, 1.0, 1.089],等效 sRGB 的顯示用途放 D65 光源 [0.95047, 1.0, 1.08883],然後以 [0..100] 的 L* 與所選範圍內的 a*、b*(通常 [-128..127])上色。自 HotPDF v2.44.0 起提供
- 用於 spot colors 的 Separation color space(PDF 1.3+ ISO 32000-1 8.6.6.4):THotPDF.RegisterSeparation(ColorantName, AlternateCS, TintC1) 宣告一個單一 component 的 spot ink,其 [0..1] 內的單一 tint operand 會驅動內部建立的線性 Function Type 2 tint transform。將回傳名稱(Sep1、Sep2、...)搭配一般 SetFillColorSpace / SetStrokeColorSpace + SetFillColor([tint]) / SetStrokeColor([tint]) pipeline 使用。AlternateCS 接受 DeviceGray、DeviceRGB 或 DeviceCMYK;TintC1 提供 tint = 1.0 時的 alt-CS components。Pantone 與其他含空格的 ink names 可直接接受;HotPDF 寫入 color-space name 時會依 PDF 1.7 7.3.5 將空格 escape 為 #20。自 HotPDF v2.45.0 起提供
/TilingType placement rules, supports negative /XStep and /YStep, starts every cell with an isolated path, applies an uncoloured pattern's base tint to both fill and stroke operations, and retains bounded nested-pattern execution. The extended RegisterTilingPattern overload and THPDFTilingPatternBuilder.TilingType / Matrix properties expose the same validated controls for generated PDFs. Available since HotPDF v2.542.0
- AcroForm multi-line 與 comb text appearance streams(PDF 1.7 ISO 32000-1 12.7.4.3):當 THotPDF.AutoFormAppearances 開啟時,Flags 包含 ffMultiline 的 text fields 會取得 word-wrapped /AP /N Form XObject(Td + T* + /TL leading layout,遵守 CR / LF / CRLF separators 並依可見列數截斷)。Flags 包含 ffComb 且 MaxLen 為正值的欄位,會用每個 glyph 的絕對 Tm matrix 將每個字元繪製到自己的等寬 cell。沒有這些 flags 的欄位會逐位元保留 v2.28.0 的 single-line layout。初始值中的國際字元仍會落到 viewer 的 /NeedAppearances recomputation path;完整 embedded-CID-font appearance generation 仍是未來工作。自 HotPDF v2.46.0 起提供
THotPDF.RegisterLabColorSpace(Xw, Yw, Zw, aMin, aMax, bMin, bMax) builds an inline [/Lab << /WhitePoint /BlackPoint /Range >>] color 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 color space for spot colors (PDF 1.3+ ISO 32000-1 8.6.6.4):
THotPDF.RegisterSeparation(ColorantName, AlternateCS, TintC1) declares a one-component spot ink whose single tint operand in [0..1] drives a linear Function Type 2 tint transform built internally. Use the returned name (Sep1, Sep2, ...) with the regular SetFillColorSpace / SetStrokeColorSpace + SetFillColor([tint]) / SetStrokeColor([tint]) pipeline. AlternateCS accepts DeviceGray, DeviceRGB or DeviceCMYK; TintC1 supplies the alt-CS components at tint = 1.0. Pantone and other ink names with spaces are accepted directly - HotPDF escapes them to #20 per PDF 1.7 7.3.5 when writing the color-space name. Available since HotPDF v2.45.0.
- AcroForm multi-line and comb text appearance streams (PDF 1.7 ISO 32000-1 12.7.4.3): when
THotPDF.AutoFormAppearances is on, text fields whose Flags include ffMultiline get a word-wrapped /AP /N Form XObject (Td + T* + /TL leading layout, honoring CR / LF / CRLF separators and truncating at the visible row count). Fields whose Flags include ffComb together with a positive MaxLen render each character into its own equal-width cell using an absolute Tm matrix per glyph. The single-line layout from v2.28.0 is preserved byte-for-byte for fields with no such flags. International characters in the initial value still fall through to the viewer's /NeedAppearances recomputation path - full embedded-CID-font appearance generation remains future work. Available since 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 serialization) without touching internal helpers. Pass empty LogicalName and nil FontDict to revert to the v2.46.0 ASCII-only /Helv behavior. 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]) 會輸出 text widget,包含 /RV(rich-text XHTML body)、/DS(類 CSS default style)、自動 OR 進去的 ffRichText /Ff bit 26 flag,以及不解析 /RV 的 readers 使用的 plain-text /V + /DV fallback。當 RichText bit 開啟時,Acrobat 與 Foxit 會直接從 /RV render,並使用 reader 已安裝 Unicode fonts 的 font fallbacks,因此 multi-byte content(CJK / Cyrillic / Arabic / accented Latin)可正確顯示,不需要 HotPDF 在 /DR Resources 中嵌入 CID font。/V 與 /RV 都會自動偵測 multi-byte input,必要時切換到 UTF-16BE hex-string encoding(FE FF BOM + big-endian code units)。HotPDF 自身 /AP path 的 CID-font appearance-stream generation 仍是未來工作;支援 rich-text 的 viewers 不需要它。自 HotPDF v2.55.0 起提供
THPDFPage.AddRichTextField(FieldName, InitialValue, RichValue, DefaultStyle, Rectangle, [MaxLen], [Flags]) emits a text widget with /RV (rich-text XHTML body), /DS (CSS-like default style), the ffRichText /Ff bit 26 flag automatically OR'd in, plus the plain-text /V + /DV fallback used by readers that do not parse /RV. Acrobat and Foxit render directly from /RV when the RichText bit is on, picking up font fallbacks from the reader's installed Unicode fonts - so multi-byte content (CJK / Cyrillic / Arabic / accented Latin) displays correctly without HotPDF embedding a CID font in /DR Resources. Both /V and /RV auto-detect multi-byte input and switch to UTF-16BE hex-string encoding (FE FF BOM + big-endian code units) when needed. CID-font appearance-stream generation for HotPDF's own /AP path remains future work; rich-text-aware viewers do not need it. Available since HotPDF v2.55.0.
- DeviceN 色彩空間,用於多色版特別色工作流程(PDF 1.3+ ISO 32000-1 8.6.6.5):
THotPDF.RegisterDeviceN(ColorantNames, AlternateCS, TintC1Matrix) 把 RegisterSeparation 的單一特別色推廣到 N 色。tint transform 是 PostScript 計算器式的 Function Type 4,對傳入的 N x M 矩陣做線性加權混合(僅 colorant n 為 1.0 時,矩陣第 n 列第 m 欄就是它對 AlternateCS 第 m 個 channel 的貢獻)。傳回色彩空間名稱(DevN1、DevN2、...),搭配一般 SetFillColorSpace + SetFillColor([t0, t1, ..., t_{N-1}]) 管線使用。AlternateCS 接受 DeviceGray、DeviceRGB 或 DeviceCMYK;含空格的油墨名稱依 PDF 1.7 7.3.5 escape 成 #20;特殊名稱 None 代表未使用的色版槽位。自 HotPDF v2.47.0 起提供
- 自由格式 Gouraud 著色三角網格(PDF 1.3+ ISO 32000-1 8.7.4.5.4):
THotPDF.RegisterFreeFormGouraudShading(XMin, YMin, XMax, YMax, NumComponents, Vertices) 宣告帶 /BitsPerCoordinate 16 + /BitsPerComponent 8 + /BitsPerFlag 8 的 /ShadingType 4 串流,包成頁面 Resources/Pattern 字典裡的內嵌 Pattern Type 2 項目,並傳回自動命名的 pattern 名稱(Sh1、Sh2、...)供一般 SetFillPattern / SetStrokePattern 管線使用。每個 vertex 打包成 1 個 flag 位元組(獨立三角形固定為 0)+ 2 個 big-endian X 位元組 + 2 個 big-endian Y 位元組 + NumComponents 個 8 位元顏色 component。NumComponents 接受 1(DeviceGray)、3(DeviceRGB)或 4(DeviceCMYK);每個 vertex 依 (X, Y, c1...cN) 順序對 Vertices 貢獻 2 + NumComponents 個 Extended 值;vertex 數必須是 3 的倍數。/Decode 會把 16 位元座標映射回 [XMin, XMax] x [YMin, YMax],顏色 component 映射到 [0, 1]。Type 5(lattice)、Type 6(Coons patch)與 Type 7(tensor product)網格尚屬未來工作。自 HotPDF v2.48.0 起提供
- Lattice-form Gouraud-shaded triangle mesh(PDF 1.3+ ISO 32000-1 8.7.4.5.5):THotPDF.RegisterLatticeFormGouraudShading(XMin, YMin, XMax, YMax, NumComponents, VerticesPerRow, Vertices) 宣告 /ShadingType 5 stream,將 vertices 排成 M-row x N-column lattice,並讓 renderer 自動把每對相鄰列三角化為 triangle strip。不同於 RegisterFreeFormGouraudShading(Type 4),它沒有 per-vertex flag byte;shading dictionary 不含 /BitsPerFlag,且每個 vertex 只佔 4 + NumComponents bytes(2 big-endian X + 2 big-endian Y + N color components)。shading dictionary 改為攜帶必要的 /VerticesPerRow N entry。適用於來源資料已位於規則 sample grid(terrain、FEA results、scientific heatmaps)的情境;應用程式以 row-major 提供 vertices,rendering pipeline 會自動組裝 triangle strip topology。VerticesPerRow 至少必須為 2,且 vertex 總數必須是 VerticesPerRow 的倍數並至少有兩列。自 HotPDF v2.49.0 起提供
THotPDF.RegisterLatticeFormGouraudShading(XMin, YMin, XMax, YMax, NumComponents, VerticesPerRow, Vertices) declares a /ShadingType 5 stream that arranges vertices in an M-row x N-column lattice and lets the renderer auto-triangulate each pair of adjacent rows into a triangle strip. Unlike RegisterFreeFormGouraudShading (Type 4), there is no per-vertex flag byte; /BitsPerFlag is absent from the shading dictionary and each vertex occupies only 4 + NumComponents bytes (2 big-endian X + 2 big-endian Y + N color components). The shading dictionary instead carries the required /VerticesPerRow N entry. Use it for source data that is already on a regular sample grid (terrain, FEA results, scientific heatmaps) - the application supplies vertices row-major and the rendering pipeline assembles the triangle strip topology automatically. VerticesPerRow must be at least 2 and total vertex count must be a multiple of VerticesPerRow with at least two rows. Available since 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 stream,每個 patch 由四條 cubic Bezier curves 圍成,且每個角各帶一個顏色。renderer 會在四條邊之間擬合 Coons surface,產生可任意彎曲且帶顏色的 quad;適合彎曲路徑上的 foil 與 metallic gradients、SVG-derived gradient meshes,以及任何原本需要大量小三角形近似的 curved-edge quad。每個 patch 提供 12 個 control points(24 個 X+Y Extended values,依 c1..c12 沿邊界順時針排序,其中 c1 / c4 / c7 / c10 位於四個角,其餘 8 個是 inner Bezier handles),後接 4 個 corner colors(4 * NumComponents Extended values),因此 Patches stride 為 24 + 4 * NumComponents。shading dictionary 攜帶與 Type 4 相同的 /BitsPerCoordinate 16 + /BitsPerComponent 8 + /BitsPerFlag 8(且不同於 Type 5,不含 /VerticesPerRow)。每個輸出的 patch 都帶 flag = 0(independent patch);continuation flags 1 / 2 / 3(edge sharing)未在此 convenience overload 中公開。自 HotPDF v2.50.0 起提供
THotPDF.RegisterCoonsPatchMesh(XMin, YMin, XMax, YMax, NumComponents, Patches) declares a /ShadingType 6 stream of Coons patches, each bounded by four cubic Bezier curves and carrying one color per corner. The renderer fits the Coons surface between the four edges, giving an arbitrarily curved color-bearing quad - useful for foil and metallic gradients on bent paths, SVG-derived gradient meshes, and any quad with curved edges that would otherwise need many small triangles to approximate. Each patch contributes 12 control points (24 X+Y Extended values, ordered c1..c12 clockwise around the boundary with c1 / c4 / c7 / c10 at the four corners and the remaining 8 as inner Bezier handles) followed by 4 corner colors (4 * NumComponents Extended values), so the Patches stride is 24 + 4 * NumComponents. The shading dictionary carries the same /BitsPerCoordinate 16 + /BitsPerComponent 8 + /BitsPerFlag 8 as Type 4 (and unlike Type 5, /VerticesPerRow is absent). Every emitted patch carries flag = 0 (independent patch); continuation flags 1 / 2 / 3 (edge sharing) are not exposed in this convenience overload. Available since HotPDF v2.50.0.
- 含取樣 LUT tint transform 的 Separation 色彩空間(PDF 1.3+ ISO 32000-1 8.6.6.4 + 7.10.2):
THotPDF.RegisterSeparationLUT(ColorantName, AlternateCS, Samples) 包裝 RegisterSampledFunction,讓呼叫端把完整的非線性 tint -> alt-CS 曲線表示成 8 位元(M-tuple)取樣組成的平面位元組串流,不必手動建 Function Type 0 字典。色彩轉變非線性時就用 LUT 變體 —— PANTONE Hexachrome 式的 tint ramp、gamma 校正後的濃度曲線、對齊印刷特性曲線的手繪色調曲線、不帶完整 ICC profile 機制的 sRGB 對特別色轉換 ICC LUT;線性單端點情境仍交給 v2.45.0 的 RegisterSeparation。AlternateCS 接受 DeviceGray、DeviceRGB 或 DeviceCMYK;Samples 長度必須是 M 的正倍數且至少 2 * M 位元組,函式才有可內插的範圍;格點數 S 由 Length(Samples) / M 推得。依 PDF 1.7 /Order 1,預設線性內插。傳回註冊後的色彩空間名稱(Sep1、Sep2、...)供一般 SetFillColorSpace + SetFillColor([tint]) 管線使用。自 HotPDF v2.53.0 起提供
- Function Type 0(取樣)註冊(PDF 1.3+ ISO 32000-1 7.10.2):
THotPDF.RegisterSampledFunction(Domain, Range, Size, BitsPerSample, Samples, [Order]) 宣告間接的 /FunctionType 0 串流,把任意的輸入到輸出映射表示成規則的 N 維格點搭配 M 維輸出取樣,並在格點之間內插。適用時機:ICC profile 機制太重、但想要手工調校色彩 LUT 的場合 —— /TransferFunction(ExtGState /TR) 的色調曲線、/Separation / /DeviceN 超出線性 Type 2 / 算術 Type 4 路徑的取樣 tint transform、half-tone 門檻曲線,或任何接受 Function 字典的 PDF 結構。Domain 是 2N 個項目(每個輸入維度一組 [min, max]);Range 是 2M 個項目(每個輸出維度一組);Size 是 N 個格點數;BitsPerSample 依 PDF 1.7 Table 38 接受 1、2、4、8、12、16、24 或 32;Samples 是原始位元打包的取樣串流(每個取樣內 MSB 在前,取樣之間不填充,僅最後位元組補零;依規格的取樣順序規則,輸入 0 變化最快);Order 預設 1(線性),依 PDF 1.7 Table 38 可設 3(三次樣條內插,v2.54.0 起)。HotPDF 會以 ceil(GridPoints * M * BitsPerSample / 8) 驗證取樣位元組數。傳回間接的 THPDFStreamObject,凡需要 Function 字典的地方都能掛上。自 HotPDF v2.52.0 起提供;三次 /Order 3 與端到端多輸入 / 多輸出支援自 v2.54.0 起
- Tensor product patch mesh shading(PDF 1.3+ ISO 32000-1 8.7.4.5.7):THotPDF.RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax, NumComponents, Patches) 宣告 tensor-product patches 的 /ShadingType 7 stream,每個 patch 由完整 4 x 4 bicubic Bezier control points p[i][j] 網格加上每個角一個顏色定義。它在 RegisterCoonsPatchMesh(Type 6)的 12 個 boundary points 之外,再加入 4 個明確 interior control points(p[1][1]、p[1][2]、p[2][2]、p[2][1]),因此比 Coons-blended fit 能更細緻控制 patch interior。適合 SVG mesh-gradient round-trips,以及任何需要 tensor-product Bezier surface 的 artwork。每個 patch 提供 16 個 control points(32 個 X+Y Extended values,依規格 Table 88 stream order 排列:p[0][0..3]、p[1][3]、p[2][3]、p[3][3]、p[3][2..0]、p[2][0]、p[1][0],再接 4 個 interior points p[1][1]、p[1][2]、p[2][2]、p[2][1]),後接 4 個 corner colors(位於 p[0][0] / p[0][3] / p[3][3] / p[3][0] 的 4 * NumComponents Extended values),因此 Patches stride 為 32 + 4 * NumComponents。每個輸出的 patch 都帶 flag = 0(independent patch)。至此,完整 ISO 32000-1 8.7.4.5 mesh shading family(Types 4 / 5 / 6 / 7)已全部涵蓋。自 HotPDF v2.51.0 起提供
THotPDF.RegisterTensorProductPatchMesh(XMin, YMin, XMax, YMax, NumComponents, Patches) declares a /ShadingType 7 stream of tensor-product patches, each defined by a full 4 x 4 grid of bicubic Bezier control points p[i][j] plus one color per corner. Extends RegisterCoonsPatchMesh (Type 6) by adding 4 explicit interior control points (p[1][1], p[1][2], p[2][2], p[2][1]) on top of the 12 boundary points, giving finer control of the patch interior than the Coons-blended fit can express. Useful for SVG mesh-gradient round-trips and any artwork that needs a tensor-product Bezier surface. Each patch contributes 16 control points (32 X+Y Extended values, ordered per spec Table 88 stream order: p[0][0..3], p[1][3], p[2][3], p[3][3], p[3][2..0], p[2][0], p[1][0], then the 4 interior points p[1][1], p[1][2], p[2][2], p[2][1]) followed by 4 corner colors (4 * NumComponents Extended values at p[0][0] / p[0][3] / p[3][3] / p[3][0]), so the Patches stride is 32 + 4 * NumComponents. Every emitted patch carries flag = 0 (independent patch). With this release, the entire ISO 32000-1 8.7.4.5 mesh shading family (Types 4 / 5 / 6 / 7) is now covered. Available since HotPDF v2.51.0.
- 標註邊框樣式與 Popup 連結(PDF 1.7 12.5.4 / 12.5.6.14):
THPDFPage.SetAnnotationBorderStyle(Annot, Width, Style, DashPattern) 會附上帶所選 THPDFAnnotBorderStyle(absSolid / absDashed / absBeveled / absInset / absUnderline)的 /BS 字典。THPDFPage.AddPopupAnnotationFor(ParentAnnot, Rect, Open) 會輸出雙向接線的 /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
- Public-Key Security Handler (ISO 32000-1 7.6.4, ISO 32000-2 7.6.5):
/Popup 標註(parent /Popup -> popup、popup /Parent -> parent),檢視器因此畫得出對話氣泡連接線。新的 THPDFPage.LastAnnotation 屬性可餵給上述任一輔助方法,也不改變既有 Add*Annotation 程序的簽名。自 HotPDF v2.34.0 起提供
- Public-Key Security Handler(PDF 1.7 7.6.5):THotPDF.EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) + THotPDF.AddPubKeyRecipient(envelope) 會輸出 /Filter /Adobe.PubSec encrypt dictionary(/SubFilter /adbe.pkcs7.s4 用於 V=1 RC4-40;/adbe.pkcs7.s5 用於 V=2 RC4-128 / V=4 AESV2)。呼叫端提供 20-byte random seed,以及每位 recipient 一個 PKCS#7 envelopedData binary blob(由 Windows CryptoAPI、OpenSSL 或 pycryptodome 在外部建立)。HotPDF 透過 algorithm 9(seed 與每個 envelope 串接後取 SHA-1)推導 file encryption key,並對 AES-128 / RC4 streams 重用標準 per-object key derivation。自 HotPDF v2.33.0 起提供
請參閱
|