pdfnative 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -14
- package/dist/index.cjs +2753 -442
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +603 -29
- package/dist/index.d.ts +603 -29
- package/dist/index.js +2727 -443
- package/dist/index.js.map +1 -1
- package/dist/worker/index.cjs +2003 -121
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.js +2003 -121
- package/dist/worker/index.js.map +1 -1
- package/fonts/noto-color-emoji-data.d.ts +28 -0
- package/fonts/noto-color-emoji-data.js +26 -0
- package/fonts/noto-ethiopic-data.d.ts +13 -0
- package/fonts/noto-ethiopic-data.js +64 -0
- package/fonts/noto-khmer-data.d.ts +13 -0
- package/fonts/noto-khmer-data.js +64 -0
- package/fonts/noto-myanmar-data.d.ts +13 -0
- package/fonts/noto-myanmar-data.js +64 -0
- package/fonts/noto-sinhala-data.d.ts +13 -0
- package/fonts/noto-sinhala-data.js +64 -0
- package/fonts/noto-telugu-data.d.ts +13 -0
- package/fonts/noto-telugu-data.js +64 -0
- package/fonts/noto-tibetan-data.d.ts +13 -0
- package/fonts/noto-tibetan-data.js +64 -0
- package/package.json +22 -5
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,93 @@ interface FontData {
|
|
|
33
33
|
readonly mark1Anchors: Record<number, Record<number, [number, number]>>;
|
|
34
34
|
readonly mark2Classes: Record<number, [number, number, number]>;
|
|
35
35
|
} | null;
|
|
36
|
+
/**
|
|
37
|
+
* Colour glyph table (COLR/CPAL), keyed by base glyph id. Present only
|
|
38
|
+
* for colour fonts such as Noto Color Emoji (opt-in via the
|
|
39
|
+
* `'emoji-color'` lang). Each entry is an ordered list of paint layers
|
|
40
|
+
* resolved against the font's CPAL palette (painter's algorithm).
|
|
41
|
+
* `undefined`/`null` for ordinary monochrome fonts. (v1.3.0)
|
|
42
|
+
*/
|
|
43
|
+
readonly colorGlyphs?: Record<number, ColorGlyph> | null;
|
|
44
|
+
}
|
|
45
|
+
/** An sRGB colour with alpha, each channel 0–255. Resolved from CPAL. */
|
|
46
|
+
type CpalColor = readonly [number, number, number, number];
|
|
47
|
+
/** A gradient colour stop: `offset` in [0,1] with a resolved colour. */
|
|
48
|
+
interface ColorStop {
|
|
49
|
+
readonly offset: number;
|
|
50
|
+
readonly color: CpalColor;
|
|
51
|
+
}
|
|
52
|
+
/** How a gradient extends beyond its [0,1] range (COLR Extend / PDF Extend). */
|
|
53
|
+
type GradientExtend = 'pad' | 'repeat' | 'reflect';
|
|
54
|
+
/** A flat colour fill (COLR PaintSolid / COLRv0 layer). */
|
|
55
|
+
interface SolidPaint {
|
|
56
|
+
readonly kind: 'solid';
|
|
57
|
+
readonly color: CpalColor;
|
|
58
|
+
}
|
|
59
|
+
/** A linear (axial) gradient fill (COLR PaintLinearGradient → PDF Shading 2). */
|
|
60
|
+
interface LinearGradientPaint {
|
|
61
|
+
readonly kind: 'linear';
|
|
62
|
+
readonly p0: readonly [number, number];
|
|
63
|
+
readonly p1: readonly [number, number];
|
|
64
|
+
readonly stops: readonly ColorStop[];
|
|
65
|
+
readonly extend: GradientExtend;
|
|
66
|
+
}
|
|
67
|
+
/** A radial gradient fill (COLR PaintRadialGradient → PDF Shading 3). */
|
|
68
|
+
interface RadialGradientPaint {
|
|
69
|
+
readonly kind: 'radial';
|
|
70
|
+
readonly c0: readonly [number, number];
|
|
71
|
+
readonly r0: number;
|
|
72
|
+
readonly c1: readonly [number, number];
|
|
73
|
+
readonly r1: number;
|
|
74
|
+
readonly stops: readonly ColorStop[];
|
|
75
|
+
readonly extend: GradientExtend;
|
|
76
|
+
}
|
|
77
|
+
/** A paint used to fill a colour-glyph layer. */
|
|
78
|
+
type ColorPaint = SolidPaint | LinearGradientPaint | RadialGradientPaint;
|
|
79
|
+
/** A single colour-glyph layer: a base outline filled by a paint. */
|
|
80
|
+
interface ColorLayer {
|
|
81
|
+
/** Glyph id of the base outline (in the font's `glyf` table). */
|
|
82
|
+
readonly glyphId: number;
|
|
83
|
+
/** The fill applied to the outline. */
|
|
84
|
+
readonly paint: ColorPaint;
|
|
85
|
+
/**
|
|
86
|
+
* Optional affine transform `[a b c d e f]` (font-unit space) applied to
|
|
87
|
+
* both the outline and the paint geometry of this layer — flattened from
|
|
88
|
+
* COLRv1 `PaintTransform`/`PaintTranslate`/`PaintScale`. Identity when
|
|
89
|
+
* absent.
|
|
90
|
+
*/
|
|
91
|
+
readonly transform?: readonly [number, number, number, number, number, number];
|
|
92
|
+
}
|
|
93
|
+
/** A resolved colour glyph: ordered layers painted back-to-front. */
|
|
94
|
+
interface ColorGlyph {
|
|
95
|
+
readonly layers: readonly ColorLayer[];
|
|
96
|
+
}
|
|
97
|
+
/** A colour-emoji Form XObject collected during content building. */
|
|
98
|
+
interface ColorEmojiForm {
|
|
99
|
+
/** Resource name (without leading `/`), e.g. `CEm0`. */
|
|
100
|
+
readonly name: string;
|
|
101
|
+
/** Form XObject content stream (font-unit space). */
|
|
102
|
+
readonly content: string;
|
|
103
|
+
/** Inline `/Resources` body (shadings + ExtGStates), may be empty. */
|
|
104
|
+
readonly resources: string;
|
|
105
|
+
/** Form BBox `[x0 y0 x1 y1]` in font units. */
|
|
106
|
+
readonly bbox: readonly [number, number, number, number];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Collects unique colour-emoji glyphs encountered while building a document's
|
|
110
|
+
* content streams, de-duplicating them into a shared set of Form XObjects.
|
|
111
|
+
* Present on the {@link EncodingContext} only when an `'emoji-color'` font
|
|
112
|
+
* (a {@link FontData} carrying `colorGlyphs`) is registered. (v1.3.0)
|
|
113
|
+
*/
|
|
114
|
+
interface ColorEmojiCollector {
|
|
115
|
+
/**
|
|
116
|
+
* Register use of a colour glyph and return its Form resource name, or
|
|
117
|
+
* `null` when `gid` is not a colour glyph (caller falls back to normal
|
|
118
|
+
* text rendering).
|
|
119
|
+
*/
|
|
120
|
+
useGlyph(fontData: FontData, gid: number): string | null;
|
|
121
|
+
/** The de-duplicated colour-emoji forms, in first-use order. */
|
|
122
|
+
readonly forms: ColorEmojiForm[];
|
|
36
123
|
}
|
|
37
124
|
/** A font entry binding FontData to a PDF font reference. */
|
|
38
125
|
interface FontEntry {
|
|
@@ -67,6 +154,12 @@ interface EncodingContext {
|
|
|
67
154
|
readonly f2: string;
|
|
68
155
|
readonly fontData?: FontData;
|
|
69
156
|
readonly getUsedGids?: () => Map<string, Set<number>>;
|
|
157
|
+
/**
|
|
158
|
+
* Colour-emoji collector — present only when an `'emoji-color'` font
|
|
159
|
+
* (carrying `colorGlyphs`) is registered. Used by the text emitter to
|
|
160
|
+
* draw colour-emoji Form XObjects inline. (v1.3.0)
|
|
161
|
+
*/
|
|
162
|
+
readonly colorEmoji?: ColorEmojiCollector;
|
|
70
163
|
}
|
|
71
164
|
/** A single row in the PDF table. */
|
|
72
165
|
interface PdfRow {
|
|
@@ -301,6 +394,51 @@ interface PdfLayoutOptions {
|
|
|
301
394
|
* Default: undefined (no attachments).
|
|
302
395
|
*/
|
|
303
396
|
readonly attachments?: readonly PdfAttachment[];
|
|
397
|
+
/**
|
|
398
|
+
* Maximum number of document blocks `buildDocumentPDF` / `buildDocumentPDFBytes`
|
|
399
|
+
* (and the streaming variants) will accept before throwing. This is a
|
|
400
|
+
* safety rail against accidental unbounded input, not a hard engine limit —
|
|
401
|
+
* raise it for very large generated reports (e.g. multi-thousand-page
|
|
402
|
+
* medical or financial documents).
|
|
403
|
+
*
|
|
404
|
+
* Default: `DEFAULT_MAX_BLOCKS` (100 000), matching the table builder's
|
|
405
|
+
* 100 000-row ceiling. Has no effect on the table builder (`buildPDF`).
|
|
406
|
+
*
|
|
407
|
+
* @since 1.3.0
|
|
408
|
+
*/
|
|
409
|
+
readonly maxBlocks?: number;
|
|
410
|
+
/**
|
|
411
|
+
* Apply Unicode normalization to all rendered text before shaping and
|
|
412
|
+
* encoding. Uses the native `String.prototype.normalize` (zero dependency).
|
|
413
|
+
*
|
|
414
|
+
* Useful when input text may contain decomposed combining sequences (e.g.
|
|
415
|
+
* Vietnamese, some Indic input, or text copied from macOS which favours
|
|
416
|
+
* NFD) so that base + combining marks compose to the precomposed code
|
|
417
|
+
* points a font's cmap is most likely to cover, maximising glyph coverage.
|
|
418
|
+
*
|
|
419
|
+
* - `'NFC'` (recommended): canonical composition
|
|
420
|
+
* - `'NFD'`: canonical decomposition
|
|
421
|
+
* - `'NFKC'` / `'NFKD'`: compatibility (de)composition
|
|
422
|
+
* - `false` / omitted: no normalization (default — output is byte-identical)
|
|
423
|
+
*
|
|
424
|
+
* Default: `false` (backward compatible, byte-stable).
|
|
425
|
+
*
|
|
426
|
+
* @since 1.3.0
|
|
427
|
+
*/
|
|
428
|
+
readonly normalize?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD' | false;
|
|
429
|
+
/**
|
|
430
|
+
* Override the PDF creation date embedded in `/Info /CreationDate` and
|
|
431
|
+
* XMP metadata. Accepts any `Date` object.
|
|
432
|
+
*
|
|
433
|
+
* When omitted, defaults to `new Date()` at build time. Pinning this
|
|
434
|
+
* value makes output byte-identical across repeated calls — useful for
|
|
435
|
+
* deterministic tests and content-addressable storage.
|
|
436
|
+
*
|
|
437
|
+
* Default: `undefined` (current wall-clock time).
|
|
438
|
+
*
|
|
439
|
+
* @since 1.3.0
|
|
440
|
+
*/
|
|
441
|
+
readonly creationDate?: Date;
|
|
304
442
|
}
|
|
305
443
|
/**
|
|
306
444
|
* Relationship of an embedded file to the PDF document (ISO 19005-3 §6.8).
|
|
@@ -1997,6 +2135,36 @@ declare function buildPDFStreamPageByPage(params: PdfParams, layoutOptions?: Par
|
|
|
1997
2135
|
* ```
|
|
1998
2136
|
*/
|
|
1999
2137
|
declare function buildPDFStream(params: PdfParams, layoutOptions?: Partial<PdfLayoutOptions>, streamOptions?: StreamOptions): AsyncGenerator<Uint8Array>;
|
|
2138
|
+
/**
|
|
2139
|
+
* Build a free-form PDF document with **true constant-memory streaming**.
|
|
2140
|
+
*
|
|
2141
|
+
* Unlike {@link buildDocumentPDFStream} (which assembles the full binary
|
|
2142
|
+
* then chunks it), this variant assembles the PDF into its raw parts and
|
|
2143
|
+
* yields them progressively, freeing each part as it is emitted. The
|
|
2144
|
+
* fully-joined PDF binary never exists in memory at once. Byte output is
|
|
2145
|
+
* identical to {@link buildDocumentPDFBytes}.
|
|
2146
|
+
*
|
|
2147
|
+
* Constraints (same as `buildDocumentPDFStream`):
|
|
2148
|
+
* - TOC blocks are not allowed (require multi-pass pagination)
|
|
2149
|
+
* - `{pages}` placeholder is not allowed in header/footer templates
|
|
2150
|
+
*
|
|
2151
|
+
* @param params - Document content (title, blocks, footer, fonts)
|
|
2152
|
+
* @param layoutOptions - Optional layout customization
|
|
2153
|
+
* @param streamOptions - Chunk size configuration
|
|
2154
|
+
* @yields Uint8Array chunks of the PDF
|
|
2155
|
+
*/
|
|
2156
|
+
declare function buildDocumentPDFStreamTrue(params: DocumentParams, layoutOptions?: Partial<PdfLayoutOptions>, streamOptions?: StreamOptions): AsyncGenerator<Uint8Array>;
|
|
2157
|
+
/**
|
|
2158
|
+
* Build a table-centric PDF with **true constant-memory streaming**.
|
|
2159
|
+
* See {@link buildDocumentPDFStreamTrue} for the full contract. Byte
|
|
2160
|
+
* output is identical to {@link buildPDFBytes}.
|
|
2161
|
+
*
|
|
2162
|
+
* @param params - PDF content (title, rows, headers, etc.)
|
|
2163
|
+
* @param layoutOptions - Optional layout customization
|
|
2164
|
+
* @param streamOptions - Chunk size configuration
|
|
2165
|
+
* @yields Uint8Array chunks of the PDF
|
|
2166
|
+
*/
|
|
2167
|
+
declare function buildPDFStreamTrue(params: PdfParams, layoutOptions?: Partial<PdfLayoutOptions>, streamOptions?: StreamOptions): AsyncGenerator<Uint8Array>;
|
|
2000
2168
|
/**
|
|
2001
2169
|
* Concatenate an array of Uint8Array chunks into a single Uint8Array.
|
|
2002
2170
|
*
|
|
@@ -2079,6 +2247,12 @@ declare const DEFAULT_MARGINS: {
|
|
|
2079
2247
|
l: number;
|
|
2080
2248
|
};
|
|
2081
2249
|
declare const DEFAULT_CW: number;
|
|
2250
|
+
/**
|
|
2251
|
+
* Default ceiling for `buildDocumentPDF` block count, overridable per call via
|
|
2252
|
+
* `PdfLayoutOptions.maxBlocks`. Matches the table builder's 100 000-row cap.
|
|
2253
|
+
* @since 1.3.0
|
|
2254
|
+
*/
|
|
2255
|
+
declare const DEFAULT_MAX_BLOCKS = 100000;
|
|
2082
2256
|
declare const ROW_H = 12;
|
|
2083
2257
|
declare const TH_H = 15;
|
|
2084
2258
|
declare const INFO_LN = 13;
|
|
@@ -2264,7 +2438,7 @@ declare function helveticaBoldWidth(str: string, sz: number): number;
|
|
|
2264
2438
|
* Latin mode is used as before — strict PDF/A conformance requires the caller
|
|
2265
2439
|
* to register a Latin font (e.g. Noto Sans VF).
|
|
2266
2440
|
*/
|
|
2267
|
-
declare function createEncodingContext(fontEntries: FontEntry[], pdfA?: boolean): EncodingContext;
|
|
2441
|
+
declare function createEncodingContext(fontEntries: FontEntry[], pdfA?: boolean, normalize?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD' | false): EncodingContext;
|
|
2268
2442
|
|
|
2269
2443
|
/**
|
|
2270
2444
|
* pdfnative — Font Loader
|
|
@@ -2360,6 +2534,18 @@ declare function isArmenianCodepoint(cp: number): boolean;
|
|
|
2360
2534
|
declare function isBengaliCodepoint(cp: number): boolean;
|
|
2361
2535
|
/** Check if a codepoint falls in the Tamil Unicode block. */
|
|
2362
2536
|
declare function isTamilCodepoint(cp: number): boolean;
|
|
2537
|
+
/** Check if a codepoint falls in the Telugu Unicode block. */
|
|
2538
|
+
declare function isTeluguCodepoint(cp: number): boolean;
|
|
2539
|
+
/** Check if a codepoint falls in any Ethiopic Unicode block. */
|
|
2540
|
+
declare function isEthiopicCodepoint(cp: number): boolean;
|
|
2541
|
+
/** Check if a codepoint falls in the Sinhala Unicode block. */
|
|
2542
|
+
declare function isSinhalaCodepoint(cp: number): boolean;
|
|
2543
|
+
/** Check if a codepoint falls in the Tibetan Unicode block. */
|
|
2544
|
+
declare function isTibetanCodepoint(cp: number): boolean;
|
|
2545
|
+
/** Check if a codepoint falls in any Khmer Unicode block. */
|
|
2546
|
+
declare function isKhmerCodepoint(cp: number): boolean;
|
|
2547
|
+
/** Check if a codepoint falls in any Myanmar Unicode block. */
|
|
2548
|
+
declare function isMyanmarCodepoint(cp: number): boolean;
|
|
2363
2549
|
/** Check if a codepoint falls in any Devanagari Unicode block. */
|
|
2364
2550
|
declare function isDevanagariCodepoint(cp: number): boolean;
|
|
2365
2551
|
/** Check if text contains Arabic characters requiring shaping. */
|
|
@@ -2372,6 +2558,18 @@ declare function containsThai(str: string): boolean;
|
|
|
2372
2558
|
declare function containsBengali(str: string): boolean;
|
|
2373
2559
|
/** Check whether a string contains any Tamil characters. */
|
|
2374
2560
|
declare function containsTamil(str: string): boolean;
|
|
2561
|
+
/** Check whether a string contains any Telugu characters. */
|
|
2562
|
+
declare function containsTelugu(str: string): boolean;
|
|
2563
|
+
/** Check whether a string contains any Ethiopic characters. */
|
|
2564
|
+
declare function containsEthiopic(str: string): boolean;
|
|
2565
|
+
/** Check whether a string contains any Sinhala characters. */
|
|
2566
|
+
declare function containsSinhala(str: string): boolean;
|
|
2567
|
+
/** Check whether a string contains any Tibetan characters. */
|
|
2568
|
+
declare function containsTibetan(str: string): boolean;
|
|
2569
|
+
/** Check whether a string contains any Khmer characters. */
|
|
2570
|
+
declare function containsKhmer(str: string): boolean;
|
|
2571
|
+
/** Check whether a string contains any Myanmar characters. */
|
|
2572
|
+
declare function containsMyanmar(str: string): boolean;
|
|
2375
2573
|
/** Check whether a string contains any Devanagari characters. */
|
|
2376
2574
|
declare function containsDevanagari(str: string): boolean;
|
|
2377
2575
|
|
|
@@ -2437,6 +2635,191 @@ declare function shapeBengaliText(str: string, fontData: FontData): ShapedGlyph[
|
|
|
2437
2635
|
*/
|
|
2438
2636
|
declare function shapeTamilText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2439
2637
|
|
|
2638
|
+
/**
|
|
2639
|
+
* pdfnative — Telugu Mini-Shaper
|
|
2640
|
+
* ================================
|
|
2641
|
+
* Pure JS OpenType GSUB + GPOS shaping for Telugu script.
|
|
2642
|
+
* Zero external dependency.
|
|
2643
|
+
*
|
|
2644
|
+
* Handles:
|
|
2645
|
+
* - Syllable cluster building (base + virama-mediated conjuncts / subjoined
|
|
2646
|
+
* consonants — Telugu stacks the dependent consonant below the base)
|
|
2647
|
+
* - GSUB LigatureSubst: conjunct / subjoined-consonant formation
|
|
2648
|
+
* (C + Virama + C → ligature glyph)
|
|
2649
|
+
* - GSUB SingleSubst: contextual glyph substitution
|
|
2650
|
+
* - GPOS MarkToBase: combining-mark positioning (above/below vowel signs,
|
|
2651
|
+
* anusvara, candrabindu, length marks)
|
|
2652
|
+
*
|
|
2653
|
+
* Telugu is structurally close to Devanagari but:
|
|
2654
|
+
* - has **no reph** (Ra forms a subjoined glyph, not a top mark),
|
|
2655
|
+
* - has **no pre-base matra reordering** — every Telugu vowel sign attaches
|
|
2656
|
+
* to the right of, or above/below, the base (nothing renders to its left),
|
|
2657
|
+
* - has **no nukta**.
|
|
2658
|
+
*
|
|
2659
|
+
* References:
|
|
2660
|
+
* - Unicode Standard §12.8 Telugu
|
|
2661
|
+
* - OpenType spec: Script-specific shaping for Telugu (tel2 / Indic2)
|
|
2662
|
+
* - ISO 15924 script code: Telu
|
|
2663
|
+
*/
|
|
2664
|
+
|
|
2665
|
+
/**
|
|
2666
|
+
* Shape a string of Telugu text into an array of positioned glyphs.
|
|
2667
|
+
*
|
|
2668
|
+
* @param str - Raw Telugu string
|
|
2669
|
+
* @param fontData - Font data with cmap, ligatures, markAnchors, metrics, widths
|
|
2670
|
+
* @returns Array of positioned glyphs
|
|
2671
|
+
*/
|
|
2672
|
+
declare function shapeTeluguText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2673
|
+
|
|
2674
|
+
/**
|
|
2675
|
+
* pdfnative — Sinhala Mini-Shaper
|
|
2676
|
+
* ================================
|
|
2677
|
+
* Pure JS OpenType GSUB + GPOS shaping for the Sinhala script (Sri Lanka).
|
|
2678
|
+
* Zero external dependency.
|
|
2679
|
+
*
|
|
2680
|
+
* Handles:
|
|
2681
|
+
* - Syllable cluster building (base + al-lakuna-mediated conjuncts)
|
|
2682
|
+
* - GSUB LigatureSubst: conjunct / touching-form ligatures
|
|
2683
|
+
* (C + Al-lakuna + ZWJ + Ya/Ra → yansaya / rakaaransaya, C+C conjuncts)
|
|
2684
|
+
* - Pre-base (left-side) vowel reordering — the kombuva family
|
|
2685
|
+
* (U+0DD9 / U+0DDB and the left half of the two-part vowels U+0DDA,
|
|
2686
|
+
* U+0DDC, U+0DDD, U+0DDE) renders to the LEFT of its base consonant, so
|
|
2687
|
+
* the shaper emits that glyph BEFORE the base in visual order.
|
|
2688
|
+
* - Two-part dependent vowels are decomposed into their left + right halves.
|
|
2689
|
+
* - GPOS MarkToBase: above / below pilla positioning.
|
|
2690
|
+
*
|
|
2691
|
+
* Known limitations (documented):
|
|
2692
|
+
* - Complex multi-consonant stacks beyond the font's pre-baked ligature
|
|
2693
|
+
* table fall back to sequential base + al-lakuna rendering.
|
|
2694
|
+
* - GSUB MultipleSubst (LookupType 2) is not consumed; two-part vowels are
|
|
2695
|
+
* instead decomposed by this shaper's own table.
|
|
2696
|
+
*
|
|
2697
|
+
* References:
|
|
2698
|
+
* - Unicode Standard §13.2 Sinhala
|
|
2699
|
+
* - OpenType spec: Script-specific shaping for Sinhala (sinh)
|
|
2700
|
+
* - ISO 15924 script code: Sinh
|
|
2701
|
+
*/
|
|
2702
|
+
|
|
2703
|
+
/**
|
|
2704
|
+
* Shape a string of Sinhala text into an array of positioned glyphs.
|
|
2705
|
+
*
|
|
2706
|
+
* @param str - Raw Sinhala string
|
|
2707
|
+
* @param fontData - Font data with cmap, ligatures, markAnchors, metrics, widths
|
|
2708
|
+
* @returns Array of positioned glyphs
|
|
2709
|
+
*/
|
|
2710
|
+
declare function shapeSinhalaText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2711
|
+
|
|
2712
|
+
/**
|
|
2713
|
+
* pdfnative — Tibetan Mini-Shaper
|
|
2714
|
+
* ================================
|
|
2715
|
+
* Pure JS OpenType GSUB + GPOS shaping for the Tibetan script.
|
|
2716
|
+
* Zero external dependency.
|
|
2717
|
+
*
|
|
2718
|
+
* Tibetan builds vertical stacks: a head consonant with zero or more
|
|
2719
|
+
* *subjoined* consonants (U+0F90–U+0FBC) stacked beneath it, plus vowel
|
|
2720
|
+
* signs above / below and spacing marks to the right.
|
|
2721
|
+
*
|
|
2722
|
+
* Handles:
|
|
2723
|
+
* - Stack building (head consonant + subjoined consonants + vowels + marks)
|
|
2724
|
+
* - GSUB LigatureSubst: pre-baked stacked-consonant ligatures when the font
|
|
2725
|
+
* provides them (head + subjoined → single stack glyph)
|
|
2726
|
+
* - GPOS MarkToBase: subjoined consonants and above/below vowel signs are
|
|
2727
|
+
* anchored on the base when no ligature exists
|
|
2728
|
+
*
|
|
2729
|
+
* Known limitations (documented):
|
|
2730
|
+
* - Deep stacks beyond the font's ligature coverage fall back to GPOS
|
|
2731
|
+
* below-base anchoring of each subjoined consonant, which approximates but
|
|
2732
|
+
* may not perfectly match a native stacking engine.
|
|
2733
|
+
* - GSUB contextual substitution (LookupType 5/6) is not consumed.
|
|
2734
|
+
*
|
|
2735
|
+
* References:
|
|
2736
|
+
* - Unicode Standard §13.4 Tibetan
|
|
2737
|
+
* - OpenType spec: Script-specific shaping for Tibetan (tibt)
|
|
2738
|
+
* - ISO 15924 script code: Tibt
|
|
2739
|
+
*/
|
|
2740
|
+
|
|
2741
|
+
/**
|
|
2742
|
+
* Shape a string of Tibetan text into an array of positioned glyphs.
|
|
2743
|
+
*
|
|
2744
|
+
* @param str - Raw Tibetan string
|
|
2745
|
+
* @param fontData - Font data with cmap, ligatures, markAnchors, metrics, widths
|
|
2746
|
+
* @returns Array of positioned glyphs
|
|
2747
|
+
*/
|
|
2748
|
+
declare function shapeTibetanText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2749
|
+
|
|
2750
|
+
/**
|
|
2751
|
+
* pdfnative — Khmer Mini-Shaper
|
|
2752
|
+
* ==============================
|
|
2753
|
+
* Pure JS OpenType GSUB + GPOS shaping for the Khmer script (Cambodia).
|
|
2754
|
+
* Zero external dependency.
|
|
2755
|
+
*
|
|
2756
|
+
* Khmer is a USE-class (Universal Shaping Engine) script. This is a pragmatic
|
|
2757
|
+
* USE-lite implementation that covers the common cases:
|
|
2758
|
+
* - Coeng (U+17D2) + consonant → subscript consonant (stacked below / behind)
|
|
2759
|
+
* - Pre-base (left-side) vowel reordering — U+17C1 (e), U+17C2 (ae),
|
|
2760
|
+
* U+17C3 (ai) render to the LEFT of their base, so they are emitted first.
|
|
2761
|
+
* - Two-part vowels (U+17BE, U+17BF, U+17C0, U+17C4, U+17C5) are decomposed
|
|
2762
|
+
* into their pre-base + post-base halves.
|
|
2763
|
+
* - GSUB LigatureSubst: coeng-form subscript ligatures when the font provides
|
|
2764
|
+
* them; GPOS MarkToBase for above / below vowel signs and diacritics.
|
|
2765
|
+
*
|
|
2766
|
+
* Known limitations (documented):
|
|
2767
|
+
* - This is not a full USE implementation. Robat (U+17CC), complex
|
|
2768
|
+
* multi-coeng stacks beyond the font's ligature coverage, and contextual
|
|
2769
|
+
* GSUB (LookupType 5/6) are approximated, not fully reordered.
|
|
2770
|
+
*
|
|
2771
|
+
* References:
|
|
2772
|
+
* - Unicode Standard §16.4 Khmer
|
|
2773
|
+
* - OpenType spec: Universal Shaping Engine; Khmer (khmr)
|
|
2774
|
+
* - ISO 15924 script code: Khmr
|
|
2775
|
+
*/
|
|
2776
|
+
|
|
2777
|
+
/**
|
|
2778
|
+
* Shape a string of Khmer text into an array of positioned glyphs.
|
|
2779
|
+
*
|
|
2780
|
+
* @param str - Raw Khmer string
|
|
2781
|
+
* @param fontData - Font data with cmap, ligatures, markAnchors, metrics, widths
|
|
2782
|
+
* @returns Array of positioned glyphs
|
|
2783
|
+
*/
|
|
2784
|
+
declare function shapeKhmerText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2785
|
+
|
|
2786
|
+
/**
|
|
2787
|
+
* pdfnative — Myanmar Mini-Shaper
|
|
2788
|
+
* ================================
|
|
2789
|
+
* Pure JS OpenType GSUB + GPOS shaping for the Myanmar (Burmese) script.
|
|
2790
|
+
* Zero external dependency.
|
|
2791
|
+
*
|
|
2792
|
+
* Myanmar is a USE-class (Universal Shaping Engine) script. This is a pragmatic
|
|
2793
|
+
* USE-lite implementation covering the common cases:
|
|
2794
|
+
* - Medial consonants: medial ya (U+103B), ra (U+103C), wa (U+103D),
|
|
2795
|
+
* ha (U+103E). Medial **ra** renders to the LEFT of its base (pre-base)
|
|
2796
|
+
* and is therefore emitted first.
|
|
2797
|
+
* - Virama / stacker (U+1039): C + U+1039 + C → stacked subscript consonant.
|
|
2798
|
+
* - Asat (U+103A, visible killer) is preserved.
|
|
2799
|
+
* - GSUB LigatureSubst for medial / stacked forms when the font provides
|
|
2800
|
+
* them; GPOS MarkToBase for above / below vowel signs and tone marks.
|
|
2801
|
+
*
|
|
2802
|
+
* Known limitations (documented):
|
|
2803
|
+
* - This is not a full USE implementation. Kinzi (U+1004 U+103A U+1039),
|
|
2804
|
+
* deep stacks beyond the font's ligature coverage, and contextual GSUB
|
|
2805
|
+
* (LookupType 5/6) are approximated, not fully reordered. Kinzi is rendered
|
|
2806
|
+
* via its stacking sequence rather than a dedicated reordering pass.
|
|
2807
|
+
*
|
|
2808
|
+
* References:
|
|
2809
|
+
* - Unicode Standard §16.3 Myanmar
|
|
2810
|
+
* - OpenType spec: Universal Shaping Engine; Myanmar (mymr)
|
|
2811
|
+
* - ISO 15924 script code: Mymr
|
|
2812
|
+
*/
|
|
2813
|
+
|
|
2814
|
+
/**
|
|
2815
|
+
* Shape a string of Myanmar text into an array of positioned glyphs.
|
|
2816
|
+
*
|
|
2817
|
+
* @param str - Raw Myanmar string
|
|
2818
|
+
* @param fontData - Font data with cmap, ligatures, markAnchors, metrics, widths
|
|
2819
|
+
* @returns Array of positioned glyphs
|
|
2820
|
+
*/
|
|
2821
|
+
declare function shapeMyanmarText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2822
|
+
|
|
2440
2823
|
/**
|
|
2441
2824
|
* pdfnative — Devanagari Mini-Shaper
|
|
2442
2825
|
* ====================================
|
|
@@ -2524,29 +2907,30 @@ interface BidiRun {
|
|
|
2524
2907
|
readonly start: number;
|
|
2525
2908
|
}
|
|
2526
2909
|
/**
|
|
2527
|
-
* UAX #9 explicit embedding
|
|
2910
|
+
* UAX #9 explicit embedding normalization (v1.2.0, refined v1.3.0).
|
|
2528
2911
|
*
|
|
2529
|
-
* Maps the legacy explicit
|
|
2530
|
-
*
|
|
2531
|
-
*
|
|
2912
|
+
* Maps the legacy explicit *embedding* characters into their sealed-isolate
|
|
2913
|
+
* equivalents so the rest of the pipeline can process them via the existing
|
|
2914
|
+
* isolate machinery:
|
|
2532
2915
|
*
|
|
2533
2916
|
* - LRE (U+202A) → LRI (U+2066)
|
|
2534
2917
|
* - RLE (U+202B) → RLI (U+2067)
|
|
2535
|
-
* -
|
|
2536
|
-
*
|
|
2537
|
-
*
|
|
2538
|
-
*
|
|
2539
|
-
*
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2542
|
-
*
|
|
2543
|
-
*
|
|
2544
|
-
*
|
|
2545
|
-
*
|
|
2546
|
-
*
|
|
2918
|
+
* - PDF (U+202C) → PDI (U+2069), but only when popping a matched LRE/RLE
|
|
2919
|
+
* from the stack (otherwise preserved or dropped, see below)
|
|
2920
|
+
*
|
|
2921
|
+
* The explicit *override* characters LRO (U+202D) / RLO (U+202E) and the
|
|
2922
|
+
* PDF (U+202C) that closes them are **preserved verbatim** — they carry
|
|
2923
|
+
* character-level type-override semantics (UAX #9 X4/X5) that the isolate
|
|
2924
|
+
* machinery cannot express. They are resolved separately by
|
|
2925
|
+
* {@link resolveBidiRuns} via the override pre-pass, which forces every
|
|
2926
|
+
* inner code point to L (LRO) or R (RLO). A PDF that would pop an override
|
|
2927
|
+
* frame is therefore left in place for that pre-pass to consume.
|
|
2928
|
+
*
|
|
2929
|
+
* This split keeps the ≥ 95 % common embedding cases on the fast isolate
|
|
2930
|
+
* path while giving LRO/RLO faithful character-level override behaviour.
|
|
2547
2931
|
*
|
|
2548
2932
|
* @param text - Raw input text in logical order
|
|
2549
|
-
* @returns
|
|
2933
|
+
* @returns Text with embeddings mapped to isolates; overrides preserved.
|
|
2550
2934
|
*/
|
|
2551
2935
|
declare function normalizeBidiEmbeddings(text: string): string;
|
|
2552
2936
|
/**
|
|
@@ -2564,10 +2948,13 @@ declare function normalizeBidiEmbeddings(text: string): string;
|
|
|
2564
2948
|
*/
|
|
2565
2949
|
declare function resolveBidiRuns(text: string): BidiRun[];
|
|
2566
2950
|
/**
|
|
2567
|
-
* Check if text contains any RTL characters (Arabic or Hebrew)
|
|
2951
|
+
* Check if text contains any RTL characters (Arabic or Hebrew) or an explicit
|
|
2952
|
+
* directional override (LRO U+202D / RLO U+202E). The override markers are
|
|
2953
|
+
* included so a direct caller that has not yet stripped controls still routes
|
|
2954
|
+
* through the bidi resolver, where the X4/X5 override pass applies.
|
|
2568
2955
|
*
|
|
2569
2956
|
* @param text - Input text string
|
|
2570
|
-
* @returns True if text contains R or
|
|
2957
|
+
* @returns True if text contains R/AL bidi types or an LRO/RLO override
|
|
2571
2958
|
*/
|
|
2572
2959
|
declare function containsRTL(text: string): boolean;
|
|
2573
2960
|
/**
|
|
@@ -2602,19 +2989,20 @@ declare function stripBidiControls(text: string): string;
|
|
|
2602
2989
|
* Based on the Universal Shaping Engine specification:
|
|
2603
2990
|
* https://learn.microsoft.com/en-us/typography/script-development/use
|
|
2604
2991
|
*
|
|
2605
|
-
* Scope (v1.
|
|
2992
|
+
* Scope (v1.3.0):
|
|
2606
2993
|
* - Public API for cluster classification: callers can run their own
|
|
2607
2994
|
* reordering / GSUB pipelines on top of the cluster categories.
|
|
2608
2995
|
* - 11 cluster categories sufficient for the four scripts pdfnative
|
|
2609
2996
|
* ships shaping for (Devanagari, Bengali, Tamil) plus a generic
|
|
2610
2997
|
* fallback that classifies any USE-eligible code point.
|
|
2611
|
-
*
|
|
2612
|
-
*
|
|
2613
|
-
* -
|
|
2614
|
-
*
|
|
2615
|
-
*
|
|
2616
|
-
*
|
|
2617
|
-
*
|
|
2998
|
+
* - Marathi eyelash-ra (Ra + virama + ZWJ) is recognised as a distinct
|
|
2999
|
+
* reph variant (`UseCluster.eyelash`).
|
|
3000
|
+
* - The bundled Devanagari/Bengali/Tamil shapers consume
|
|
3001
|
+
* `classifyUseCategory` as the single source of truth for joiner
|
|
3002
|
+
* (ZWJ/ZWNJ) and half-form/eyelash decisions; their hand-tuned
|
|
3003
|
+
* happy-path reordering (pinned by the vitest suite) is preserved.
|
|
3004
|
+
*
|
|
3005
|
+
* Not in scope (deferred):
|
|
2618
3006
|
* - State-table classification for Khmer/Myanmar/Tibetan/Sinhala/
|
|
2619
3007
|
* other USE-required scripts not currently bundled.
|
|
2620
3008
|
*/
|
|
@@ -2656,6 +3044,12 @@ interface UseCluster {
|
|
|
2656
3044
|
readonly post: UseClassifiedCp[];
|
|
2657
3045
|
/** Halant + consonant chains attached after the base (conjunct tail). */
|
|
2658
3046
|
readonly tail: UseClassifiedCp[];
|
|
3047
|
+
/**
|
|
3048
|
+
* True when the cluster head is a Marathi eyelash-ra — `Ra + virama + ZWJ`
|
|
3049
|
+
* — which renders as the eyelash (rakar) form rather than a reph. The
|
|
3050
|
+
* leading `Ra` is still recorded in {@link prebase} with category `'R'`.
|
|
3051
|
+
*/
|
|
3052
|
+
readonly eyelash?: boolean;
|
|
2659
3053
|
}
|
|
2660
3054
|
/**
|
|
2661
3055
|
* Classify a single Unicode code point into a USE-lite category.
|
|
@@ -2729,6 +3123,148 @@ declare function classifyClusters(codePoints: readonly number[]): UseCluster[];
|
|
|
2729
3123
|
*/
|
|
2730
3124
|
declare function shapeArabicText(str: string, fontData: FontData): ShapedGlyph[];
|
|
2731
3125
|
|
|
3126
|
+
/**
|
|
3127
|
+
* pdfnative — TrueType `glyf` Outline Extractor
|
|
3128
|
+
* ==============================================
|
|
3129
|
+
* Pure-JS reader that turns a TrueType glyph outline into ordered contours
|
|
3130
|
+
* of quadratic on/off-curve points. Zero external dependency.
|
|
3131
|
+
*
|
|
3132
|
+
* Used by the colour-glyph renderer (COLR/CPAL) to fill a base glyph's
|
|
3133
|
+
* outline as a native PDF path. Handles both simple and composite glyphs
|
|
3134
|
+
* (the latter via recursive 2×2 + translate component transforms).
|
|
3135
|
+
*
|
|
3136
|
+
* References:
|
|
3137
|
+
* - ISO/IEC 14496-22 (OpenType) §5.3.3 `glyf`
|
|
3138
|
+
* - Apple TrueType Reference Manual — Glyph data format
|
|
3139
|
+
*/
|
|
3140
|
+
/** A single outline point in font units. */
|
|
3141
|
+
interface OutlinePoint {
|
|
3142
|
+
readonly x: number;
|
|
3143
|
+
readonly y: number;
|
|
3144
|
+
/** True for on-curve points; false for quadratic control (off-curve). */
|
|
3145
|
+
readonly onCurve: boolean;
|
|
3146
|
+
}
|
|
3147
|
+
/** A closed contour: an ordered ring of on/off-curve points. */
|
|
3148
|
+
type Contour = OutlinePoint[];
|
|
3149
|
+
/** A parsed TrueType font exposing just enough to read glyph outlines. */
|
|
3150
|
+
interface GlyfFont {
|
|
3151
|
+
readonly view: DataView;
|
|
3152
|
+
readonly glyfOffset: number;
|
|
3153
|
+
readonly locaOffsets: number[];
|
|
3154
|
+
readonly unitsPerEm: number;
|
|
3155
|
+
}
|
|
3156
|
+
/**
|
|
3157
|
+
* Parse the table directory, `head`, `maxp` and `loca` so that subsequent
|
|
3158
|
+
* {@link extractGlyphContours} calls are O(1) lookups.
|
|
3159
|
+
*
|
|
3160
|
+
* @param bytes - Raw TrueType/OpenType (glyf-flavoured) font bytes.
|
|
3161
|
+
* @returns A {@link GlyfFont}, or `null` if the font has no `glyf` outlines
|
|
3162
|
+
* (e.g. a CFF font) or is structurally invalid.
|
|
3163
|
+
*/
|
|
3164
|
+
declare function parseGlyfFont(bytes: Uint8Array): GlyfFont | null;
|
|
3165
|
+
/**
|
|
3166
|
+
* Extract the contours of a single glyph in font units. Composite glyphs are
|
|
3167
|
+
* flattened by recursively transforming their components.
|
|
3168
|
+
*
|
|
3169
|
+
* @param font - Parsed {@link GlyfFont}.
|
|
3170
|
+
* @param gid - Glyph id.
|
|
3171
|
+
* @param depth - Internal recursion guard for composite glyphs.
|
|
3172
|
+
* @returns Array of contours (empty for whitespace / empty glyphs).
|
|
3173
|
+
*/
|
|
3174
|
+
declare function extractGlyphContours(font: GlyfFont, gid: number, depth?: number): Contour[];
|
|
3175
|
+
|
|
3176
|
+
/**
|
|
3177
|
+
* pdfnative — COLR / CPAL Colour-Font Parser
|
|
3178
|
+
* ===========================================
|
|
3179
|
+
* Pure-JS reader for the OpenType COLR (colour layers) and CPAL (colour
|
|
3180
|
+
* palette) tables. Resolves each base colour glyph into a flat list of
|
|
3181
|
+
* {@link ColorLayer}s (base outline + paint), painted back-to-front.
|
|
3182
|
+
*
|
|
3183
|
+
* Supported:
|
|
3184
|
+
* - COLR v0 — layered solid fills.
|
|
3185
|
+
* - COLR v1 — PaintColrLayers, PaintGlyph, PaintColrGlyph, PaintSolid,
|
|
3186
|
+
* PaintLinearGradient, PaintRadialGradient, PaintTransform,
|
|
3187
|
+
* PaintTranslate, PaintScale (+ around-center).
|
|
3188
|
+
*
|
|
3189
|
+
* Unsupported paints (sweep gradients, compositing, variable paints) cause
|
|
3190
|
+
* the affected glyph to be skipped so the caller can fall back to the
|
|
3191
|
+
* monochrome emoji font. This keeps output correct (never garbled) while
|
|
3192
|
+
* covering the overwhelming majority of Noto Color Emoji glyphs.
|
|
3193
|
+
*
|
|
3194
|
+
* Zero external dependency.
|
|
3195
|
+
*
|
|
3196
|
+
* References:
|
|
3197
|
+
* - ISO/IEC 14496-22 (OpenType) §5.7.11 COLR, §5.7.12 CPAL
|
|
3198
|
+
* - https://learn.microsoft.com/typography/opentype/spec/colr
|
|
3199
|
+
*/
|
|
3200
|
+
|
|
3201
|
+
/**
|
|
3202
|
+
* Parse the CPAL table's first palette into an array of {@link CpalColor}s
|
|
3203
|
+
* (sRGB + alpha, each channel 0–255), indexed by palette entry.
|
|
3204
|
+
*/
|
|
3205
|
+
declare function parseCpal(bytes: Uint8Array): CpalColor[] | null;
|
|
3206
|
+
/**
|
|
3207
|
+
* Parse the COLR + CPAL tables of a font into a colour-glyph map keyed by
|
|
3208
|
+
* base glyph id. Returns `null` when the font has no COLR table.
|
|
3209
|
+
*
|
|
3210
|
+
* @param bytes - Raw OpenType font bytes.
|
|
3211
|
+
*/
|
|
3212
|
+
declare function parseColrCpal(bytes: Uint8Array): Record<number, ColorGlyph> | null;
|
|
3213
|
+
|
|
3214
|
+
/**
|
|
3215
|
+
* pdfnative — Colour Glyph Renderer (COLR/CPAL → native PDF)
|
|
3216
|
+
* ==========================================================
|
|
3217
|
+
* Renders a resolved {@link ColorGlyph} as a native PDF Form XObject: each
|
|
3218
|
+
* layer's base-glyph outline is emitted as a vector path and filled with a
|
|
3219
|
+
* flat colour or a `/Shading` gradient. No rasterisation, zero dependency.
|
|
3220
|
+
*
|
|
3221
|
+
* - Solid layers → `r g b rg … f` (with `/ca` ExtGState for alpha < 1).
|
|
3222
|
+
* - Linear gradients → `/Shading` Type 2 (axial) painted via `sh`,
|
|
3223
|
+
* clipped to the glyph outline.
|
|
3224
|
+
* - Radial gradients → `/Shading` Type 3, likewise.
|
|
3225
|
+
*
|
|
3226
|
+
* The Form XObject's user space is font units; the caller scales it onto the
|
|
3227
|
+
* page with a `cm` and draws it with `Do`.
|
|
3228
|
+
*
|
|
3229
|
+
* References:
|
|
3230
|
+
* - ISO 32000-1 §8.7.4.5 (Shadings), §7.10.2 (Type 2 functions),
|
|
3231
|
+
* §8.10 (Form XObjects)
|
|
3232
|
+
*/
|
|
3233
|
+
|
|
3234
|
+
/** A rendered colour glyph ready to be assembled into a Form XObject. */
|
|
3235
|
+
interface ColorGlyphForm {
|
|
3236
|
+
/** Form XObject content stream (font-unit user space). */
|
|
3237
|
+
readonly content: string;
|
|
3238
|
+
/** Form BBox `[x0 y0 x1 y1]` in font units. */
|
|
3239
|
+
readonly bbox: readonly [number, number, number, number];
|
|
3240
|
+
/** Named `/Shading` resources referenced by the content stream. */
|
|
3241
|
+
readonly shadings: ReadonlyArray<{
|
|
3242
|
+
readonly name: string;
|
|
3243
|
+
readonly dict: string;
|
|
3244
|
+
}>;
|
|
3245
|
+
/** Named `/ExtGState` resources (constant alpha) referenced by content. */
|
|
3246
|
+
readonly extGStates: ReadonlyArray<{
|
|
3247
|
+
readonly name: string;
|
|
3248
|
+
readonly dict: string;
|
|
3249
|
+
}>;
|
|
3250
|
+
}
|
|
3251
|
+
/** Provider of glyph outlines (decoupled from the font parser for testing). */
|
|
3252
|
+
type OutlineProvider = (glyphId: number) => Contour[];
|
|
3253
|
+
type Mat = readonly [number, number, number, number, number, number];
|
|
3254
|
+
/**
|
|
3255
|
+
* Convert a set of TrueType quadratic contours into PDF path operators
|
|
3256
|
+
* (cubic Béziers), applying matrix `m`. Each contour is closed (`h`).
|
|
3257
|
+
*/
|
|
3258
|
+
declare function contoursToPath(contours: Contour[], m?: Mat): string;
|
|
3259
|
+
/**
|
|
3260
|
+
* Render a colour glyph into a {@link ColorGlyphForm}.
|
|
3261
|
+
*
|
|
3262
|
+
* @param glyph - Resolved colour glyph (ordered layers).
|
|
3263
|
+
* @param outlines - Provides the contours for a given base glyph id.
|
|
3264
|
+
* @param unitsPerEm - Font units per em (defines the BBox).
|
|
3265
|
+
*/
|
|
3266
|
+
declare function renderColorGlyph(glyph: ColorGlyph, outlines: OutlineProvider, unitsPerEm: number): ColorGlyphForm;
|
|
3267
|
+
|
|
2732
3268
|
/**
|
|
2733
3269
|
* pdfnative — PDF Token Scanner
|
|
2734
3270
|
* ===============================
|
|
@@ -3029,6 +3565,44 @@ interface PdfModifier {
|
|
|
3029
3565
|
*/
|
|
3030
3566
|
declare function createModifier(reader: PdfReader): PdfModifier;
|
|
3031
3567
|
|
|
3568
|
+
/**
|
|
3569
|
+
* pdfnative — PDF/UA structural validator (ISO 14289-1)
|
|
3570
|
+
* ======================================================
|
|
3571
|
+
* A lightweight, read-only conformance checker for tagged-PDF (PDF/UA)
|
|
3572
|
+
* structural prerequisites. It does **not** render or rasterise; it parses the
|
|
3573
|
+
* document with the native reader and inspects the catalog, structure tree and
|
|
3574
|
+
* per-page marked-content.
|
|
3575
|
+
*
|
|
3576
|
+
* Scope (what this validator can verify from structure alone):
|
|
3577
|
+
* - Catalog `/MarkInfo << /Marked true >>` (ISO 14289-1 §7.1)
|
|
3578
|
+
* - Catalog `/StructTreeRoot` (ISO 14289-1 §7.1)
|
|
3579
|
+
* - Catalog `/Metadata` (XMP) and `/Lang` (ISO 14289-1 §7.2, §7.3)
|
|
3580
|
+
* - `/StructTreeRoot /ParentTree` (ISO 32000-1 §14.7.4.4)
|
|
3581
|
+
* - MCID uniqueness within each page's content stream (ISO 32000-1 §14.7.4.3)
|
|
3582
|
+
*
|
|
3583
|
+
* It is intended as a fast developer-time gate, not a substitute for a full
|
|
3584
|
+
* reference validator (e.g. veraPDF) which also checks fonts, colour and
|
|
3585
|
+
* rendering. A `valid` result here means the structural prerequisites hold.
|
|
3586
|
+
*
|
|
3587
|
+
* @since 1.3.0
|
|
3588
|
+
*/
|
|
3589
|
+
/** Result of a PDF/UA structural validation. */
|
|
3590
|
+
interface PdfUAValidationResult {
|
|
3591
|
+
/** True when no blocking errors were found. */
|
|
3592
|
+
readonly valid: boolean;
|
|
3593
|
+
/** Blocking conformance violations. */
|
|
3594
|
+
readonly errors: readonly string[];
|
|
3595
|
+
/** Non-blocking recommendations (PDF/UA best practices). */
|
|
3596
|
+
readonly warnings: readonly string[];
|
|
3597
|
+
}
|
|
3598
|
+
/**
|
|
3599
|
+
* Validate the PDF/UA (ISO 14289-1) structural prerequisites of a tagged PDF.
|
|
3600
|
+
*
|
|
3601
|
+
* @param bytes - Complete PDF file bytes (e.g. from `buildDocumentPDFBytes`).
|
|
3602
|
+
* @returns A structured result with `valid`, `errors` and `warnings`.
|
|
3603
|
+
*/
|
|
3604
|
+
declare function validatePdfUA(bytes: Uint8Array): PdfUAValidationResult;
|
|
3605
|
+
|
|
3032
3606
|
/**
|
|
3033
3607
|
* pdfnative — DEFLATE Decompressor (FlateDecode reader)
|
|
3034
3608
|
* ======================================================
|
|
@@ -3176,4 +3750,4 @@ declare function createPDF(pdfParams: PdfParams, options?: {
|
|
|
3176
3750
|
layoutOptions?: Partial<PdfLayoutOptions>;
|
|
3177
3751
|
}): Promise<Uint8Array>;
|
|
3178
3752
|
|
|
3179
|
-
export { type AddSignaturePlaceholderOptions, type Annotation, type Asn1Node, BAL_H, type BarcodeBlock, type BarcodeFormat, type BidiRun, type CmsSignOptions, type ColumnDef, DEFAULT_COLORS, DEFAULT_COLUMNS, DEFAULT_CW, DEFAULT_FONT_SIZES, DEFAULT_MARGINS, DEFAULT_MAX_INFLATE_OUTPUT, type DocumentBlock, type DocumentMetadata, type DocumentParams, type EcPrivateKey, type EcPublicKey, type EmbeddedFilesResult, type EncodingContext, type EncryptionOptions, FT_H, type FontData, type FontEntry, type FontLoader, type FontMetrics, type FontRun, type FormField, type FormFieldBlock, type FormFieldType, type FormWidgetResult, HEADER_H, type HeadingBlock, INFO_LN, type ImageBlock, type InternalLink, KNOWN_DECODE_FILTERS, type LinkAnnotation, type LinkBlock, type ListBlock, MAX_PARSE_DEPTH, MAX_XREF_CHAIN, PAGE_SIZES, PDF_A_CONFORMANCE_TARGETS, PG_H, PG_W, type PageBreakBlock, type PageTemplate, type ParagraphBlock, type PdfArray as ParsedArray, type PdfDict as ParsedDict, type ParsedImage, type PdfAConfig, type PdfAConformanceTarget, type PdfAttachment, type PdfAttachmentRelationship, type PdfColor, type PdfColors, type PdfIndirectObject, type PdfInfoItem, type PdfLayoutOptions, type PdfModifier, type PdfName, type PdfParams, type PdfReader, type PdfRef, type PdfRgbString, type PdfRgbTuple, type PdfRow, type PdfSignOptions, type PdfStream, type PdfToken, type PdfTokenizer, type PdfValue, type QRErrorLevel, ROW_H, type RadioGroupContext, type RsaPrivateKey, type RsaPublicKey, type ShapedGlyph, type SigDictMetadata, type SignatureAlgorithm, type SpacerBlock, type StreamOptions, type SvgBlock, type SvgRenderOptions, type SvgSegment, TH_H, TITLE_LN, type TableBlock, type TextRun, type TocBlock, type TokenType, type UseCategory, type UseClassifiedCp, type UseCluster, WORKER_THRESHOLD, WORKER_TIMEOUT_MS, type WatermarkImage, type WatermarkOptions, type WatermarkState, type WatermarkText, type WorkerGenerationOptions, type WorkerInputMessage, type WorkerOutputMessage, type X509Certificate, type X509Name, type XrefEntry, type XrefTable, addSignaturePlaceholder, applyDecodeFilter, buildAcroFormDict, buildAppearanceStreamDict, buildCmsSignedData, buildDocumentPDF, buildDocumentPDFBytes, buildDocumentPDFStream, buildDocumentPDFStreamPageByPage, buildEmbeddedFiles, buildFormWidget, buildImageOperators, buildImageXObject, buildInternalLinkAnnotation, buildLinkAnnotation, buildPDF, buildPDFBytes, buildPDFStream, buildPDFStreamPageByPage, buildRadioGroupParent, buildSMaskXObject, buildSigDict, buildWatermarkState, chunkBinaryString, classifyClusters, classifyUseCategory, clearFontCache, computeColumnPositions, concatChunks, containsArabic, containsBengali, containsDevanagari, containsHebrew, containsRTL, containsTamil, containsThai, createEncodingContext, createModifier, createPDF, createTokenizer, decodeASCII85, decodeASCIIHex, decodeEcPublicKey, decodeLZW, decodeRunLength, defaultFieldHeight, derBitString, derDecode, derInteger, derOctetString, derOid, derSequence, detectCharLang, detectFallbackLangs, detectImageFormat, dictGet, dictGetArray, dictGetDict, dictGetName, dictGetNum, dictGetRef, downloadBlob, ean13CheckDigit, ecPublicKeyFromPrivate, ecdsaSign, ecdsaVerify, encodeCode128, encodeEcPublicKey, encodePDF417, encodePdfTextString, estimateCmsSize, estimateContentsSize, findStartxref, generateDataMatrix, generatePDFInWorker, generatePDFMainThread, generateQR, getMaxInflateOutputSize, getRegisteredLangs, getTrailerRef, getTrailerValue, hasFontLoader, helveticaBoldWidth, helveticaWidth, hmacSha256, inflateSync, initCrypto, initNodeCompression, initNodeDecompression as initNodeDecompression_parser, isArmenianCodepoint, isArray, isBengaliCodepoint, isCyrillicCodepoint, isDevanagariCodepoint, isDict, isGeorgianCodepoint, isLinkAnnotation, isName, isRef, isSelfSigned, isStream, isTamilCodepoint, isValidPdfRgb, loadFontData, nameValue, needsUnicodeFont, normalizeBidiEmbeddings, normalizeColors, openPdf, parseCertificate, parseColor, parseImage, parseIndirectObject, parseJPEG, parsePNG, parseRsaPrivateKey, parseRsaPublicKey, parseSvgPath, parseValue, parseXrefTable, pdfString, registerFont, registerFonts, renderBarcode, renderCode128, renderDataMatrix, renderEAN13, renderPDF417, renderQR, renderSvg, resetFontRegistry, resolveBidiRuns, resolveLayout, resolvePdfAConfig, resolveTemplate, rsaSign, rsaSignHash, rsaVerify, rsaVerifyHash, setDeflateImpl, setInflateImpl, setMaxInflateOutputSize, sha384, sha512, shapeArabicText, shapeBengaliText, shapeDevanagariText, shapeTamilText, shapeThaiText, signPdfBytes, slugify, splitTextByFont, streamByteLength, stripBidiControls, toBytes, toWinAnsi, truncate, truncateToWidth, validateAttachments, validateDocumentStreamable, validateTableStreamable, validateURL, validateWatermark, verifyCertSignature, wrapText };
|
|
3753
|
+
export { type AddSignaturePlaceholderOptions, type Annotation, type Asn1Node, BAL_H, type BarcodeBlock, type BarcodeFormat, type BidiRun, type CmsSignOptions, type ColorGlyph, type ColorGlyphForm, type ColorLayer, type ColorPaint, type ColorStop, type ColumnDef, type Contour, type CpalColor, DEFAULT_COLORS, DEFAULT_COLUMNS, DEFAULT_CW, DEFAULT_FONT_SIZES, DEFAULT_MARGINS, DEFAULT_MAX_BLOCKS, DEFAULT_MAX_INFLATE_OUTPUT, type DocumentBlock, type DocumentMetadata, type DocumentParams, type EcPrivateKey, type EcPublicKey, type EmbeddedFilesResult, type EncodingContext, type EncryptionOptions, FT_H, type FontData, type FontEntry, type FontLoader, type FontMetrics, type FontRun, type FormField, type FormFieldBlock, type FormFieldType, type FormWidgetResult, type GlyfFont, type GradientExtend, HEADER_H, type HeadingBlock, INFO_LN, type ImageBlock, type InternalLink, KNOWN_DECODE_FILTERS, type LinearGradientPaint, type LinkAnnotation, type LinkBlock, type ListBlock, MAX_PARSE_DEPTH, MAX_XREF_CHAIN, type OutlinePoint, type OutlineProvider, PAGE_SIZES, PDF_A_CONFORMANCE_TARGETS, PG_H, PG_W, type PageBreakBlock, type PageTemplate, type ParagraphBlock, type PdfArray as ParsedArray, type PdfDict as ParsedDict, type ParsedImage, type PdfAConfig, type PdfAConformanceTarget, type PdfAttachment, type PdfAttachmentRelationship, type PdfColor, type PdfColors, type PdfIndirectObject, type PdfInfoItem, type PdfLayoutOptions, type PdfModifier, type PdfName, type PdfParams, type PdfReader, type PdfRef, type PdfRgbString, type PdfRgbTuple, type PdfRow, type PdfSignOptions, type PdfStream, type PdfToken, type PdfTokenizer, type PdfUAValidationResult, type PdfValue, type QRErrorLevel, ROW_H, type RadialGradientPaint, type RadioGroupContext, type RsaPrivateKey, type RsaPublicKey, type ShapedGlyph, type SigDictMetadata, type SignatureAlgorithm, type SolidPaint, type SpacerBlock, type StreamOptions, type SvgBlock, type SvgRenderOptions, type SvgSegment, TH_H, TITLE_LN, type TableBlock, type TextRun, type TocBlock, type TokenType, type UseCategory, type UseClassifiedCp, type UseCluster, WORKER_THRESHOLD, WORKER_TIMEOUT_MS, type WatermarkImage, type WatermarkOptions, type WatermarkState, type WatermarkText, type WorkerGenerationOptions, type WorkerInputMessage, type WorkerOutputMessage, type X509Certificate, type X509Name, type XrefEntry, type XrefTable, addSignaturePlaceholder, applyDecodeFilter, buildAcroFormDict, buildAppearanceStreamDict, buildCmsSignedData, buildDocumentPDF, buildDocumentPDFBytes, buildDocumentPDFStream, buildDocumentPDFStreamPageByPage, buildDocumentPDFStreamTrue, buildEmbeddedFiles, buildFormWidget, buildImageOperators, buildImageXObject, buildInternalLinkAnnotation, buildLinkAnnotation, buildPDF, buildPDFBytes, buildPDFStream, buildPDFStreamPageByPage, buildPDFStreamTrue, buildRadioGroupParent, buildSMaskXObject, buildSigDict, buildWatermarkState, chunkBinaryString, classifyClusters, classifyUseCategory, clearFontCache, computeColumnPositions, concatChunks, containsArabic, containsBengali, containsDevanagari, containsEthiopic, containsHebrew, containsKhmer, containsMyanmar, containsRTL, containsSinhala, containsTamil, containsTelugu, containsThai, containsTibetan, contoursToPath, createEncodingContext, createModifier, createPDF, createTokenizer, decodeASCII85, decodeASCIIHex, decodeEcPublicKey, decodeLZW, decodeRunLength, defaultFieldHeight, derBitString, derDecode, derInteger, derOctetString, derOid, derSequence, detectCharLang, detectFallbackLangs, detectImageFormat, dictGet, dictGetArray, dictGetDict, dictGetName, dictGetNum, dictGetRef, downloadBlob, ean13CheckDigit, ecPublicKeyFromPrivate, ecdsaSign, ecdsaVerify, encodeCode128, encodeEcPublicKey, encodePDF417, encodePdfTextString, estimateCmsSize, estimateContentsSize, extractGlyphContours, findStartxref, generateDataMatrix, generatePDFInWorker, generatePDFMainThread, generateQR, getMaxInflateOutputSize, getRegisteredLangs, getTrailerRef, getTrailerValue, hasFontLoader, helveticaBoldWidth, helveticaWidth, hmacSha256, inflateSync, initCrypto, initNodeCompression, initNodeDecompression as initNodeDecompression_parser, isArmenianCodepoint, isArray, isBengaliCodepoint, isCyrillicCodepoint, isDevanagariCodepoint, isDict, isEthiopicCodepoint, isGeorgianCodepoint, isKhmerCodepoint, isLinkAnnotation, isMyanmarCodepoint, isName, isRef, isSelfSigned, isSinhalaCodepoint, isStream, isTamilCodepoint, isTeluguCodepoint, isTibetanCodepoint, isValidPdfRgb, loadFontData, nameValue, needsUnicodeFont, normalizeBidiEmbeddings, normalizeColors, openPdf, parseCertificate, parseColor, parseColrCpal, parseCpal, parseGlyfFont, parseImage, parseIndirectObject, parseJPEG, parsePNG, parseRsaPrivateKey, parseRsaPublicKey, parseSvgPath, parseValue, parseXrefTable, pdfString, registerFont, registerFonts, renderBarcode, renderCode128, renderColorGlyph, renderDataMatrix, renderEAN13, renderPDF417, renderQR, renderSvg, resetFontRegistry, resolveBidiRuns, resolveLayout, resolvePdfAConfig, resolveTemplate, rsaSign, rsaSignHash, rsaVerify, rsaVerifyHash, setDeflateImpl, setInflateImpl, setMaxInflateOutputSize, sha384, sha512, shapeArabicText, shapeBengaliText, shapeDevanagariText, shapeKhmerText, shapeMyanmarText, shapeSinhalaText, shapeTamilText, shapeTeluguText, shapeThaiText, shapeTibetanText, signPdfBytes, slugify, splitTextByFont, streamByteLength, stripBidiControls, toBytes, toWinAnsi, truncate, truncateToWidth, validateAttachments, validateDocumentStreamable, validatePdfUA, validateTableStreamable, validateURL, validateWatermark, verifyCertSignature, wrapText };
|