@hufe921/jsofd 1.0.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/dist/pdf.d.ts ADDED
@@ -0,0 +1,1122 @@
1
+ /**
2
+ * jsOFD public type definitions.
3
+ */
4
+ /** RGB color (0-255) */
5
+ type RGB = [number, number, number];
6
+ /** Paper format: a name ('a4', 'letter', ...) or [width, height] in the active unit */
7
+ type PageFormat = string | [number, number] | number[];
8
+ /** Page orientation */
9
+ type Orientation = 'p' | 'portrait' | 'l' | 'landscape';
10
+ /** Measurement unit */
11
+ type Unit = 'pt' | 'mm' | 'cm' | 'in' | 'inch' | 'px' | 'pc' | 'em' | 'ex';
12
+ /** Constructor options */
13
+ interface jsOFDOptions {
14
+ /** Page orientation, default 'p' (portrait) */
15
+ orientation?: Orientation;
16
+ /** Measurement unit, default 'mm' */
17
+ unit?: Unit;
18
+ /** Paper format, default 'a4'; may be a [width, height] array */
19
+ format?: PageFormat;
20
+ /** Number serialization precision (decimals), default 4 */
21
+ floatPrecision?: number;
22
+ }
23
+ interface EmbeddedFontFile {
24
+ /** Raw TTF/OTF bytes written into `Doc_0/Res/`. */
25
+ data: Uint8Array;
26
+ /** File extension: `ttf` or `otf`. */
27
+ ext: string;
28
+ }
29
+ /** Font style */
30
+ type FontStyle = 'normal' | 'bold' | 'italic' | 'bolditalic';
31
+ /** Text alignment */
32
+ type TextAlign = 'left' | 'center' | 'right' | 'justify';
33
+ /** Text baseline */
34
+ type TextBaseline = 'alphabetic' | 'top' | 'middle' | 'bottom' | 'hanging';
35
+ /** Text rendering mode */
36
+ type TextRenderingMode = 'fill' | 'stroke' | 'fillThenStroke' | 'invisible';
37
+ /** doc.text() options */
38
+ interface TextOptions {
39
+ /** Horizontal alignment, default 'left'; 'justify' requires maxWidth */
40
+ align?: TextAlign;
41
+ /** Rotation in degrees, clockwise around the x,y anchor */
42
+ angle?: number;
43
+ /** Baseline position, default 'alphabetic' (x,y marks the baseline) */
44
+ baseline?: TextBaseline;
45
+ /** Extra spacing between glyphs (active unit) */
46
+ charSpace?: number;
47
+ /** Line height factor, default 1.15 */
48
+ lineHeightFactor?: number;
49
+ /** Maximum line width before wrapping (active unit) */
50
+ maxWidth?: number;
51
+ /** Rendering mode (string or PDF Tr number 0-7) */
52
+ renderingMode?: TextRenderingMode | number | boolean;
53
+ /** Opacity 0-1 */
54
+ opacity?: number;
55
+ /** Font size override in points (jsPDF semantics) */
56
+ fontSize?: number;
57
+ /** Horizontal scale; 1 is unscaled (jsPDF horizontalScale) */
58
+ horizontalScale?: number;
59
+ /** Render right-to-left (jsPDF R2L) */
60
+ R2L?: boolean;
61
+ }
62
+ /** Link options */
63
+ interface LinkOptions {
64
+ /** External URL */
65
+ url?: string;
66
+ /** In-document target page number (1-based) */
67
+ pageNumber?: number;
68
+ /** Jump magnification */
69
+ magFactor?: 'fit' | 'fitH' | 'fitV' | number | string;
70
+ }
71
+ /** Document properties */
72
+ interface DocProperties {
73
+ title?: string;
74
+ subject?: string;
75
+ author?: string;
76
+ keywords?: string;
77
+ creator?: string;
78
+ creatorVersion?: string;
79
+ }
80
+ /** addFont options */
81
+ interface AddFontOptions {
82
+ /** Display family name (defaults to fontName) */
83
+ familyName?: string;
84
+ /** Whether the font is serif */
85
+ serif?: boolean;
86
+ /** Whether the font is monospaced */
87
+ fixed?: boolean;
88
+ /** Whether the font covers CJK (full-width approximation) */
89
+ cjk?: boolean;
90
+ /** Ascent (1/1000 em, default 800) */
91
+ ascent?: number;
92
+ /** Descent (1/1000 em, negative, default -200) */
93
+ descent?: number;
94
+ /** Custom width table (ASCII 32..126, 1/1000 em) */
95
+ widths?: Partial<Record<FontStyle, number[]>>;
96
+ /** Alias for setFont lookups */
97
+ alias?: string;
98
+ /** Embedded font file extension override (`ttf` default, `otf` for CFF). */
99
+ fontExt?: string;
100
+ }
101
+ /** Bookmark options */
102
+ interface OutlineOptions {
103
+ /** Target page number (1-based, default 1) */
104
+ pageNumber?: number;
105
+ /** Jump position */
106
+ left?: number;
107
+ top?: number;
108
+ zoom?: number;
109
+ }
110
+ /** Bookmark node returned by doc.outline.add; pass back as parent to nest */
111
+ interface OutlineNode {
112
+ title: string;
113
+ parent: OutlineNode | null;
114
+ children: OutlineNode[];
115
+ options: OutlineOptions;
116
+ }
117
+ /** Attachment options */
118
+ interface AttachmentOptions {
119
+ /** Attachment format description */
120
+ format?: string;
121
+ /** Description */
122
+ description?: string;
123
+ }
124
+ /** Accepted addImage inputs */
125
+ type ImageInput = string | Uint8Array | ArrayBuffer | HTMLImageElement | HTMLCanvasElement;
126
+ /** Image properties returned by getImageProperties */
127
+ interface ImageProperties {
128
+ fileType: string;
129
+ width: number | null;
130
+ height: number | null;
131
+ bytes: number;
132
+ data: Uint8Array;
133
+ }
134
+ /** Graphics state */
135
+ interface GState {
136
+ /** Opacity 0-1 */
137
+ opacity?: number;
138
+ }
139
+ /** Reader interface preferences (jsPDF viewerPreferences) */
140
+ interface ViewerPreferences {
141
+ HideToolbar?: boolean;
142
+ HideMenubar?: boolean;
143
+ HideWindowUI?: boolean;
144
+ FitWindow?: boolean;
145
+ }
146
+ /** output() return type ('dataurlnewwindow' returns null after opening a window) */
147
+ type OutputResult = ArrayBuffer | Uint8Array | string | Blob | null;
148
+ /** Active font info (getFont) */
149
+ interface FontInfo {
150
+ fontName: string;
151
+ fontStyle: FontStyle;
152
+ key: string;
153
+ }
154
+
155
+ /**
156
+ * Internal page object model (points; converted to mm at serialisation time).
157
+ */
158
+
159
+ interface PageData {
160
+ /** Page width in points */
161
+ width: number;
162
+ /** Page height in points */
163
+ height: number;
164
+ objects: PageObject[];
165
+ }
166
+ type PageObject = TextRun | PathRun | ImageRun | LinkRun;
167
+ interface TextRun {
168
+ t: 'text';
169
+ /** Baseline start X in points */
170
+ x: number;
171
+ /** Baseline start Y in points */
172
+ y: number;
173
+ text: string;
174
+ /** Font size in points */
175
+ size: number;
176
+ fontKey: string;
177
+ style: FontStyle;
178
+ color: RGB;
179
+ charSpace: number;
180
+ /** Rotation in degrees */
181
+ angle: number;
182
+ ascent: number;
183
+ descent: number;
184
+ renderingMode: string;
185
+ opacity: number | null;
186
+ /** Justification target width in points; null disables stretching */
187
+ justifyWidth: number | null;
188
+ /** Horizontal scale (jsPDF horizontalScale; 1 is unscaled) */
189
+ hScale: number;
190
+ /** Per-glyph advances in points (PDF import); falls back to font metrics */
191
+ glyphWs?: number[];
192
+ }
193
+ type PathOp = {
194
+ op: 'M';
195
+ x: number;
196
+ y: number;
197
+ } | {
198
+ op: 'L';
199
+ x: number;
200
+ y: number;
201
+ } | {
202
+ op: 'C';
203
+ x1: number;
204
+ y1: number;
205
+ x2: number;
206
+ y2: number;
207
+ x: number;
208
+ y: number;
209
+ } | {
210
+ op: 'Z';
211
+ };
212
+ interface DashState {
213
+ pattern: number[];
214
+ phase: number;
215
+ }
216
+ interface PathRun {
217
+ t: 'path';
218
+ ops: PathOp[];
219
+ fill: boolean;
220
+ stroke: boolean;
221
+ fillColor: RGB;
222
+ strokeColor: RGB;
223
+ /** Stroke width in points */
224
+ lineWidth: number;
225
+ dash: DashState | null;
226
+ cap: number;
227
+ join: number;
228
+ /** Miter limit in points (emitted when > 1) */
229
+ miterLimit: number;
230
+ opacity: number | null;
231
+ }
232
+ interface AttachmentData {
233
+ name: string;
234
+ data: Uint8Array;
235
+ format: string;
236
+ description: string;
237
+ creationDate: Date;
238
+ }
239
+ /** Registered image resources (deduplicated). */
240
+ interface ImageResource {
241
+ alias: string;
242
+ data: Uint8Array;
243
+ /** OFD MultiMedia Format value (PNG/JPEG/GIF/BMP/TIFF) */
244
+ format: string;
245
+ /** File extension (lowercase) */
246
+ ext: string;
247
+ width: number | null;
248
+ height: number | null;
249
+ /** Resource ID assigned at serialisation time */
250
+ resId: number;
251
+ }
252
+ interface ImageRun {
253
+ t: 'image';
254
+ x: number;
255
+ y: number;
256
+ w: number;
257
+ h: number;
258
+ /** Image resource reference */
259
+ imageRef: ImageResource;
260
+ angle: number;
261
+ opacity: number | null;
262
+ }
263
+ interface LinkRun {
264
+ t: 'link';
265
+ x: number;
266
+ y: number;
267
+ w: number;
268
+ h: number;
269
+ url: string | null;
270
+ pageNumber: number | null;
271
+ magFactor: string | number | null;
272
+ }
273
+
274
+ /**
275
+ * Font registry and text metrics.
276
+ *
277
+ * Width tables come from the public Adobe Core 14 AFM metrics (Helvetica/Times/Courier, ASCII 32..126);
278
+ * Chinese fonts (Song/Hei/Kai/FangSong) are approximated as full-width 1000, half-width 500.
279
+ * No font files are embedded; FontName references the reader's local fonts.
280
+ */
281
+
282
+ interface FontWidths {
283
+ normal?: number[];
284
+ bold?: number[];
285
+ italic?: number[];
286
+ bolditalic?: number[];
287
+ }
288
+ interface FontDef {
289
+ /** PostScript/reference name (written to FontName) */
290
+ familyName: string;
291
+ /** Display name (written to FamilyName) */
292
+ displayName: string;
293
+ serif: boolean;
294
+ fixed: boolean;
295
+ /** Whether the font covers CJK (full-width CJK, half-width ASCII when true) */
296
+ cjk: boolean;
297
+ /** Ascent (1/1000 em) */
298
+ ascent: number;
299
+ /** Descent (1/1000 em, negative) */
300
+ descent: number;
301
+ widths: FontWidths | null;
302
+ /** Per-code-point widths in 1/1000 em (embedded fonts, exact metrics). */
303
+ unicodeWidths?: Map<number, number>;
304
+ /** Embedded font file; when present readers never fall back to local fonts. */
305
+ fontFile?: EmbeddedFontFile;
306
+ }
307
+
308
+ /** Interactive annotations: link areas and file attachments. */
309
+
310
+ declare const AnnotationApi: {
311
+ /**
312
+ * Add a clickable rectangular area.
313
+ *
314
+ * Pass `url` for an external target or `pageNumber` (1-based) for an
315
+ * in-document jump. The area itself is invisible.
316
+ */
317
+ link(this: jsOFD, x: number, y: number, w: number, h: number, options?: LinkOptions): jsOFD;
318
+ /**
319
+ * Embed a file as an OFD attachment.
320
+ *
321
+ * @param data UTF-8 text, a base64 data URL, or binary bytes
322
+ */
323
+ addFileAsAttachment(this: jsOFD, filename: string, data: string | Uint8Array | ArrayBuffer, options?: AttachmentOptions): jsOFD;
324
+ };
325
+ type AnnotationApi = typeof AnnotationApi;
326
+ declare module '../jsofd' {
327
+ interface jsOFD extends AnnotationApi {
328
+ }
329
+ }
330
+
331
+ /**
332
+ * Visual annotations: highlight, underline, strikeout, squiggly, freehand
333
+ * ink, free text and stamp-like boxes.
334
+ *
335
+ * They are emitted as ordinary page objects (translucent fills, strokes,
336
+ * text), so every OFD reader renders them without needing the optional
337
+ * annotation sidecar of the standard.
338
+ */
339
+
340
+ type AnnotationType = 'highlight' | 'underline' | 'strikeout' | 'squiggly' | 'ink' | 'freetext' | 'box';
341
+ interface AnnotationOptions {
342
+ /** Annotation color (default per type) */
343
+ color?: RGB;
344
+ /** Opacity 0-1 (default 0.35 for highlight, 1 otherwise) */
345
+ opacity?: number;
346
+ /** Line thickness (active unit, default 0.6) */
347
+ lineWidth?: number;
348
+ /** Font size in pt for freetext (default 11) */
349
+ fontSize?: number;
350
+ /** Font key for freetext (default: current font) */
351
+ fontKey?: string;
352
+ /** Text for freetext */
353
+ text?: string;
354
+ /** Fill color for box (default: transparent — stroke only) */
355
+ fill?: RGB;
356
+ /** Freehand point list for `ink` (active units) */
357
+ points?: [number, number][];
358
+ }
359
+ declare const AnnotationVisualApi: {
360
+ /**
361
+ * Draw a visual annotation over the rectangle `(x, y, w, h)` and return the
362
+ * doc for chaining.
363
+ *
364
+ * - `highlight` translucent marker behind/over text (default yellow)
365
+ * - `underline` straight line at the bottom edge
366
+ * - `strikeout` line through the vertical middle
367
+ * - `squiggly` hand-drawn style zigzag along the bottom edge
368
+ * - `box` rectangle outline (optionally filled via `options.fill`)
369
+ * - `ink` `options.points` as a freehand polyline (`[[x,y],…]`)
370
+ * - `freetext` `options.text` wrapped inside the rectangle
371
+ */
372
+ addAnnotation(this: jsOFD, type: AnnotationType, x: number, y: number, w: number, h: number, options?: AnnotationOptions): jsOFD;
373
+ };
374
+ type AnnotationVisualApi = typeof AnnotationVisualApi;
375
+ declare module '../jsofd' {
376
+ interface jsOFD extends AnnotationVisualApi {
377
+ }
378
+ }
379
+
380
+ /**
381
+ * Page-flow helpers: automatic multi-page text flow (`autoPaging`) and
382
+ * header/footer hooks applied to every page (`headerFooter`).
383
+ */
384
+
385
+ /** Info passed to page hooks. */
386
+ interface PageInfo {
387
+ /** One-based page number */
388
+ pageNumber: number;
389
+ /** Total page count at the time of the call */
390
+ pageCount: number;
391
+ }
392
+ type PageHook = (doc: jsOFD, info: PageInfo) => void;
393
+ interface HeaderFooterOptions {
394
+ /** Drawn on every page in `startPage..end` */
395
+ header?: PageHook;
396
+ /** Drawn on every page in `startPage..end` */
397
+ footer?: PageHook;
398
+ /** First one-based page to draw on (default 1) */
399
+ startPage?: number;
400
+ /** Last one-based page to draw on (default: last page) */
401
+ endPage?: number;
402
+ }
403
+ interface AutoPagingOptions {
404
+ /** Left edge of the text block (active unit) */
405
+ x?: number;
406
+ /** First baseline (active unit); defaults to `topMargin` + first line */
407
+ y?: number;
408
+ /** Wrap width (active unit); defaults to page width − `x` − `rightMargin` */
409
+ maxWidth?: number;
410
+ /** Page top margin used when a new page starts (active unit, default 20) */
411
+ topMargin?: number;
412
+ /** Page bottom margin; flow breaks before crossing it (default 20) */
413
+ bottomMargin?: number;
414
+ /** Right margin when `maxWidth` is omitted (default 20) */
415
+ rightMargin?: number;
416
+ /** Line height factor (default: current global) */
417
+ lineHeightFactor?: number;
418
+ /** Alignment of every line (default 'left') */
419
+ align?: 'left' | 'center' | 'right' | 'justify';
420
+ /** Called after each automatic `addPage()` */
421
+ onNewPage?: PageHook;
422
+ }
423
+ declare const FlowApi: {
424
+ /**
425
+ * Flow long text across as many pages as needed.
426
+ *
427
+ * Lines wrap at `maxWidth` (same CJK/Latin rules as `text()`); when the
428
+ * next line would cross the bottom margin a new page is appended and
429
+ * `onNewPage` fires (for headers, page numbers, …).
430
+ *
431
+ * @returns the Y coordinate (active unit) after the last line — chain more
432
+ * content from there
433
+ */
434
+ autoPaging(this: jsOFD, text: string, options?: AutoPagingOptions): number;
435
+ /**
436
+ * Draw headers and footers on a page range.
437
+ *
438
+ * Hooks receive the document (positioned on the target page — use
439
+ * `text`/`line`/… normally) and `{ pageNumber, pageCount }`. Common use:
440
+ *
441
+ * ```ts
442
+ * doc.headerFooter({
443
+ * header: (d, { pageNumber }) => d.text('季度报告', 20, 12),
444
+ * footer: (d, { pageNumber, pageCount }) =>
445
+ * d.text(`第 ${pageNumber} 页 / 共 ${pageCount} 页`, 105, 285, { align: 'center' }),
446
+ * });
447
+ * ```
448
+ */
449
+ headerFooter(this: jsOFD, options: HeaderFooterOptions): jsOFD;
450
+ };
451
+ type FlowApi = typeof FlowApi;
452
+ declare module '../jsofd' {
453
+ interface jsOFD extends FlowApi {
454
+ }
455
+ }
456
+
457
+ /**
458
+ * `doc.html()` — render simple HTML into the document.
459
+ *
460
+ * A dependency-free tag-stream parser (works in Node and browsers) walks the
461
+ * markup and lays out block elements — headings, paragraphs, lists, breaks —
462
+ * flowing across pages at the bottom margin. Inline styling covers bold and
463
+ * italic (`b`, `strong`, `i`, `em`), entities are decoded.
464
+ *
465
+ * This is deliberately not a CSS engine: layout attributes come from the tag
466
+ * semantics, not stylesheets.
467
+ */
468
+
469
+ interface HtmlOptions {
470
+ /** Left edge of the text block (active unit, default 20) */
471
+ x?: number;
472
+ /** Top of the content (active unit, default 20) */
473
+ y?: number;
474
+ /** Wrap width (default: page width − x − `rightMargin`) */
475
+ width?: number;
476
+ /** Bottom margin of the flow area (default 20) */
477
+ bottomMargin?: number;
478
+ /** Top margin used on continuation pages (default 20) */
479
+ topMargin?: number;
480
+ /** Base font size in pt (default 11) */
481
+ fontSize?: number;
482
+ /** Heading scale factor per level: h1 = base × 2, h2 = × 1.5, … */
483
+ headingScale?: number;
484
+ /** Line height factor (default 1.5) */
485
+ lineHeightFactor?: number;
486
+ /** Called after each automatic page break */
487
+ onNewPage?: (doc: jsOFD, info: {
488
+ pageNumber: number;
489
+ pageCount: number;
490
+ }) => void;
491
+ }
492
+ declare const HtmlApi: {
493
+ /**
494
+ * Render an HTML fragment and return the final Y (active unit).
495
+ *
496
+ * Supported: `h1–h6`, `p`, `div`, `br`, `ul/ol` + `li`, `b/strong`,
497
+ * `i/em`, entities. Inline `span` text is preserved. Attributes and CSS
498
+ * are ignored by design.
499
+ */
500
+ html(this: jsOFD, html: string, options?: HtmlOptions): number;
501
+ };
502
+ type HtmlApi = typeof HtmlApi;
503
+ declare module '../jsofd' {
504
+ interface jsOFD extends HtmlApi {
505
+ }
506
+ }
507
+
508
+ /** Image embedding and inspection. */
509
+
510
+ declare const ImageApi: {
511
+ /**
512
+ * Embed an image and place it on the current page.
513
+ *
514
+ * Binary data (PNG/JPEG/GIF/BMP/TIFF) is embedded byte-for-byte; data URLs,
515
+ * bare base64 strings (with `format`), `HTMLImageElement` and
516
+ * `HTMLCanvasElement` inputs are also accepted.
517
+ *
518
+ * When `w`/`h` are omitted the natural size at 72 dpi is used. Identical
519
+ * data is stored once and referenced multiple times.
520
+ */
521
+ addImage(this: jsOFD, a: unknown, b: unknown, c?: unknown, d?: unknown, e?: unknown, f?: unknown, g?: unknown, h?: unknown, i?: unknown): jsOFD;
522
+ /**
523
+ * Inspect an image without embedding it.
524
+ *
525
+ * @returns format, pixel dimensions, byte count and the raw data
526
+ */
527
+ getImageProperties(this: jsOFD, imageData: ImageInput): ImageProperties;
528
+ };
529
+ /** Structural type of the mixin (merged into jsOFD via declaration merging). */
530
+ type ImageApi = typeof ImageApi;
531
+ declare module '../jsofd' {
532
+ interface jsOFD extends ImageApi {
533
+ }
534
+ }
535
+
536
+ /** Vector shape primitives: lines, polylines, curves and closed shapes. */
537
+
538
+ declare const ShapeApi: {
539
+ /**
540
+ * @internal Push a path onto the current page using the active graphics
541
+ * state. All public shape helpers funnel through this single entry point.
542
+ */
543
+ _pushPath(this: jsOFD, ops: PathOp[], style?: string): jsOFD;
544
+ /** Draw a straight line from `(x1, y1)` to `(x2, y2)`. */
545
+ line(this: jsOFD, x1: number, y1: number, x2: number, y2: number, style?: string): jsOFD;
546
+ /**
547
+ * Draw a polyline or curve through relative segments (jsPDF `lines`).
548
+ *
549
+ * The path starts with `M` at the anchor `(x, y)`. Each segment is a
550
+ * cumulative delta relative to the current point:
551
+ * `[dx, dy]` draws a straight line, `[x1, y1, x2, y2, x3, y3]` a cubic
552
+ * Bézier through three delta points.
553
+ *
554
+ * Supports the legacy signature `lines(x, y, lines, scale, style, closed)`.
555
+ */
556
+ lines(this: jsOFD, linesOrX: number[][] | number, xOrY: number | number[][], yOrLines?: number | number[][], scale1OrStyle?: number | number[] | string, scale2?: number | string, styleOrClosed?: string | boolean, _closedArg?: boolean): jsOFD;
557
+ /** Draw a triangle through three vertices. */
558
+ triangle(this: jsOFD, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, style?: string): jsOFD;
559
+ /** Draw a rectangle; `(x, y)` is the top-left corner. */
560
+ rect(this: jsOFD, x: number, y: number, w: number, h: number, style?: string): jsOFD;
561
+ /**
562
+ * Draw a rounded rectangle; `(x, y)` is the top-left corner.
563
+ *
564
+ * `ry` defaults to `rx`. Corners are quarter circles approximated with
565
+ * cubic Béziers (κ = 0.5523).
566
+ */
567
+ roundedRect(this: jsOFD, x: number, y: number, w: number, h: number, rx: number, ry?: number, style?: string): jsOFD;
568
+ /** Draw an ellipse centered at `(x, y)`. */
569
+ ellipse(this: jsOFD, x: number, y: number, rx: number, ry: number, style?: string): jsOFD;
570
+ /** Draw a circle centered at `(x, y)` with radius `r`. */
571
+ circle(this: jsOFD, x: number, y: number, r: number, style?: string): jsOFD;
572
+ };
573
+ type ShapeApi = typeof ShapeApi;
574
+ declare module '../jsofd' {
575
+ interface jsOFD extends ShapeApi {
576
+ }
577
+ }
578
+
579
+ /** Document state accessors: fonts, colors and graphics state. */
580
+
581
+ declare const StateApi: {
582
+ /** Resolve a font key to its definition (custom → builtin → Helvetica). */
583
+ getFontDef(this: jsOFD, key: string): FontDef;
584
+ /**
585
+ * Register a custom font.
586
+ *
587
+ * Fonts are referenced by `FontName` and resolved by the reader's local
588
+ * font table — no font file is embedded.
589
+ *
590
+ * @param postScriptName unique registry key
591
+ * @param fontName family name written to the OFD font declaration
592
+ * @param fontStyle `normal` / `bold` / `italic` / `bolditalic`
593
+ * @param opts metrics (ascent/descent/widths) and aliases
594
+ */
595
+ addFont(this: jsOFD, postScriptName: string, fontName: string, fontStyle: string, opts?: AddFontOptions): string;
596
+ /**
597
+ * Register a font with an embedded file (recommended for CJK documents).
598
+ *
599
+ * Parses the font for exact metrics (units per em, ascent/descent, per-glyph
600
+ * advance widths via cmap/hmtx) and writes the bytes into the OFD package as
601
+ * `FontFile`. Embedded fonts render identically in every reader — unembedded
602
+ * fonts depend on the reader's local font table and may show garbage glyphs.
603
+ *
604
+ * Registering a key that matches a built-in (`'simsun'`, `'simhei'`, ...)
605
+ * overrides it, so existing code keeps working while gaining embedding.
606
+ *
607
+ * @param postScriptName registry key, e.g. `'simsun'` or `'MyFont'`
608
+ * @param fontName family name written to the OFD font declaration
609
+ * @param ttfData TTF/OTF (or TTC) file bytes
610
+ */
611
+ addFontTtf(this: jsOFD, postScriptName: string, fontName: string, ttfData: Uint8Array, opts?: AddFontOptions): string;
612
+ /**
613
+ * Select the active font.
614
+ *
615
+ * Accepts PostScript names (`Helvetica-Bold`), family names (`helvetica`,
616
+ * `times`), common Chinese names (`宋体`, `黑体`, `楷体`, `仿宋`) and any
617
+ * previously registered custom key or alias.
618
+ */
619
+ setFont(this: jsOFD, fontName: string, fontStyle?: string): jsOFD;
620
+ /** Set the font size in points (independent of the document unit, like jsPDF). */
621
+ setFontSize(this: jsOFD, size: number): jsOFD;
622
+ /** Active font size in points (default 16, like jsPDF). */
623
+ getFontSize(this: jsOFD): number;
624
+ /** Set extra spacing between glyphs, in the active unit. */
625
+ setCharSpace(this: jsOFD, space: number): jsOFD;
626
+ /** Active character spacing in the active unit. */
627
+ getCharSpace(this: jsOFD): number;
628
+ /** Set the line height factor (default 1.15, like jsPDF). */
629
+ setLineHeightFactor(this: jsOFD, f: number): jsOFD;
630
+ /** Registered font keys, built-in first. */
631
+ getFontList(this: jsOFD): string[];
632
+ /** Information about the active font (jsPDF `getFont()`). */
633
+ getFont(this: jsOFD): FontInfo;
634
+ /** Set the text fill color (`r` may also be a color name or hex string). */
635
+ setTextColor(this: jsOFD, r: number | string, g?: number, b?: number): jsOFD;
636
+ /** Active text color as `#rrggbb` (jsPDF getter semantics). */
637
+ getTextColor(this: jsOFD): string;
638
+ /** Set the stroke color used by shape outlines. */
639
+ setDrawColor(this: jsOFD, r: number | string, g?: number, b?: number): jsOFD;
640
+ /** Active stroke color as `#rrggbb`. */
641
+ getDrawColor(this: jsOFD): string;
642
+ /** Set the fill color used by filled shapes. */
643
+ setFillColor(this: jsOFD, r: number | string, g?: number, b?: number): jsOFD;
644
+ /** Active fill color as `#rrggbb`. */
645
+ getFillColor(this: jsOFD): string;
646
+ /** Set the stroke width in the active unit. */
647
+ setLineWidth(this: jsOFD, width: number): jsOFD;
648
+ /** Active stroke width in the active unit. */
649
+ getLineWidth(this: jsOFD): number;
650
+ /** Set the dash pattern (active unit); an empty array clears dashing. */
651
+ setLineDashPattern(this: jsOFD, dashArray: number[], dashPhase?: number): jsOFD;
652
+ /** Active dash pattern in the active unit. */
653
+ getLineDashPattern(this: jsOFD): number[];
654
+ /** Set the line cap: 0 butt, 1 round, 2 square (names accepted). */
655
+ setLineCap(this: jsOFD, style: number | "butt" | "round" | "square"): jsOFD;
656
+ /** Active line cap (0-2). */
657
+ getLineCap(this: jsOFD): number;
658
+ /** Set the line join: 0 miter, 1 round, 2 bevel (names accepted). */
659
+ setLineJoin(this: jsOFD, style: number | "miter" | "round" | "bevel"): jsOFD;
660
+ /** Active line join (0-2). */
661
+ getLineJoin(this: jsOFD): number;
662
+ /** Set the miter limit (active unit); values ≤ 1 omit the attribute. */
663
+ setLineMiterLimit(this: jsOFD, limit: number): jsOFD;
664
+ /** Active miter limit in the active unit. */
665
+ getLineMiterLimit(this: jsOFD): number;
666
+ /** Line height in points: font size × line height factor. */
667
+ getLineHeight(this: jsOFD): number;
668
+ /** Enable or disable right-to-left rendering. */
669
+ setR2L(this: jsOFD, value: boolean): jsOFD;
670
+ /** Whether right-to-left rendering is active. */
671
+ getR2L(this: jsOFD): boolean;
672
+ /**
673
+ * Apply a graphics state.
674
+ *
675
+ * Only `opacity` is supported; other GState keys are ignored (OFD models
676
+ * blend modes differently from PDF).
677
+ */
678
+ setGState(this: jsOFD, gs: GState): jsOFD;
679
+ /** Set the rendering opacity for subsequent objects (0-1). */
680
+ setOpacity(this: jsOFD, opacity: number): jsOFD;
681
+ };
682
+ type StateApi = typeof StateApi;
683
+ declare module '../jsofd' {
684
+ interface jsOFD extends StateApi {
685
+ }
686
+ }
687
+
688
+ /**
689
+ * `doc.svg()` — embed an SVG by rasterizing it through the browser canvas.
690
+ *
691
+ * The SVG is loaded into an `Image` via a blob URL, drawn to a canvas at a
692
+ * 2× device scale for crispness, and embedded as PNG. Requires a browser
693
+ * (jsPDF's `addSvgAsImage` has the same constraint); Node throws a clear
694
+ * error suggesting pre-rasterized bytes via `addImage`.
695
+ */
696
+
697
+ interface SvgOptions {
698
+ x: number;
699
+ y: number;
700
+ /** Width (active unit); defaults to the intrinsic size at 72dpi */
701
+ w?: number;
702
+ /** Height (active unit); defaults to w scaled by the viewBox ratio */
703
+ h?: number;
704
+ /** Raster scale factor (default 2 — retina-crisp) */
705
+ scale?: number;
706
+ rotation?: number;
707
+ opacity?: number;
708
+ /** Background color painted behind transparent areas (CSS color) */
709
+ background?: string;
710
+ }
711
+ declare const SvgApi: {
712
+ /**
713
+ * Rasterize an SVG markup string and embed it as a PNG image.
714
+ *
715
+ * Browser only (uses `Image` + canvas). The SVG is rendered at `scale`
716
+ * (default 2×) for crisp output. Use `addImage` when you already have
717
+ * raster bytes.
718
+ */
719
+ svg(this: jsOFD, svgMarkup: string, options: SvgOptions): Promise<void>;
720
+ };
721
+ type SvgApi = typeof SvgApi;
722
+ declare module '../jsofd' {
723
+ interface jsOFD extends SvgApi {
724
+ }
725
+ }
726
+
727
+ /**
728
+ * `doc.table()` — a lightweight table engine in the spirit of jspdf-autotable:
729
+ * grid lines, header row with fill, per-column width/align, zebra striping and
730
+ * automatic pagination with a repeated header.
731
+ *
732
+ * All internal computation uses points (the model unit); public inputs and the
733
+ * return value use the active unit.
734
+ */
735
+
736
+ interface TableColumn {
737
+ /** Header caption */
738
+ header?: string;
739
+ /** Column width (active unit); omitted columns share the remaining width */
740
+ width?: number;
741
+ /** Cell text alignment (default 'left') */
742
+ align?: 'left' | 'center' | 'right';
743
+ }
744
+ interface TableCell {
745
+ text: string;
746
+ bold?: boolean;
747
+ align?: TableColumn['align'];
748
+ /** Horizontal span (skip the covered cells in the row data) */
749
+ colSpan?: number;
750
+ }
751
+ type TableCellInput = string | TableCell;
752
+ interface TableStyle {
753
+ /** Body font size (pt) */
754
+ fontSize?: number;
755
+ /** Header font size (pt); defaults to fontSize */
756
+ headFontSize?: number;
757
+ /** Header fill; null disables the fill (default: blue) */
758
+ headFill?: RGB | null;
759
+ /** Header text color (default white) */
760
+ headColor?: RGB;
761
+ /** Body text color (default: current text color) */
762
+ textColor?: RGB;
763
+ /** Grid line color (default light gray); null disables all grid lines */
764
+ borderColor?: RGB | null;
765
+ /** Grid line width (active unit, default 0.2) */
766
+ lineWidth?: number;
767
+ /** Cell padding (active unit, default 2) */
768
+ cellPadding?: number;
769
+ /** Fixed row height (active unit); default: fits the tallest cell */
770
+ rowHeight?: number;
771
+ /** Alternating [even, odd] row fills; enables zebra striping */
772
+ zebra?: [RGB, RGB] | null;
773
+ }
774
+ interface TableOptions {
775
+ columns: TableColumn[];
776
+ rows?: TableCellInput[][];
777
+ style?: TableStyle;
778
+ /** Append pages as needed, repeating the header row (default true) */
779
+ autoPage?: boolean;
780
+ /** Page margin of the flow area when autoPage (active unit, default 20) */
781
+ bottomMargin?: number;
782
+ /** Called after each automatic page break */
783
+ onNewPage?: (doc: jsOFD, info: {
784
+ pageNumber: number;
785
+ pageCount: number;
786
+ }) => void;
787
+ }
788
+ declare const TableApi: {
789
+ /**
790
+ * Render a table at `(x, y)` and return the bottom Y (active unit).
791
+ *
792
+ * Column widths: explicit `width`, otherwise the remaining page width is
793
+ * shared equally. With `autoPage` (default) rows that would cross the
794
+ * bottom margin continue on a fresh page under a repeated header.
795
+ */
796
+ table(this: jsOFD, x: number, y: number, options: TableOptions): number;
797
+ };
798
+ type TableApi = typeof TableApi;
799
+ declare module '../jsofd' {
800
+ interface jsOFD extends TableApi {
801
+ }
802
+ }
803
+
804
+ /** Text layout and rendering: measurement, line breaking and `text()`. */
805
+
806
+ declare const TextApi: {
807
+ /**
808
+ * Measure the width of `text` in points for an explicit font and size.
809
+ *
810
+ * Exposed publicly because jsPDF relies on `doc.measure`-style hooks for
811
+ * plugins such as autotable.
812
+ */
813
+ measure(this: jsOFD, text: string, fontDef: FontDef, style: FontStyle, sizePt: number, charSpacePt: number): number;
814
+ /** String width in font units (jsPDF `getStringUnitWidth`). */
815
+ getStringUnitWidth(this: jsOFD, text: string): number;
816
+ /**
817
+ * Per-character widths in points (jsPDF `getCharWidthsArray`).
818
+ *
819
+ * @param options override `fontSize` (default: active) and `charSpace`
820
+ */
821
+ getCharWidthsArray(this: jsOFD, text: string, options?: {
822
+ fontSize?: number;
823
+ charSpace?: number;
824
+ }): number[];
825
+ /** Width of `text` at the active font and size, in the active unit. */
826
+ getTextWidth(this: jsOFD, text: string): number;
827
+ /** Split `text` into lines that fit `maxWidth` (active unit). */
828
+ splitTextToSize(this: jsOFD, text: string, maxWidth: number): string[];
829
+ /**
830
+ * Line-breaking core.
831
+ *
832
+ * Breaks Latin text at spaces, CJK text between any two characters, and
833
+ * hard-splits words longer than the line width (jsPDF behaviour).
834
+ *
835
+ * @internal maxWidthPt is in points
836
+ */
837
+ _splitCore(this: jsOFD, text: string, maxWidthPt: number, fontDef: FontDef, style: FontStyle): string[];
838
+ /**
839
+ * Write text at `(x, y)`.
840
+ *
841
+ * The anchor is the left end of the baseline unless changed through the
842
+ * `baseline` option. Multi-line input is accepted as `\n` separated text
843
+ * or an array of lines; `maxWidth` enables automatic wrapping.
844
+ *
845
+ * Supports the legacy jsPDF argument order `text(x, y, text, options)`.
846
+ */
847
+ text(this: jsOFD, text: string | string[] | number, x: number | string | string[], y: number | string | TextOptions, optionsOrNothing?: TextOptions): jsOFD;
848
+ /**
849
+ * Write text wrapped in a clickable link annotation.
850
+ *
851
+ * Pass `url` for an external target or `pageNumber` for an in-document jump.
852
+ */
853
+ textWithLink(this: jsOFD, text: string, x: number, y: number, options?: TextOptions & LinkOptions): jsOFD;
854
+ };
855
+ /** Structural type of the mixin (merged into jsOFD via declaration merging). */
856
+ type TextApi = typeof TextApi;
857
+ declare module '../jsofd' {
858
+ interface jsOFD extends TextApi {
859
+ }
860
+ }
861
+
862
+ /**
863
+ * Dependency-free ZIP writer (STORE method).
864
+ *
865
+ * An OFD package is a ZIP container; stored (uncompressed) entries are accepted by every
866
+ * unzip implementation and keep output() synchronous. OFD.xml is written as the first entry.
867
+ */
868
+ interface ZipEntry {
869
+ name: string;
870
+ data: Uint8Array;
871
+ }
872
+
873
+ declare const ViewApi: {
874
+ /** Set document metadata (title, subject, author, keywords, creator). */
875
+ setProperties(this: jsOFD, properties: DocProperties): jsOFD;
876
+ /** Override the document creation date. */
877
+ setCreationDate(this: jsOFD, date: Date | string | number): jsOFD;
878
+ /**
879
+ * Read the creation date.
880
+ *
881
+ * @param type `'array'` returns `[y, m, d, h, min, s]`; anything else
882
+ * returns a `Date` (jsPDF `'jsDate'` semantics)
883
+ */
884
+ getCreationDate(this: jsOFD, type?: "jsDate" | "array"): Date | number[];
885
+ /**
886
+ * Configure the initial viewer presentation.
887
+ *
888
+ * @param zoom numeric multiplier, `'N%'`, or `'fullwidth'` /
889
+ * `'fullheight'` / `'fullpage'` / `'original'`
890
+ * @param layout `'continuous'` / `'single'` / `'twoleft'` / `'tworight'` / `'two'`
891
+ * @param pageMode `'UseNone'` / `'UseOutlines'` / `'UseThumbs'` / `'FullScreen'`
892
+ * @throws on unrecognized values, mirroring jsPDF
893
+ */
894
+ setDisplayMode(this: jsOFD, zoom?: number | string, layout?: "continuous" | "single" | "twoleft" | "tworight" | "two" | string, pageMode?: string): jsOFD;
895
+ /**
896
+ * Set reader interface preferences.
897
+ *
898
+ * Supported flags: `HideToolbar`, `HideMenubar`, `HideWindowUI`, `FitWindow`.
899
+ * Pass `doReset` to clear previously set flags first.
900
+ */
901
+ viewerPreferences(this: jsOFD, options: ViewerPreferences, doReset?: boolean): jsOFD;
902
+ /**
903
+ * Register a total-page-count placeholder (jsPDF `putTotalPages`).
904
+ *
905
+ * At output time every occurrence of `pageIndicator` in text objects is
906
+ * replaced with the page count.
907
+ */
908
+ putTotalPages(this: jsOFD, pageIndicator?: string): jsOFD;
909
+ /** API-compatibility no-op (OFD carries no language field). */
910
+ setLanguage(this: jsOFD): jsOFD;
911
+ /**
912
+ * @internal Serialize to OFD ZIP entries (`OFD.xml` first).
913
+ *
914
+ * Applies the `putTotalPages` substitution on a copy, leaving the live
915
+ * document untouched so `output()` stays repeatable.
916
+ */
917
+ _buildFiles(this: jsOFD): ZipEntry[];
918
+ /**
919
+ * Serialize the document.
920
+ *
921
+ * @param type `'arraybuffer'` (default) / `'uint8array'` / `'blob'` /
922
+ * `'dataurlstring'` / `'dataurlnewwindow'` / `'binarystring'` /
923
+ * `'bloburl'`
924
+ */
925
+ output(this: jsOFD, type?: string): OutputResult;
926
+ /** Shorthand for `output('dataurlstring')`. */
927
+ getDataUrl(this: jsOFD): string;
928
+ /**
929
+ * Save the document to a file.
930
+ *
931
+ * Browser: triggers a download. Node (CJS): writes into the working
932
+ * directory. Node ESM has no synchronous `require` — use
933
+ * `output('arraybuffer')` and write the bytes yourself.
934
+ */
935
+ save(this: jsOFD, filename?: string): jsOFD;
936
+ };
937
+ type ViewApi = typeof ViewApi;
938
+ declare module '../jsofd' {
939
+ interface jsOFD extends ViewApi {
940
+ }
941
+ }
942
+
943
+ /**
944
+ * jsOFD document class.
945
+ *
946
+ * The public API mirrors jsPDF while the serialized output follows the Chinese
947
+ * national fixed-layout document standard GB/T 33190-2016 (OFD).
948
+ *
949
+ * This module holds document state, the constructor, page management and the
950
+ * graphics-state helpers. Feature methods are contributed by the mixins in
951
+ * `src/modules/` and merged onto the prototype at the bottom of this file:
952
+ *
953
+ * - {@link modules/state.ts} fonts, colors, metrics, graphics state
954
+ * - {@link modules/text.ts} measurement, line breaking, `text()`
955
+ * - {@link modules/shapes.ts} vector primitives
956
+ * - {@link modules/images.ts} image embedding
957
+ * - {@link modules/annotations.ts} links and attachments
958
+ * - {@link modules/view.ts} metadata, viewer preferences, output
959
+ */
960
+
961
+ type OrientationResolved = 'p' | 'l';
962
+ declare class jsOFD {
963
+ #private;
964
+ /** Active measurement unit. */
965
+ readonly unit: string;
966
+ /** Unit → point scale factor (jsPDF-compatible `internal.scaleFactor`). */
967
+ readonly scaleFactor: number;
968
+ /** Decimal places used when serializing numbers. */
969
+ readonly floatPrecision: number;
970
+ /** @internal Default orientation for `addPage()` without arguments. */
971
+ readonly defaultOrientation: OrientationResolved;
972
+ /** Pages in the document (internal coordinates are points). */
973
+ pages: PageData[];
974
+ /** Zero-based index of the current page. */
975
+ page: number;
976
+ /** User-registered fonts. */
977
+ customFonts: Record<string, FontDef>;
978
+ /** Image resources, keyed by alias, plus insertion order. */
979
+ images: Record<string, ImageRun['imageRef']>;
980
+ imageList: ImageRun['imageRef'][];
981
+ /** Embedded file attachments. */
982
+ attachments: AttachmentData[];
983
+ /** Bookmark tree root. */
984
+ outlineRoot: {
985
+ children: OutlineNode[];
986
+ };
987
+ /** Document metadata (see `setProperties`). */
988
+ properties: {
989
+ title: string;
990
+ subject: string;
991
+ author: string;
992
+ keywords: string;
993
+ creator: string;
994
+ creatorVersion: string;
995
+ };
996
+ /** Random document identifier. */
997
+ docID: string;
998
+ creationDate: Date;
999
+ modDate: Date | null;
1000
+ displayMode: {
1001
+ zoom: number | string;
1002
+ layout: string;
1003
+ pageMode?: string;
1004
+ } | null;
1005
+ viewerPrefs: Record<string, boolean>;
1006
+ /** Placeholder (e.g. `{total}`) replaced at output time, see `putTotalPages`. */
1007
+ totalPagesPattern: string | null;
1008
+ activeFontKey: string;
1009
+ activeFontStyle: 'normal' | 'bold' | 'italic' | 'bolditalic';
1010
+ /** Font size in points. Like jsPDF, the size is always in pt regardless of unit. */
1011
+ fontSize: number;
1012
+ textColor: RGB;
1013
+ drawColor: RGB;
1014
+ fillColor: RGB;
1015
+ lineWidth: number;
1016
+ lineDash: {
1017
+ pattern: number[];
1018
+ phase: number;
1019
+ } | null;
1020
+ lineCap: number;
1021
+ lineJoin: number;
1022
+ /** Miter limit in points; 0 omits the attribute. */
1023
+ miterLimit: number;
1024
+ charSpace: number;
1025
+ lineHeightFactor: number;
1026
+ opacity: number | null;
1027
+ r2l: boolean;
1028
+ /** @internal Paper format used by `addPage()` without arguments. */
1029
+ _lastFormat: PageFormat;
1030
+ /** jsPDF-style introspection surface. */
1031
+ readonly internal: {
1032
+ version: string;
1033
+ scaleFactor: number;
1034
+ pageSize: {
1035
+ getWidth(): number;
1036
+ getHeight(): number;
1037
+ };
1038
+ numberOfPages: number;
1039
+ pages: PageData[];
1040
+ getFileId(): string;
1041
+ };
1042
+ /** Bookmark API: `doc.outline.add(parent, title, options)`. */
1043
+ readonly outline: {
1044
+ add(parent: OutlineNode | null, title: string, options?: OutlineOptions): OutlineNode;
1045
+ };
1046
+ /**
1047
+ * Canvas-style drawing context (subset of `CanvasRenderingContext2D`).
1048
+ * Draw calls land on the current page as vector objects.
1049
+ */
1050
+ get context2d(): CanvasRenderingContext2D;
1051
+ constructor(options?: jsOFDOptions | Orientation | string, unitArg?: string, formatArg?: PageFormat);
1052
+ /** @internal Resolve a named or `[w, h]` format to a pt size pair. */
1053
+ _resolveFormat(format: PageFormat, orientation: OrientationResolved): [number, number];
1054
+ /** @internal Convert a coordinate in the active unit to points. */
1055
+ _u(v: number): number;
1056
+ /** @internal Append a page sized in points and make it current. */
1057
+ _addPageWithSize(wPt: number, hPt: number): this;
1058
+ /** Append a page, optionally with a different format and orientation. */
1059
+ addPage(format?: PageFormat, orientation?: string): this;
1060
+ /** Switch to a one-based page number. */
1061
+ setPage(n: number): this;
1062
+ /** Insert an empty page before the given one-based position. */
1063
+ insertPage(beforePage?: number): this;
1064
+ /** Move a page (default: the current one) to before another position. */
1065
+ movePage(targetPage?: number, beforePage?: number): this;
1066
+ /** Delete a page (the last page is replaced by an empty one). */
1067
+ deletePage(target?: number): this;
1068
+ /** Number of pages in the document. */
1069
+ getNumberOfPages(): number;
1070
+ /** Width of the current page in the active unit. */
1071
+ getPageWidth(): number;
1072
+ /** Height of the current page in the active unit. */
1073
+ getPageHeight(): number;
1074
+ }
1075
+
1076
+ /**
1077
+ * PDF to OFD conversion by replaying the pdfjs-dist operator list.
1078
+ *
1079
+ * Converts: text (position, size, color, weight/style, advances per glyph),
1080
+ * fonts (embedded font files are carried over and embedded into the OFD),
1081
+ * vector paths (lines, rectangles, Bezier, fills, strokes, dashes, caps,
1082
+ * miter), raster images (RGB/RGBA/grayscale re-encoded as PNG), opacity,
1083
+ * multiple pages and page rotation.
1084
+ *
1085
+ * Not converted: clipping paths, blend modes, pattern and shading fills,
1086
+ * Type 3 fonts, and annotations.
1087
+ *
1088
+ * Usage: `const doc = await pdfToOfd(pdfBytes); doc.save("out.ofd");`
1089
+ */
1090
+
1091
+ interface PdfImgData {
1092
+ width: number;
1093
+ height: number;
1094
+ kind?: number;
1095
+ data: Uint8Array | Uint8ClampedArray;
1096
+ bitmap?: unknown;
1097
+ }
1098
+ /** @internal Exposed for tests. */
1099
+ declare function imgDataToPng(img: PdfImgData): Promise<Uint8Array | null>;
1100
+ /** pdfjs extras (browsers should pass workerSrc / standardFontDataUrl). */
1101
+ interface PdfToOfdOptions {
1102
+ /** Page size scale (default 1; output unit is pt). */
1103
+ scale?: number;
1104
+ /** Progress callback (0-based page index). */
1105
+ onProgress?: (pageIndex: number, totalPages: number) => void;
1106
+ /** pdfjs worker URL (recommended in browsers, e.g. a CDN pdf.worker.min.mjs). */
1107
+ workerSrc?: string;
1108
+ /** Standard-font data directory (optional; silences Base14 warnings). */
1109
+ standardFontDataUrl?: string;
1110
+ /** CMap directory (required for CJK CID fonts; auto-detected in Node). */
1111
+ cMapUrl?: string;
1112
+ cMapPacked?: boolean;
1113
+ }
1114
+ /** Globally configure pdfjs worker/font asset URLs (browsers). */
1115
+ declare function configurePdfImport(opts: {
1116
+ workerSrc?: string;
1117
+ standardFontDataUrl?: string;
1118
+ cMapUrl?: string;
1119
+ }): void;
1120
+ declare function pdfToOfd(data: Uint8Array | ArrayBuffer, options?: PdfToOfdOptions): Promise<jsOFD>;
1121
+
1122
+ export { type PdfToOfdOptions, configurePdfImport, imgDataToPng, pdfToOfd };