|
PDF Filter Support
Overview
PDF streams and embedded images identify their encoding through filter names. HotPDF
primarily works with the following filter families when generating documents or decoding
external content.
Common Filters
- FlateDecode: Main compression filter for generated streams and the primary zlib-based decompression path
- LZWDecode: Supported for legacy and compatibility scenarios through 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: Encoder helpers exposed in HPDFTypes.pas (
_ASCIIHexEncode, _ASCII85Encode, _RunLengthEncode) since HotPDF v2.4.0. Useful when wrapping arbitrary binary content for 7-bit channels or for explicit PDF 1.7 7.4 round-trip support
- JBIG2Decode / JPXDecode: Filter names defined by PDF 1.7 7.4.7 / 7.4.9. HotPDF's bundled JBIG2 and JPEG 2000 helpers are stubs that report unsupported (return
False) until a real OpenJPEG / JBIG2 backend is linked. Earlier builds returned a fake 100×100 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
- For generated PDF content, THotPDF.Compression remains the central user-facing setting
- When loading external data, the applicable filter depends on the source file format and the helper class being used
- 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
- Interactive form fields are emitted as Widget annotations that the viewer paints; see AcroForm Support
- Text-markup annotations (Highlight, Underline, Squiggly, StrikeOut) and intra-document jump links (
GoTo, GoToR, Launch) are exposed as new THPDFPage.Add*Annotation / AddGoToLink / AddGoToRLink / AddLaunchLink methods since HotPDF v2.6.0
- DeviceCMYK output is available through
THPDFPage.SetCMYKColor / SetCMYKFillColor / SetCMYKStrokeColor; ICC-managed colour spaces are registered with THotPDF.RegisterICCProfile and applied via SetFillColorSpace / SetStrokeColorSpace + SetFillColor / SetStrokeColor since HotPDF v2.7.0
- Set
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
- Set
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 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 since v2.18.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 honour 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 colour 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.
- OpenType-CFF (.otf) embed path wired into
StoreFont (PDF 1.6+ 9.7.4 Table 117). When the GDI-loaded font binary is an sfnt OTTO container, HotPDF subsets the embedded 'CFF ' sub-table through HPDFSubsetOTFContainer, emits the font program via /FontFile3 /Subtype /OpenType, and writes the descendant font dictionary with /Subtype /CIDFontType0 instead of /CIDFontType2. TrueType fonts continue through the existing /FontFile2 + /CIDFontType2 path with no behavior change. Available since HotPDF v2.38.0.
- CFF subroutine subsetting end-to-end (PDF 1.7 9.7.4 §6 / Adobe Tech Note #5177 §3.1): the CFF subsetter now strips unused entries from BOTH the Global Subr INDEX (located immediately after String INDEX in the CFF binary) and the Local Subr INDEX (nested under Private DICT, reached via Top DICT operator 18 + Private DICT operator 19). A single fixed-point closure follows
callsubr (op 0x0A) AND callgsubr (op 0x1D) chains transitively, so a CharString that calls a Local Subr that calls a Global Subr that calls another Local Subr is picked up in one iteration. Each unused entry is replaced by a 1-byte return stub and the INDEX is rewritten in place with the trailing slack zero-filled. This behavior is exposed through the public HPDFSubsetCFF and HPDFSubsetOTFContainer helpers; lower-level CFF scanners remain internal. Available since HotPDF v2.39.0.
- CID-keyed CFF subsetting (PDF 1.7 ISO 32000-1 9.7.4 / Adobe Tech Note #5176 §18-19): the CFF subsetter now recognises the Top DICT
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.
- Object Streams (PDF 1.5 ISO 32000-1 7.5.7): set
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.
- Soft-mask image / SMask (PDF 1.4 ISO 32000-1 8.9.5.4):
THotPDF.AddImageWithSMask(Width, Height, RGB, Alpha) emits a colour 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. Both call sites gate through RequirePDFVersion(pdf14) so strict-mode 1.3 output stays compliant. Available since HotPDF v2.42.0.
- Uncoloured Tiling Pattern painting (PDF 1.7 ISO 32000-1 8.6.6.1):
THotPDF.RegisterTilingPattern has emitted both /PaintType 1 (coloured) and /PaintType 2 (uncoloured) since v2.19.0, but the matching page-side operator sequence was only correct for the coloured variant. Six new THPDFPage methods - SetFillPatternRGB / SetStrokePatternRGB / SetFillPatternGray / SetStrokePatternGray / SetFillPatternCMYK / SetStrokePatternCMYK - now drive the uncoloured path by auto-registering the matching [/Pattern /BaseCS] tinting colour space on the page Resources/ColorSpace dict and emitting the spec-mandated tint_components /Pn scn sequence. Use the original SetFillPattern / SetStrokePattern for the coloured variant where the tile carries its own colour. Available since HotPDF v2.43.0.
- CIELab colour space (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 colour space for spot colours (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 colour-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, honouring 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 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]) 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 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-shaded triangle mesh (PDF 1.3+ ISO 32000-1 8.7.4.5.5):
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 colour 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) declares a /ShadingType 6 stream of Coons patches, each bounded by four cubic Bezier curves and carrying one colour per corner. The renderer fits the Coons surface between the four edges, giving an arbitrarily curved colour-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 colours (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.
- 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.
- Tensor product patch mesh shading (PDF 1.3+ ISO 32000-1 8.7.4.5.7):
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 colour 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 colours (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.
- 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
- Public-Key Security Handler (PDF 1.7 7.6.5):
THotPDF.EnablePubKeyEncryption(seed, KeyType, EncryptMetadata) + THotPDF.AddPubKeyRecipient(envelope) emit a /Filter /Adobe.PubSec encrypt dictionary (/SubFilter /adbe.pkcs7.s4 for V=1 RC4-40 / /adbe.pkcs7.s5 for V=2 RC4-128 / V=4 AESV2). Caller supplies the 20-byte random seed and one PKCS#7 envelopedData binary blob per recipient (built externally with Windows CryptoAPI, OpenSSL, or pycryptodome). HotPDF derives the file encryption key through algorithm 9 (SHA-1 of seed concatenated with each envelope) and reuses the standard per-object key derivation for AES-128 / RC4 streams. Available since HotPDF v2.33.0
See Also
|