@docmentis/udoc-viewer 0.6.42 → 0.6.43

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.
@@ -1,76 +1,57 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Markup metadata for JavaScript serialization (author, subject, contents, state).
4
+ * A contiguous group of pages sharing a stitching layout.
5
+ *
6
+ * Viewers build one stitched canvas per group (e.g., one panel per Excel
7
+ * sheet). Per-page `tilePos` values on `JsPageInfo` are local coordinates
8
+ * within the group.
5
9
  */
6
- export interface JsMarkupMetadata {
7
- author?: string;
8
- subject?: string;
9
- contents?: string;
10
+ export interface JsPageGroup {
10
11
  /**
11
- * Annotation state (e.g., \"Accepted\", \"Rejected\", \"Completed\", \"Marked\").
12
+ * Display label (sheet name for XLSX). Absent for unnamed linear groups.
12
13
  */
13
- state?: string;
14
+ name?: string;
14
15
  /**
15
- * State model (e.g., \"Review\" or \"Marked\").
16
+ * Global index of the first page in the group.
16
17
  */
17
- stateModel?: string;
18
- creationDate?: string;
18
+ startPageIndex: number;
19
19
  /**
20
- * Reply type: \"reply\" or \"group\".
20
+ * Number of pages in the group.
21
21
  */
22
- replyType?: string;
23
- intent?: string;
24
- richContents?: string;
25
- }
26
-
27
- /**
28
- * Rectangle for JavaScript serialization.
29
- */
30
- export interface JsRect {
31
- x: number;
32
- y: number;
33
- width: number;
34
- height: number;
35
- }
36
-
37
- /**
38
- * RGB color for JavaScript serialization (values 0.0-1.0).
39
- */
40
- export interface JsColor {
41
- r: number;
42
- g: number;
43
- b: number;
22
+ pageCount: number;
23
+ /**
24
+ * Stitching layout (discriminated union tagged by `type`).
25
+ */
26
+ layout: JsPageGroupLayout;
44
27
  }
45
28
 
46
29
  /**
47
- * Link action for JavaScript serialization.
48
- */
49
- export type JsLinkAction = { actionType: "goTo"; destination: JsDestination } | { actionType: "uri"; uri: string };
50
-
51
- /**
52
- * Quadrilateral for JavaScript serialization (used in text markup annotations).
30
+ * A pick specification from JavaScript.
53
31
  */
54
- export interface JsQuad {
32
+ export interface JsPick {
55
33
  /**
56
- * Four corner points: [bottom-left, bottom-right, top-right, top-left]
34
+ * Document index (0-based, referring to documents in doc_ids array)
57
35
  */
58
- points: [JsPoint, JsPoint, JsPoint, JsPoint];
36
+ doc: number;
37
+ /**
38
+ * Page range string (0-based, e.g., \"0-2,4\")
39
+ */
40
+ pages: string;
41
+ /**
42
+ * Optional rotation in degrees (0, 90, 180, or 270)
43
+ */
44
+ rotation: number | undefined;
59
45
  }
60
46
 
61
47
  /**
62
- * Annotation type for JavaScript serialization.
63
- */
64
- export type JsAnnotationType = { type: "link"; action: JsLinkAction } | { type: "highlight"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "underline"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "strikeOut"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "squiggly"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "text"; icon: string; open: boolean; color?: JsColor; opacity?: number } | { type: "freeText"; contents?: string; justification: string; defaultAppearance?: string; color?: JsColor; borderColor?: JsColor; calloutLine?: JsPoint[]; opacity?: number; defaultStyle?: string; lineEnding?: string; rectDifferences?: JsRectDifferences } | { type: "stamp"; name?: string; hasCustomAppearance: boolean; color?: JsColor; opacity?: number } | { type: "line"; start: JsPoint; end: JsPoint; startEnding: string; endEnding: string; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number; leaderLength?: number; leaderExtension?: number; leaderOffset?: number; caption?: boolean; captionPosition?: string; captionOffset?: [number, number] } | { type: "square"; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number; rectDifferences?: JsRectDifferences } | { type: "circle"; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number; rectDifferences?: JsRectDifferences } | { type: "polygon"; vertices: JsPoint[]; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; startEnding: string; endEnding: string; opacity?: number } | { type: "polyLine"; vertices: JsPoint[]; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; startEnding: string; endEnding: string; opacity?: number } | { type: "ink"; inkList: JsPoint[][]; color?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number } | { type: "caret"; symbol: string; color?: JsColor; opacity?: number; rectDifferences?: JsRectDifferences } | { type: "redact"; quads: JsQuad[]; interiorColor?: JsColor; overlayText?: string; justification: string; repeat: boolean; color?: JsColor; opacity?: number; defaultAppearance?: string };
65
-
66
- /**
67
- * Rectangle differences for JavaScript serialization.
48
+ * A simple rectangle for serialization to JavaScript.
68
49
  */
69
- export interface JsRectDifferences {
70
- left: number;
71
- bottom: number;
72
- right: number;
73
- top: number;
50
+ export interface JsRect {
51
+ x: number;
52
+ y: number;
53
+ width: number;
54
+ height: number;
74
55
  }
75
56
 
76
57
  /**
@@ -101,33 +82,47 @@ export interface JsAnnotation extends JsAnnotationType {
101
82
  }
102
83
 
103
84
  /**
104
- * Point for JavaScript serialization.
85
+ * Annotation type for JavaScript serialization.
105
86
  */
106
- export interface JsPoint {
107
- x: number;
108
- y: number;
109
- }
87
+ export type JsAnnotationType = { type: "link"; action: JsLinkAction } | { type: "highlight"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "underline"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "strikeOut"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "squiggly"; quads: JsQuad[]; color?: JsColor; opacity?: number } | { type: "text"; icon: string; open: boolean; color?: JsColor; opacity?: number } | { type: "freeText"; contents?: string; justification: string; defaultAppearance?: string; color?: JsColor; borderColor?: JsColor; calloutLine?: JsPoint[]; opacity?: number; defaultStyle?: string; lineEnding?: string; rectDifferences?: JsRectDifferences } | { type: "stamp"; name?: string; hasCustomAppearance: boolean; color?: JsColor; opacity?: number } | { type: "line"; start: JsPoint; end: JsPoint; startEnding: string; endEnding: string; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number; leaderLength?: number; leaderExtension?: number; leaderOffset?: number; caption?: boolean; captionPosition?: string; captionOffset?: [number, number] } | { type: "square"; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number; rectDifferences?: JsRectDifferences } | { type: "circle"; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number; rectDifferences?: JsRectDifferences } | { type: "polygon"; vertices: JsPoint[]; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; startEnding: string; endEnding: string; opacity?: number } | { type: "polyLine"; vertices: JsPoint[]; color?: JsColor; interiorColor?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; startEnding: string; endEnding: string; opacity?: number } | { type: "ink"; inkList: JsPoint[][]; color?: JsColor; borderWidth?: number; borderStyle: string; dashPattern?: number[]; opacity?: number } | { type: "caret"; symbol: string; color?: JsColor; opacity?: number; rectDifferences?: JsRectDifferences } | { type: "redact"; quads: JsQuad[]; interiorColor?: JsColor; overlayText?: string; justification: string; repeat: boolean; color?: JsColor; opacity?: number; defaultAppearance?: string };
110
88
 
111
- export type JsViewerScrollMode = "spread" | "continuous";
89
+ /**
90
+ * Annotations grouped by page index (as string keys).
91
+ */
92
+ export type JsAnnotationsByPage = Record<string, JsAnnotation[]>;
112
93
 
113
- export interface JsViewerPreferences {
114
- layoutMode?: JsViewerLayoutMode;
115
- scrollMode?: JsViewerScrollMode;
116
- }
94
+ /**
95
+ * Destination display parameters for JavaScript serialization.
96
+ */
97
+ export type JsDestinationDisplay = { type: "xyz"; left: number | undefined; top: number | undefined; zoom: number | undefined } | { type: "fit" } | { type: "fitH"; top: number | undefined } | { type: "fitV"; left: number | undefined } | { type: "fitR"; left: number; top: number; right: number; bottom: number } | { type: "fitB" } | { type: "fitBH"; top: number | undefined } | { type: "fitBV"; left: number | undefined };
117
98
 
118
- export type JsViewerLayoutMode = "single-page" | "double-page-odd-right" | "double-page-odd-left";
99
+ /**
100
+ * Destination for JavaScript serialization.
101
+ */
102
+ export interface JsDestination {
103
+ pageIndex: number;
104
+ display: JsDestinationDisplay;
105
+ }
119
106
 
120
107
  /**
121
- * Stitching layout of a `JsPageGroup` (discriminated union tagged by `type`).
108
+ * Extracted font info for JavaScript.
122
109
  */
123
- export type JsPageGroupLayout = { type: "linear" } | { type: "tiled"; rows: number; cols: number };
110
+ export interface JsExtractedFont {
111
+ name: string;
112
+ fontType: string;
113
+ extension: string;
114
+ data: number[];
115
+ }
124
116
 
125
117
  /**
126
- * Outline section info for split_by_outline results.
118
+ * Extracted image info for JavaScript.
127
119
  */
128
- export interface JsOutlineSection {
129
- title: string;
130
- index: number;
120
+ export interface JsExtractedImage {
121
+ name: string;
122
+ format: string;
123
+ width: number | undefined;
124
+ height: number | undefined;
125
+ data: number[];
131
126
  }
132
127
 
133
128
  /**
@@ -139,45 +134,89 @@ export interface JsParsedFontInfo {
139
134
  italic: boolean;
140
135
  }
141
136
 
142
- export type JsCornerDirection = "leftUp" | "rightUp" | "leftDown" | "rightDown";
143
-
144
- export type JsMorphOption = "byObject" | "byWord" | "byChar";
137
+ /**
138
+ * Font registration entry from JavaScript.
139
+ */
140
+ export interface JsFontRegistration {
141
+ typeface: string;
142
+ bold: boolean;
143
+ italic: boolean;
144
+ url: string;
145
+ }
145
146
 
146
- export type JsInOutDirection = "in" | "out";
147
+ /**
148
+ * Font source for JavaScript serialization.
149
+ */
150
+ export type JsFontSource = "embedded" | "standard" | "googleFonts" | "url" | "local" | { custom: string };
147
151
 
148
- export type JsOrientation = "horizontal" | "vertical";
152
+ /**
153
+ * Font spec for JavaScript serialization.
154
+ */
155
+ export type JsFontSpec = { typeface: string; bold: boolean; italic: boolean } | { fontId: string };
149
156
 
150
157
  /**
151
- * Extracted image info for JavaScript.
158
+ * Font usage entry for JavaScript serialization.
152
159
  */
153
- export interface JsExtractedImage {
154
- name: string;
155
- format: string;
156
- width: number | undefined;
157
- height: number | undefined;
158
- data: number[];
160
+ export interface JsFontUsageEntry {
161
+ spec: JsFontSpec;
162
+ resolved: JsResolvedFontInfo;
163
+ fallbacks: JsResolvedFontInfo[];
159
164
  }
160
165
 
161
- export type JsEightDirection = "left" | "right" | "up" | "down" | "leftUp" | "rightUp" | "leftDown" | "rightDown";
162
-
163
- export type JsShredPattern = "strip" | "rectangle";
166
+ /**
167
+ * Link action for JavaScript serialization.
168
+ */
169
+ export type JsLinkAction = { actionType: "goTo"; destination: JsDestination } | { actionType: "uri"; uri: string };
164
170
 
165
171
  /**
166
- * A pick specification from JavaScript.
172
+ * Markup metadata for JavaScript serialization (author, subject, contents, state).
167
173
  */
168
- export interface JsPick {
174
+ export interface JsMarkupMetadata {
175
+ author?: string;
176
+ subject?: string;
177
+ contents?: string;
169
178
  /**
170
- * Document index (0-based, referring to documents in doc_ids array)
179
+ * Annotation state (e.g., \"Accepted\", \"Rejected\", \"Completed\", \"Marked\").
171
180
  */
172
- doc: number;
181
+ state?: string;
173
182
  /**
174
- * Page range string (0-based, e.g., \"0-2,4\")
183
+ * State model (e.g., \"Review\" or \"Marked\").
175
184
  */
176
- pages: string;
185
+ stateModel?: string;
186
+ creationDate?: string;
177
187
  /**
178
- * Optional rotation in degrees (0, 90, 180, or 270)
188
+ * Reply type: \"reply\" or \"group\".
179
189
  */
180
- rotation: number | undefined;
190
+ replyType?: string;
191
+ intent?: string;
192
+ richContents?: string;
193
+ }
194
+
195
+ /**
196
+ * Nested `Vec<Vec<T>>` can\'t cross the WASM boundary directly, so we use a
197
+ * transparent Tsify wrapper.
198
+ */
199
+ export type JsCompositions = JsPick[][];
200
+
201
+ /**
202
+ * Outline item for JavaScript serialization.
203
+ */
204
+ export interface JsOutlineItem {
205
+ title: string;
206
+ destination?: JsDestination;
207
+ children: JsOutlineItem[];
208
+ /**
209
+ * Whether this item should be initially collapsed in the viewer.
210
+ */
211
+ initiallyCollapsed: boolean;
212
+ }
213
+
214
+ /**
215
+ * Outline section info for split_by_outline results.
216
+ */
217
+ export interface JsOutlineSection {
218
+ title: string;
219
+ index: number;
181
220
  }
182
221
 
183
222
  /**
@@ -207,35 +246,75 @@ export interface JsPageInfo {
207
246
  }
208
247
 
209
248
  /**
210
- * Extracted font info for JavaScript.
249
+ * Page transition info for serialization to JavaScript.
250
+ *
251
+ * The `effect` field is a discriminated union tagged by `type`, e.g.:
252
+ * `{ effect: { type: \"fade\", throughBlack: true }, durationMs: 500 }`
211
253
  */
212
- export interface JsExtractedFont {
213
- name: string;
214
- fontType: string;
215
- extension: string;
216
- data: number[];
254
+ export interface JsPageTransition {
255
+ /**
256
+ * The visual transition effect (discriminated union tagged by `type`).
257
+ */
258
+ effect: JsTransitionEffect;
259
+ /**
260
+ * Duration of the transition animation in milliseconds.
261
+ */
262
+ durationMs?: number;
263
+ /**
264
+ * Whether clicking advances to the next page.
265
+ */
266
+ advanceOnClick?: boolean;
267
+ /**
268
+ * Auto-advance after this many milliseconds.
269
+ */
270
+ advanceAfterMs?: number;
217
271
  }
218
272
 
219
273
  /**
220
- * Font usage entry for JavaScript serialization.
274
+ * Point for JavaScript serialization.
221
275
  */
222
- export interface JsFontUsageEntry {
223
- spec: JsFontSpec;
224
- resolved: JsResolvedFontInfo;
225
- fallbacks: JsResolvedFontInfo[];
276
+ export interface JsPoint {
277
+ x: number;
278
+ y: number;
226
279
  }
227
280
 
228
281
  /**
229
- * Font source for JavaScript serialization.
282
+ * Quadrilateral for JavaScript serialization (used in text markup annotations).
230
283
  */
231
- export type JsFontSource = "embedded" | "standard" | "googleFonts" | "url" | "local" | { custom: string };
284
+ export interface JsQuad {
285
+ /**
286
+ * Four corner points: [bottom-left, bottom-right, top-right, top-left]
287
+ */
288
+ points: [JsPoint, JsPoint, JsPoint, JsPoint];
289
+ }
232
290
 
233
291
  /**
234
- * Tile position in a 2D page grid.
292
+ * RGB color for JavaScript serialization (values 0.0-1.0).
235
293
  */
236
- export interface JsTilePos {
237
- row: number;
238
- col: number;
294
+ export interface JsColor {
295
+ r: number;
296
+ g: number;
297
+ b: number;
298
+ }
299
+
300
+ /**
301
+ * Rectangle differences for JavaScript serialization.
302
+ */
303
+ export interface JsRectDifferences {
304
+ left: number;
305
+ bottom: number;
306
+ right: number;
307
+ top: number;
308
+ }
309
+
310
+ /**
311
+ * Rectangle for JavaScript serialization.
312
+ */
313
+ export interface JsRect {
314
+ x: number;
315
+ y: number;
316
+ width: number;
317
+ height: number;
239
318
  }
240
319
 
241
320
  /**
@@ -249,107 +328,63 @@ export interface JsResolvedFontInfo {
249
328
  italic: boolean;
250
329
  }
251
330
 
252
- export type JsGlitterPattern = "diamond" | "hexagon";
253
-
254
- /**
255
- * Font spec for JavaScript serialization.
256
- */
257
- export type JsFontSpec = { typeface: string; bold: boolean; italic: boolean } | { fontId: string };
258
-
259
331
  /**
260
- * A simple rectangle for serialization to JavaScript.
332
+ * Result from pdf_split_by_outline.
261
333
  */
262
- export interface JsRect {
263
- x: number;
264
- y: number;
265
- width: number;
266
- height: number;
334
+ export interface JsSplitByOutlineResult {
335
+ documentIds: string[];
336
+ sections: JsOutlineSection[];
267
337
  }
268
338
 
269
339
  /**
270
- * A contiguous group of pages sharing a stitching layout.
271
- *
272
- * Viewers build one stitched canvas per group (e.g., one panel per Excel
273
- * sheet). Per-page `tilePos` values on `JsPageInfo` are local coordinates
274
- * within the group.
340
+ * Result returned to JavaScript after license validation.
275
341
  */
276
- export interface JsPageGroup {
342
+ export interface LicenseResult {
277
343
  /**
278
- * Display label (sheet name for XLSX). Absent for unnamed linear groups.
344
+ * Whether the license is valid.
279
345
  */
280
- name?: string;
346
+ valid: boolean;
281
347
  /**
282
- * Global index of the first page in the group.
348
+ * Error message if validation failed.
283
349
  */
284
- startPageIndex: number;
350
+ error?: string;
285
351
  /**
286
- * Number of pages in the group.
352
+ * Enabled features.
287
353
  */
288
- pageCount: number;
354
+ features: string[];
289
355
  /**
290
- * Stitching layout (discriminated union tagged by `type`).
356
+ * Numeric limits.
291
357
  */
292
- layout: JsPageGroupLayout;
293
- }
294
-
295
- /**
296
- * Annotations grouped by page index (as string keys).
297
- */
298
- export type JsAnnotationsByPage = Record<string, JsAnnotation[]>;
299
-
300
- /**
301
- * Visibility group info for serialization to JavaScript.
302
- */
303
- export interface JsVisibilityGroup {
304
- id: string;
305
- name: string;
306
- visible: boolean;
307
- locked: boolean;
308
- }
309
-
310
- export type JsRippleDirection = "center" | "leftUp" | "rightUp" | "leftDown" | "rightDown";
311
-
312
- export type JsSideDirection = "left" | "right" | "up" | "down";
313
-
314
- /**
315
- * Nested `Vec<Vec<T>>` can\'t cross the WASM boundary directly, so we use a
316
- * transparent Tsify wrapper.
317
- */
318
- export type JsCompositions = JsPick[][];
319
-
320
- /**
321
- * Page transition info for serialization to JavaScript.
322
- *
323
- * The `effect` field is a discriminated union tagged by `type`, e.g.:
324
- * `{ effect: { type: \"fade\", throughBlack: true }, durationMs: 500 }`
325
- */
326
- export interface JsPageTransition {
358
+ limits: Record<string, number>;
327
359
  /**
328
- * The visual transition effect (discriminated union tagged by `type`).
360
+ * Organization name.
329
361
  */
330
- effect: JsTransitionEffect;
362
+ organization?: string;
331
363
  /**
332
- * Duration of the transition animation in milliseconds.
364
+ * Expiry timestamp (Unix seconds), if set.
333
365
  */
334
- durationMs?: number;
366
+ expiresAt?: number;
335
367
  /**
336
- * Whether clicking advances to the next page.
368
+ * Upgrade window cutoff (Unix seconds), if set.
337
369
  */
338
- advanceOnClick?: boolean;
370
+ upgradeUntil?: number;
339
371
  /**
340
- * Auto-advance after this many milliseconds.
372
+ * Unix-seconds release date of this WASM build.
341
373
  */
342
- advanceAfterMs?: number;
374
+ wasmReleaseDate: number;
343
375
  }
344
376
 
345
377
  /**
346
- * Font registration entry from JavaScript.
378
+ * Stitching layout of a `JsPageGroup` (discriminated union tagged by `type`).
347
379
  */
348
- export interface JsFontRegistration {
349
- typeface: string;
350
- bold: boolean;
351
- italic: boolean;
352
- url: string;
380
+ export type JsPageGroupLayout = { type: "linear" } | { type: "tiled"; rows: number; cols: number };
381
+
382
+ /**
383
+ * Tile position in a 2D page grid.
384
+ */
385
+ export interface JsTilePos {
386
+ row: number;
387
+ col: number;
353
388
  }
354
389
 
355
390
  /**
@@ -358,18 +393,38 @@ export interface JsFontRegistration {
358
393
  export type JsTransitionEffect = { type: "blinds"; orientation: JsOrientation } | { type: "checker"; orientation: JsOrientation } | { type: "circle" } | { type: "dissolve" } | { type: "comb"; orientation: JsOrientation } | { type: "cover"; direction: JsEightDirection } | { type: "cut"; throughBlack: boolean } | { type: "diamond" } | { type: "fade"; throughBlack: boolean } | { type: "newsflash" } | { type: "plus" } | { type: "pull"; direction: JsEightDirection } | { type: "push"; direction: JsSideDirection } | { type: "random" } | { type: "randomBar"; orientation: JsOrientation } | { type: "split"; orientation: JsOrientation; inOut: JsInOutDirection } | { type: "strips"; direction: JsCornerDirection } | { type: "wedge" } | { type: "wheel"; spokes: number } | { type: "wipe"; direction: JsSideDirection } | { type: "zoom"; inOut: JsInOutDirection } | { type: "box"; inOut: JsInOutDirection } | { type: "glitter"; direction: JsSideDirection; pattern: JsGlitterPattern } | { type: "fly"; direction: JsSideDirection } | { type: "uncover"; direction: JsEightDirection } | { type: "replace" } | { type: "vortex"; direction: JsSideDirection } | { type: "switch"; direction: JsSideDirection } | { type: "flip"; direction: JsSideDirection } | { type: "ripple"; direction: JsRippleDirection } | { type: "honeycomb" } | { type: "prism"; direction: JsSideDirection; isContent: boolean; isInverted: boolean } | { type: "doors"; orientation: JsOrientation } | { type: "window"; orientation: JsOrientation } | { type: "ferris"; direction: JsSideDirection } | { type: "gallery"; direction: JsSideDirection } | { type: "conveyor"; direction: JsSideDirection } | { type: "pan"; direction: JsSideDirection } | { type: "warp"; inOut: JsInOutDirection } | { type: "flythrough"; inOut: JsInOutDirection; hasBounce: boolean } | { type: "flash" } | { type: "shred"; pattern: JsShredPattern; inOut: JsInOutDirection } | { type: "reveal"; throughBlack: boolean; direction: JsSideDirection } | { type: "wheelReverse"; spokes: number } | { type: "morph"; option: JsMorphOption };
359
394
 
360
395
  /**
361
- * Result from pdf_split_by_outline.
396
+ * Visibility group info for serialization to JavaScript.
362
397
  */
363
- export interface JsSplitByOutlineResult {
364
- documentIds: string[];
365
- sections: JsOutlineSection[];
398
+ export interface JsVisibilityGroup {
399
+ id: string;
400
+ name: string;
401
+ visible: boolean;
402
+ locked: boolean;
403
+ }
404
+
405
+ export interface JsLayoutFrame {
406
+ transform: JsTransform;
407
+ parcel?: JsLayoutParcel;
408
+ }
409
+
410
+ export interface JsLayoutGlyph {
411
+ x: number;
412
+ y: number;
413
+ advance: number;
414
+ /**
415
+ * Byte offset of this glyph\'s source character relative to the parent run\'s text.
416
+ */
417
+ offset: number;
366
418
  }
367
419
 
368
- export interface JsLayoutRunList {
369
- baseline: number;
420
+ export interface JsLayoutGrid {
421
+ x: number;
422
+ y: number;
370
423
  width: number;
371
424
  height: number;
372
- runs: JsLayoutRun[];
425
+ scale: number;
426
+ columns: JsLayoutGridColumn[];
427
+ rows: JsLayoutGridRow[];
373
428
  }
374
429
 
375
430
  export interface JsLayoutGridCell {
@@ -381,30 +436,15 @@ export interface JsLayoutGridCell {
381
436
  parcel?: JsLayoutParcel;
382
437
  }
383
438
 
384
- export interface JsLayoutFrame {
385
- transform: JsTransform;
386
- parcel?: JsLayoutParcel;
387
- }
388
-
389
- export interface JsLayoutRun {
439
+ export interface JsLayoutGridColumn {
390
440
  x: number;
391
441
  width: number;
392
- transform: JsTransform;
393
- content: JsLayoutRunContent;
394
442
  }
395
443
 
396
- export type JsLayoutLineContent = ({ type: "runList" } & JsLayoutRunList) | ({ type: "table" } & JsLayoutTable);
397
-
398
- export interface JsLayoutTable {
399
- width: number;
444
+ export interface JsLayoutGridRow {
445
+ y: number;
400
446
  height: number;
401
- columns: JsLayoutTableColumn[];
402
- rows: JsLayoutTableRow[];
403
- }
404
-
405
- export interface JsLayoutTableColumn {
406
- x: number;
407
- width: number;
447
+ cells: JsLayoutGridCell[];
408
448
  }
409
449
 
410
450
  export interface JsLayoutLine {
@@ -418,25 +458,6 @@ export interface JsLayoutLine {
418
458
  content: JsLayoutLineContent;
419
459
  }
420
460
 
421
- export interface JsTransform {
422
- scaleX: number;
423
- skewY: number;
424
- skewX: number;
425
- scaleY: number;
426
- translateX: number;
427
- translateY: number;
428
- }
429
-
430
- export interface JsLayoutGlyph {
431
- x: number;
432
- y: number;
433
- advance: number;
434
- /**
435
- * Byte offset of this glyph\'s source character relative to the parent run\'s text.
436
- */
437
- offset: number;
438
- }
439
-
440
461
  export interface JsLayoutPage {
441
462
  width: number;
442
463
  height: number;
@@ -444,33 +465,33 @@ export interface JsLayoutPage {
444
465
  grid?: JsLayoutGrid;
445
466
  }
446
467
 
447
- export interface JsLayoutGrid {
468
+ export interface JsLayoutParcel {
448
469
  x: number;
449
470
  y: number;
450
471
  width: number;
451
472
  height: number;
452
- scale: number;
453
- columns: JsLayoutGridColumn[];
454
- rows: JsLayoutGridRow[];
473
+ lines: JsLayoutLine[];
455
474
  }
456
475
 
457
- export interface JsLayoutParcel {
476
+ export interface JsLayoutRun {
458
477
  x: number;
459
- y: number;
460
478
  width: number;
461
- height: number;
462
- lines: JsLayoutLine[];
479
+ transform: JsTransform;
480
+ content: JsLayoutRunContent;
463
481
  }
464
482
 
465
- export interface JsLayoutGridColumn {
466
- x: number;
483
+ export interface JsLayoutRunList {
484
+ baseline: number;
467
485
  width: number;
486
+ height: number;
487
+ runs: JsLayoutRun[];
468
488
  }
469
489
 
470
- export interface JsLayoutGridRow {
471
- y: number;
490
+ export interface JsLayoutTable {
491
+ width: number;
472
492
  height: number;
473
- cells: JsLayoutGridCell[];
493
+ columns: JsLayoutTableColumn[];
494
+ rows: JsLayoutTableRow[];
474
495
  }
475
496
 
476
497
  export interface JsLayoutTableCell {
@@ -484,611 +505,595 @@ export interface JsLayoutTableCell {
484
505
  parcel?: JsLayoutParcel;
485
506
  }
486
507
 
508
+ export interface JsLayoutTableColumn {
509
+ x: number;
510
+ width: number;
511
+ }
512
+
487
513
  export interface JsLayoutTableRow {
488
514
  y: number;
489
515
  height: number;
490
516
  cells: JsLayoutTableCell[];
491
517
  }
492
518
 
519
+ export interface JsTransform {
520
+ scaleX: number;
521
+ skewY: number;
522
+ skewX: number;
523
+ scaleY: number;
524
+ translateX: number;
525
+ translateY: number;
526
+ }
527
+
528
+ export interface JsViewerPreferences {
529
+ layoutMode?: JsViewerLayoutMode;
530
+ scrollMode?: JsViewerScrollMode;
531
+ }
532
+
533
+ export type JsCornerDirection = "leftUp" | "rightUp" | "leftDown" | "rightDown";
534
+
535
+ export type JsEightDirection = "left" | "right" | "up" | "down" | "leftUp" | "rightUp" | "leftDown" | "rightDown";
536
+
537
+ export type JsGlitterPattern = "diamond" | "hexagon";
538
+
539
+ export type JsInOutDirection = "in" | "out";
540
+
541
+ export type JsLayoutLineContent = ({ type: "runList" } & JsLayoutRunList) | ({ type: "table" } & JsLayoutTable);
542
+
493
543
  export type JsLayoutRunContent = { type: "glyphs"; text: string; fontSize: number; ascent: number; descent: number; glyphs: JsLayoutGlyph[] } | { type: "space"; advance: number; fontSize: number; ascent: number; descent: number } | { type: "tab"; advance: number; fontSize: number; ascent: number; descent: number } | { type: "paragraphEnd"; advance: number } | { type: "break" } | { type: "inlineDrawing"; width: number; height: number };
494
544
 
545
+ export type JsMorphOption = "byObject" | "byWord" | "byChar";
546
+
547
+ export type JsOrientation = "horizontal" | "vertical";
548
+
549
+ export type JsRippleDirection = "center" | "leftUp" | "rightUp" | "leftDown" | "rightDown";
550
+
551
+ export type JsShredPattern = "strip" | "rectangle";
552
+
553
+ export type JsSideDirection = "left" | "right" | "up" | "down";
554
+
555
+ export type JsViewerLayoutMode = "single-page" | "double-page-odd-right" | "double-page-odd-left";
556
+
557
+ export type JsViewerScrollMode = "spread" | "continuous";
558
+
559
+
495
560
  /**
496
- * Result returned to JavaScript after license validation.
561
+ * Universal document viewer.
562
+ *
563
+ * Loads, stores, and renders PDF documents. Each document is identified by a unique ID.
497
564
  */
498
- export interface LicenseResult {
565
+ export class Wasm {
566
+ free(): void;
567
+ [Symbol.dispose](): void;
499
568
  /**
500
- * Whether the license is valid.
569
+ * Get info for all pages in one call.
570
+ *
571
+ * Returns an array of `PageInfo` objects, one per page.
572
+ * More efficient than calling `page_info` for each page.
501
573
  */
502
- valid: boolean;
574
+ all_page_info(id: string): JsPageInfo[];
503
575
  /**
504
- * Error message if validation failed.
576
+ * Authenticate with a password to unlock an encrypted document.
577
+ *
578
+ * # Arguments
579
+ * * `id` - Document ID
580
+ * * `password` - Password to try
581
+ *
582
+ * # Returns
583
+ * `true` if authentication succeeded, `false` if the password was incorrect.
505
584
  */
506
- error?: string;
585
+ authenticate(id: string, password: string): boolean;
507
586
  /**
508
- * Enabled features.
587
+ * Disable telemetry reporting.
588
+ *
589
+ * Only takes effect if the current license includes the `no_telemetry`
590
+ * feature flag. Returns `true` if telemetry was disabled, `false` if the
591
+ * license does not permit it.
509
592
  */
510
- features: string[];
593
+ disable_telemetry(): boolean;
511
594
  /**
512
- * Numeric limits.
595
+ * Get the format of a loaded document.
596
+ *
597
+ * Returns one of: "pdf", "docx", "pptx", "xlsx", "image".
513
598
  */
514
- limits: Record<string, number>;
599
+ document_format(id: string): string;
515
600
  /**
516
- * Organization name.
601
+ * Get all document IDs.
517
602
  */
518
- organization?: string;
603
+ document_ids(): string[];
519
604
  /**
520
- * Expiry timestamp (Unix seconds), if set.
605
+ * Enable Google Fonts.
606
+ *
607
+ * When enabled, fonts that are not embedded in the document will be
608
+ * automatically fetched from Google Fonts during rendering. Google Fonts
609
+ * are resolved after any URL fonts registered via `registerFonts`.
610
+ *
611
+ * Call this before loading documents.
612
+ *
613
+ * # Example (JavaScript)
614
+ * ```js
615
+ * udoc.enableGoogleFonts();
616
+ * const docId = udoc.loadPptx(pptxBytes);
617
+ * const pixels = udoc.renderPageToRgba(docId, 0, 800, 600);
618
+ * ```
521
619
  */
522
- expiresAt?: number;
620
+ enableGoogleFonts(): void;
523
621
  /**
524
- * Upgrade window cutoff (Unix seconds), if set.
622
+ * Get all annotations in the document, grouped by page index.
623
+ *
624
+ * Returns an object mapping page indices (as strings) to arrays of annotations.
525
625
  */
526
- upgradeUntil?: number;
626
+ get_all_annotations(id: string): JsAnnotationsByPage;
527
627
  /**
528
- * Unix-seconds release date of this WASM build.
628
+ * Get the raw file bytes of a document.
629
+ *
630
+ * Returns the original file data for the document.
529
631
  */
530
- wasmReleaseDate: number;
531
- }
532
-
533
- /**
534
- * Destination display parameters for JavaScript serialization.
535
- */
536
- export type JsDestinationDisplay = { type: "xyz"; left: number | undefined; top: number | undefined; zoom: number | undefined } | { type: "fit" } | { type: "fitH"; top: number | undefined } | { type: "fitV"; left: number | undefined } | { type: "fitR"; left: number; top: number; right: number; bottom: number } | { type: "fitB" } | { type: "fitBH"; top: number | undefined } | { type: "fitBV"; left: number | undefined };
537
-
538
- /**
539
- * Destination for JavaScript serialization.
540
- */
541
- export interface JsDestination {
542
- pageIndex: number;
543
- display: JsDestinationDisplay;
544
- }
545
-
546
- /**
547
- * Outline item for JavaScript serialization.
548
- */
549
- export interface JsOutlineItem {
550
- title: string;
551
- destination?: JsDestination;
552
- children: JsOutlineItem[];
632
+ get_bytes(id: string): Uint8Array;
553
633
  /**
554
- * Whether this item should be initially collapsed in the viewer.
634
+ * Get font usage information for a document.
635
+ *
636
+ * Returns an array of `FontUsageEntry` objects describing how each font
637
+ * spec in the document was resolved, including primary resolution and
638
+ * any glyph-fallback fonts used during text shaping.
639
+ *
640
+ * This information is populated during layout — call after rendering at
641
+ * least one page to get results.
642
+ *
643
+ * # Arguments
644
+ * * `id` - Document ID
645
+ *
646
+ * # Returns
647
+ * `FontUsageEntry[]` — see TypeScript types for shape.
555
648
  */
556
- initiallyCollapsed: boolean;
557
- }
558
-
559
-
560
- export class Wasm {
561
- free(): void;
562
- [Symbol.dispose](): void;
563
- /**
564
- * Load an image file and return its ID.
565
- *
566
- * Supports various image formats: JPEG, PNG, GIF, BMP, TIFF, WebP, etc.
567
- * Multi-page TIFF files will create a document with multiple pages.
568
- *
569
- * # Arguments
570
- * * `bytes` - Raw image file data
571
- *
572
- * # Returns
573
- * A unique document ID that can be used to reference this document.
574
- */
575
- load_image(bytes: Uint8Array): string;
576
- /**
577
- * Get the page count of a document.
578
- */
579
- page_count(id: string): number;
580
- /**
581
- * Get the document outline (bookmarks/table of contents).
582
- *
583
- * Returns an array of outline items, where each item has:
584
- * - `title`: Display text for the item
585
- * - `destination`: Optional navigation destination with `pageIndex` and display parameters
586
- * - `children`: Nested child items
587
- *
588
- * Returns an empty array if the document has no outline.
589
- */
590
- get_outline(id: string): JsOutlineItem[];
591
- /**
592
- * Check if a feature is enabled by the current license.
593
- */
594
- has_feature(feature: string): boolean;
595
- /**
596
- * Get the page groups for a document.
597
- *
598
- * Each group covers a contiguous range of global page indices with a
599
- * shared stitching layout. Use this to build per-group canvases (e.g.,
600
- * one panel per Excel sheet) and group-named sidebars.
601
- *
602
- * - PDF/DOCX: one `linear` group covering all pages, no name.
603
- * - PPTX: one `linear` group (per-section groups once sections are modeled).
604
- * - XLSX: one `tiled` group per sheet with the sheet name and page-grid dimensions.
605
- */
606
- page_groups(id: string): JsPageGroup[];
607
- /**
608
- * Compose new PDF documents by cherry-picking pages from source documents.
609
- *
610
- * The original documents remain unchanged.
611
- *
612
- * # Arguments
613
- * * `compositions` - Array of compositions. Each composition is an array of picks.
614
- * Each pick is `{ doc: docIndex, pages: "0-2,4" }` where `docIndex` is the index
615
- * in the `doc_ids` array and `pages` is a page range string (0-based).
616
- * * `doc_ids` - Array of document IDs to use as sources (order matters for doc indices)
617
- *
618
- * # Example
619
- * ```js
620
- * // Create two documents: first has pages 0-2 from doc A, second has page 0 from A and 1 from B
621
- * const newDocIds = udoc.pdf_compose(
622
- * [
623
- * [{ doc: 0, pages: "0-2" }],
624
- * [{ doc: 0, pages: "0" }, { doc: 1, pages: "1" }]
625
- * ],
626
- * ["doc_0", "doc_1"]
627
- * );
628
- * ```
629
- *
630
- * # Returns
631
- * Array of IDs for the newly created documents (one per composition).
632
- */
633
- pdf_compose(compositions: JsCompositions, doc_ids: string[]): string[];
634
- /**
635
- * Set the license key.
636
- *
637
- * # Arguments
638
- * * `license_key` - The license key string
639
- *
640
- * # Returns
641
- * License validation result as JSON.
642
- */
643
- set_license(license_key: string): LicenseResult;
644
- /**
645
- * Authenticate with a password to unlock an encrypted document.
646
- *
647
- * # Arguments
648
- * * `id` - Document ID
649
- * * `password` - Password to try
650
- *
651
- * # Returns
652
- * `true` if authentication succeeded, `false` if the password was incorrect.
653
- */
654
- authenticate(id: string, password: string): boolean;
655
- /**
656
- * Get all document IDs.
657
- */
658
- document_ids(): string[];
659
- /**
660
- * Check if a document with the given ID exists.
661
- */
662
- has_document(id: string): boolean;
663
- /**
664
- * Compress a PDF document.
665
- *
666
- * Saves the document with full compression options enabled:
667
- * - Compress stream data using FlateDecode
668
- * - Pack objects into compressed object streams (PDF 1.5+)
669
- * - Use compressed xref streams (PDF 1.5+)
670
- * - Remove unreferenced objects
671
- *
672
- * # Arguments
673
- * * `doc_id` - Document ID to compress
674
- *
675
- * # Returns
676
- * Compressed PDF data as Uint8Array
677
- */
678
- pdf_compress(doc_id: string): Uint8Array;
679
- /**
680
- * Get info for all pages in one call.
681
- *
682
- * Returns an array of `PageInfo` objects, one per page.
683
- * More efficient than calling `page_info` for each page.
684
- */
685
- all_page_info(id: string): JsPageInfo[];
686
- /**
687
- * Get font usage information for a document.
688
- *
689
- * Returns an array of `FontUsageEntry` objects describing how each font
690
- * spec in the document was resolved, including primary resolution and
691
- * any glyph-fallback fonts used during text shaping.
692
- *
693
- * This information is populated during layout — call after rendering at
694
- * least one page to get results.
695
- *
696
- * # Arguments
697
- * * `id` - Document ID
698
- *
699
- * # Returns
700
- * `FontUsageEntry[]` — see TypeScript types for shape.
701
- */
702
- get_font_usage(id: string): JsFontUsageEntry[];
703
- /**
704
- * Get current license status.
705
- */
706
- license_status(): LicenseResult;
707
- /**
708
- * Check if a document requires a password to open.
709
- *
710
- * Returns `true` if the document is encrypted and requires authentication
711
- * before pages can be loaded or rendered.
712
- */
713
- needs_password(id: string): boolean;
714
- /**
715
- * Decompress a PDF document.
716
- *
717
- * Removes all filter encodings from streams, resulting in raw,
718
- * uncompressed stream data. Useful for debugging or inspection.
719
- *
720
- * # Arguments
721
- * * `doc_id` - Document ID to decompress
722
- *
723
- * # Returns
724
- * Decompressed PDF data as Uint8Array
725
- */
726
- pdf_decompress(doc_id: string): Uint8Array;
727
- /**
728
- * Register font URLs.
729
- *
730
- * The caller provides a list of all available fonts with their download
731
- * URLs. During layout, when the engine needs a font, it is fetched from
732
- * the URL, parsed, and cached for reuse.
733
- *
734
- * Call this before loading documents. Registered fonts are automatically
735
- * applied to every document loaded afterward. URL fonts are always
736
- * resolved before Google Fonts.
737
- *
738
- * # Arguments
739
- * * `fonts` - Array of font entries: `[{ typeface: "Roboto", bold: false, italic: false, url: "https://..." }, ...]`
740
- *
741
- * # Example (JavaScript)
742
- * ```js
743
- * // Register available fonts before loading documents
744
- * udoc.registerFonts([
745
- * { typeface: "Roboto", bold: false, italic: false, url: "https://cdn.example.com/Roboto-Regular.woff2" },
746
- * { typeface: "Roboto", bold: true, italic: false, url: "https://cdn.example.com/Roboto-Bold.woff2" },
747
- * ]);
748
- *
749
- * // Load and render - fonts are fetched on demand during layout
750
- * const docId = udoc.loadPptx(pptxBytes);
751
- * const pixels = udoc.renderPageToRgba(docId, 0, 800, 600);
752
- * ```
753
- */
754
- registerFonts(fonts: JsFontRegistration[]): void;
755
- /**
756
- * Get the format of a loaded document.
757
- *
758
- * Returns one of: "pdf", "docx", "pptx", "xlsx", "image".
759
- */
760
- document_format(id: string): string;
761
- /**
762
- * Get the layout model for a specific page.
763
- *
764
- * Returns the hierarchical layout structure (frames, parcels, lines, runs,
765
- * glyphs, tables, grids) without building the full display list. This is
766
- * more efficient than `get_page_text` for text selection/search and
767
- * preserves semantic structure (paragraphs, tables, etc.).
768
- *
769
- * All coordinates are in points (1/72 inch). The viewer should scale by
770
- * `canvasWidth / layoutPage.width` to convert to pixels.
771
- */
772
- get_layout_page(id: string, page_index: number): JsLayoutPage;
773
- /**
774
- * Remove a document by ID.
775
- *
776
- * Returns true if the document was removed, false if it didn't exist.
777
- */
778
- remove_document(id: string): boolean;
779
- /**
780
- * Render a page using the GPU backend (Vello + WebGPU).
781
- *
782
- * Returns raw RGBA pixel data in premultiplied alpha format,
783
- * identical to `render_page_to_rgba` but GPU-accelerated.
784
- *
785
- * # Errors
786
- * Returns an error if the GPU backend is not initialized
787
- * (call `init_gpu()` first), if the document is not found,
788
- * or if rendering fails.
789
- */
790
- render_page_gpu(id: string, page_index: number, width: number, height: number): Promise<Uint8Array>;
791
- /**
792
- * Set the anonymous distinct ID for telemetry tracking.
793
- *
794
- * Call this after `new()` once the ID has been read from localStorage
795
- * (or generated). Must be called before loading documents so that
796
- * telemetry events include the correct metadata.
797
- *
798
- * # Arguments
799
- * * `distinct_id` - Anonymous UUID for per-user tracking (persisted in localStorage)
800
- */
801
- setup_telemetry(distinct_id: string): void;
802
- /**
803
- * Disable telemetry reporting.
804
- *
805
- * Only takes effect if the current license includes the `no_telemetry`
806
- * feature flag. Returns `true` if telemetry was disabled, `false` if the
807
- * license does not permit it.
808
- */
809
- disable_telemetry(): boolean;
810
- /**
811
- * Extract all embedded fonts from a PDF document.
812
- *
813
- * # Arguments
814
- * * `doc_id` - Document ID to extract fonts from
815
- *
816
- * # Returns
817
- * Array of extracted font objects, each with:
818
- * - `name`: Font name from the resource dictionary
819
- * - `fontType`: Font type (Type1, TrueType, etc.)
820
- * - `extension`: File extension (ttf, cff, t1, etc.)
821
- * - `data`: Raw font data as Uint8Array
822
- */
823
- pdf_extract_fonts(doc_id: string): JsExtractedFont[];
824
- /**
825
- * Extract all embedded images from a PDF document.
826
- *
827
- * # Arguments
828
- * * `doc_id` - Document ID to extract images from
829
- * * `convert_raw_to_png` - When true, converts raw pixel data to PNG format
830
- *
831
- * # Returns
832
- * Array of extracted image objects, each with:
833
- * - `name`: Image name from the resource dictionary
834
- * - `format`: Image format (jpeg, png, jp2, etc.)
835
- * - `width`: Width in pixels
836
- * - `height`: Height in pixels
837
- * - `data`: Raw image data as Uint8Array
838
- */
839
- pdf_extract_images(doc_id: string, convert_raw_to_png: boolean): JsExtractedImage[];
840
- /**
841
- * Render a page to PNG bytes.
842
- *
843
- * # Arguments
844
- * * `id` - Document ID
845
- * * `page_index` - Zero-based page index
846
- * * `width` - Output width in pixels
847
- * * `height` - Output height in pixels
848
- *
849
- * # Returns
850
- * PNG-encoded image data as a byte array.
851
- */
852
- render_page_to_png(id: string, page_index: number, width: number, height: number): Uint8Array;
853
- /**
854
- * Get viewer preferences embedded in the document.
855
- *
856
- * Returns a `JsViewerPreferences` with optional fields:
857
- * - `layoutMode`: `"single-page"` | `"double-page-odd-right"` | `"double-page-odd-left"`
858
- * - `scrollMode`: `"spread"` | `"continuous"`
859
- */
860
- viewer_preferences(id: string): JsViewerPreferences;
861
- /**
862
- * Enable Google Fonts.
863
- *
864
- * When enabled, fonts that are not embedded in the document will be
865
- * automatically fetched from Google Fonts during rendering. Google Fonts
866
- * are resolved after any URL fonts registered via `registerFonts`.
867
- *
868
- * Call this before loading documents.
869
- *
870
- * # Example (JavaScript)
871
- * ```js
872
- * udoc.enableGoogleFonts();
873
- * const docId = udoc.loadPptx(pptxBytes);
874
- * const pixels = udoc.renderPageToRgba(docId, 0, 800, 600);
875
- * ```
876
- */
877
- enableGoogleFonts(): void;
878
- /**
879
- * Get all annotations in the document, grouped by page index.
880
- *
881
- * Returns an object mapping page indices (as strings) to arrays of annotations.
882
- */
883
- get_all_annotations(id: string): JsAnnotationsByPage;
884
- /**
885
- * Render a page to raw RGBA pixel data.
886
- *
887
- * The returned data is in premultiplied alpha format, suitable for
888
- * use with `ImageData` and canvas rendering.
889
- *
890
- * # Arguments
891
- * * `id` - Document ID
892
- * * `page_index` - Zero-based page index
893
- * * `width` - Output width in pixels
894
- * * `height` - Output height in pixels
895
- *
896
- * # Returns
897
- * Raw RGBA pixel data (width * height * 4 bytes).
898
- */
899
- render_page_to_rgba(id: string, page_index: number, width: number, height: number): Uint8Array;
900
- /**
901
- * Get annotations for a specific page.
902
- *
903
- * Returns an array of annotation objects for the given page.
904
- * Uses per-page loading for efficiency (only loads the requested page).
905
- *
906
- * All geometry fields on the returned annotations (`bounds`, `quads`,
907
- * `vertices`, `inkList`, `start`/`end`, …) are in the page's unrotated
908
- * MediaBox coordinate space — origin top-left, PDF points, +y downward
909
- * regardless of the page's `/Rotate` value. The viewer applies
910
- * rotation as a display transform on top. This matches the input space
911
- * expected by `pdf_save_annotations`, so the round-trip is consistent.
912
- */
913
- get_page_annotations(id: string, page_index: number): JsAnnotation[];
914
- /**
915
- * Save annotations back to a PDF document.
916
- *
917
- * Takes the current document and a set of annotations (grouped by page),
918
- * writes them into the PDF's annotation structures, and returns the
919
- * modified PDF bytes.
920
- *
921
- * # Coordinate space
922
- *
923
- * Every geometry field on the supplied annotations (`bounds`, `quads`,
924
- * `vertices`, `inkList`, `start`/`end`, `calloutLine`, …) must be in
925
- * the page's **unrotated MediaBox** coordinate space:
926
- *
927
- * - Origin = MediaBox top-left of the page in its natural (pre-`/Rotate`)
928
- * orientation. `(0, 0)` does not move when the page is displayed
929
- * rotated 90°/180°/270°.
930
- * - Units = PDF points (1/72 inch).
931
- * - Axes = `+x` right, `+y` downward (Y-flipped relative to PDF's native
932
- * bottom-up `/Rect`; this function performs the flip on the way out).
933
- * - `CropBox` is ignored — coordinates are MediaBox-relative even when
934
- * the page's CropBox trims the visible area.
935
- *
936
- * This is the same space returned by `get_page_annotations` /
937
- * `get_all_annotations`, so a load-edit-save round-trip is consistent.
938
- * Pages with no existing `/Annots` array are handled automatically: any
939
- * pre-existing array is cleared and a fresh one is created.
940
- *
941
- * # Arguments
942
- * * `doc_id` - Document ID
943
- * * `annotations_by_page` - Object mapping page indices (as strings) to
944
- * arrays of annotation objects. Same schema as returned by
945
- * `get_all_annotations`.
946
- *
947
- * # Returns
948
- * The modified PDF file bytes with annotations saved.
949
- *
950
- * # Example (JavaScript)
951
- * ```js
952
- * const annotations = udoc.get_all_annotations(docId);
953
- * // ... viewer edits annotations ...
954
- * const pdfBytes = udoc.pdf_save_annotations(docId, annotations);
955
- * ```
956
- */
957
- pdf_save_annotations(doc_id: string, annotations_by_page: JsAnnotationsByPage): Uint8Array;
958
- /**
959
- * Split a PDF document by its outline (bookmarks) structure.
960
- *
961
- * Creates multiple documents, one for each outline section at the specified level.
962
- *
963
- * # Arguments
964
- * * `doc_id` - Document ID to split
965
- * * `max_level` - Maximum outline level to consider (1 = top level only)
966
- * * `split_mid_page` - When true, filters page content when sections share a page
967
- *
968
- * # Returns
969
- * Object with:
970
- * - `documentIds`: Array of IDs for the newly created documents
971
- * - `sections`: Array of section info objects with `title`, `startPage`, `level`
972
- */
973
- pdf_split_by_outline(doc_id: string, max_level: number, split_mid_page: boolean): JsSplitByOutlineResult;
974
- /**
975
- * Get all visibility groups for a document.
976
- *
977
- * Returns an array of objects, each containing:
978
- * - `id`: Unique identifier string
979
- * - `name`: Display name for UI
980
- * - `visible`: Whether the group is currently visible
981
- *
982
- * Returns an empty array for documents without visibility groups.
983
- */
984
- get_visibility_groups(id: string): JsVisibilityGroup[];
985
- /**
986
- * Set the visibility of a specific visibility group.
987
- *
988
- * # Arguments
989
- * * `id` - Document ID
990
- * * `group_id` - Visibility group ID
991
- * * `visible` - Whether the group should be visible
992
- *
993
- * Returns `true` if the group was found and updated, `false` if not found.
994
- */
995
- set_visibility_group_visible(id: string, group_id: string, visible: boolean): boolean;
996
- /**
997
- * Create a new document viewer.
998
- *
999
- * # Arguments
1000
- * * `domain` - Hostname of the embedding page (e.g. from `window.location.hostname`)
1001
- * * `viewer_version` - SDK version string
1002
- */
1003
- constructor(domain: string, viewer_version: string);
1004
- /**
1005
- * Load a document by auto-detecting its format from the file contents.
1006
- *
1007
- * Inspects magic bytes to determine the format:
1008
- * - `%PDF` → PDF
1009
- * - `PK\x03\x04` (ZIP) → inspects ZIP entries for `word/` (DOCX), `ppt/` (PPTX), or `xl/` (XLSX)
1010
- * - Image magic bytes (JPEG, PNG, GIF, BMP, TIFF, WebP) → Image
1011
- *
1012
- * # Arguments
1013
- * * `bytes` - Raw file data
1014
- *
1015
- * # Returns
1016
- * A unique document ID that can be used to reference this document.
1017
- */
1018
- load(bytes: Uint8Array): string;
1019
- /**
1020
- * Check whether the GPU render backend is available.
1021
- */
1022
- has_gpu(): boolean;
1023
- /**
1024
- * Initialize the GPU render backend (Vello + WebGPU).
1025
- *
1026
- * This is async because wgpu device initialization requires yielding
1027
- * to the browser event loop. Call this once after construction.
1028
- * Returns `true` if GPU initialization succeeded, `false` if no
1029
- * WebGPU adapter is available (the CPU backend remains usable).
1030
- */
1031
- init_gpu(): Promise<boolean>;
1032
- /**
1033
- * Load a PDF document and return its ID.
1034
- *
1035
- * # Arguments
1036
- * * `bytes` - Raw PDF file data
1037
- *
1038
- * # Returns
1039
- * A unique document ID that can be used to reference this document.
1040
- */
1041
- load_pdf(bytes: Uint8Array): string;
1042
- /**
1043
- * Get the raw file bytes of a document.
1044
- *
1045
- * Returns the original file data for the document.
1046
- */
1047
- get_bytes(id: string): Uint8Array;
1048
- /**
1049
- * Get a numeric limit from the current license.
1050
- *
1051
- * Returns the limit value if set in the license, otherwise returns the default.
1052
- */
1053
- get_limit(limit_name: string, _default: bigint): bigint;
1054
- /**
1055
- * Load a DOCX document and return its ID.
1056
- *
1057
- * # Arguments
1058
- * * `bytes` - Raw DOCX file data
1059
- *
1060
- * # Returns
1061
- * A unique document ID that can be used to reference this document.
1062
- */
1063
- load_docx(bytes: Uint8Array): string;
1064
- /**
1065
- * Load a PPTX (PowerPoint) document and return its ID.
1066
- *
1067
- * # Arguments
1068
- * * `bytes` - Raw PPTX file data
1069
- *
1070
- * # Returns
1071
- * A unique document ID that can be used to reference this document.
1072
- */
1073
- load_pptx(bytes: Uint8Array): string;
1074
- /**
1075
- * Load an XLSX document and return its ID.
1076
- *
1077
- * # Arguments
1078
- * * `bytes` - Raw XLSX file data
1079
- *
1080
- * # Returns
1081
- * A unique document ID that can be used to reference this document.
1082
- */
1083
- load_xlsx(bytes: Uint8Array): string;
1084
- /**
1085
- * Get info for a specific page.
1086
- */
1087
- page_info(id: string, page_index: number): JsPageInfo;
1088
- /**
1089
- * Get the number of documents currently loaded.
1090
- */
1091
- readonly document_count: number;
649
+ get_font_usage(id: string): JsFontUsageEntry[];
650
+ /**
651
+ * Get the layout model for a specific page.
652
+ *
653
+ * Returns the hierarchical layout structure (frames, parcels, lines, runs,
654
+ * glyphs, tables, grids) without building the full display list. This is
655
+ * more efficient than `get_page_text` for text selection/search and
656
+ * preserves semantic structure (paragraphs, tables, etc.).
657
+ *
658
+ * All coordinates are in points (1/72 inch). The viewer should scale by
659
+ * `canvasWidth / layoutPage.width` to convert to pixels.
660
+ */
661
+ get_layout_page(id: string, page_index: number): JsLayoutPage;
662
+ /**
663
+ * Get a numeric limit from the current license.
664
+ *
665
+ * Returns the limit value if set in the license, otherwise returns the default.
666
+ */
667
+ get_limit(limit_name: string, _default: bigint): bigint;
668
+ /**
669
+ * Get the document outline (bookmarks/table of contents).
670
+ *
671
+ * Returns an array of outline items, where each item has:
672
+ * - `title`: Display text for the item
673
+ * - `destination`: Optional navigation destination with `pageIndex` and display parameters
674
+ * - `children`: Nested child items
675
+ *
676
+ * Returns an empty array if the document has no outline.
677
+ */
678
+ get_outline(id: string): JsOutlineItem[];
679
+ /**
680
+ * Get annotations for a specific page.
681
+ *
682
+ * Returns an array of annotation objects for the given page.
683
+ * Uses per-page loading for efficiency (only loads the requested page).
684
+ *
685
+ * All geometry fields on the returned annotations (`bounds`, `quads`,
686
+ * `vertices`, `inkList`, `start`/`end`, …) are in the page's unrotated
687
+ * MediaBox coordinate space — origin top-left, PDF points, +y downward
688
+ * — regardless of the page's `/Rotate` value. The viewer applies
689
+ * rotation as a display transform on top. This matches the input space
690
+ * expected by `pdf_save_annotations`, so the round-trip is consistent.
691
+ */
692
+ get_page_annotations(id: string, page_index: number): JsAnnotation[];
693
+ /**
694
+ * Get all visibility groups for a document.
695
+ *
696
+ * Returns an array of objects, each containing:
697
+ * - `id`: Unique identifier string
698
+ * - `name`: Display name for UI
699
+ * - `visible`: Whether the group is currently visible
700
+ *
701
+ * Returns an empty array for documents without visibility groups.
702
+ */
703
+ get_visibility_groups(id: string): JsVisibilityGroup[];
704
+ /**
705
+ * Check if a document with the given ID exists.
706
+ */
707
+ has_document(id: string): boolean;
708
+ /**
709
+ * Check if a feature is enabled by the current license.
710
+ */
711
+ has_feature(feature: string): boolean;
712
+ /**
713
+ * Check whether the GPU render backend is available.
714
+ */
715
+ has_gpu(): boolean;
716
+ /**
717
+ * Initialize the GPU render backend (Vello + WebGPU).
718
+ *
719
+ * This is async because wgpu device initialization requires yielding
720
+ * to the browser event loop. Call this once after construction.
721
+ * Returns `true` if GPU initialization succeeded, `false` if no
722
+ * WebGPU adapter is available (the CPU backend remains usable).
723
+ */
724
+ init_gpu(): Promise<boolean>;
725
+ /**
726
+ * Get current license status.
727
+ */
728
+ license_status(): LicenseResult;
729
+ /**
730
+ * Load a document by auto-detecting its format from the file contents.
731
+ *
732
+ * Inspects magic bytes to determine the format:
733
+ * - `%PDF` → PDF
734
+ * - `PK\x03\x04` (ZIP) inspects ZIP entries for `word/` (DOCX), `ppt/` (PPTX), or `xl/` (XLSX)
735
+ * - Image magic bytes (JPEG, PNG, GIF, BMP, TIFF, WebP) → Image
736
+ *
737
+ * # Arguments
738
+ * * `bytes` - Raw file data
739
+ *
740
+ * # Returns
741
+ * A unique document ID that can be used to reference this document.
742
+ */
743
+ load(bytes: Uint8Array): string;
744
+ /**
745
+ * Load a DOCX document and return its ID.
746
+ *
747
+ * # Arguments
748
+ * * `bytes` - Raw DOCX file data
749
+ *
750
+ * # Returns
751
+ * A unique document ID that can be used to reference this document.
752
+ */
753
+ load_docx(bytes: Uint8Array): string;
754
+ /**
755
+ * Load an image file and return its ID.
756
+ *
757
+ * Supports various image formats: JPEG, PNG, GIF, BMP, TIFF, WebP, etc.
758
+ * Multi-page TIFF files will create a document with multiple pages.
759
+ *
760
+ * # Arguments
761
+ * * `bytes` - Raw image file data
762
+ *
763
+ * # Returns
764
+ * A unique document ID that can be used to reference this document.
765
+ */
766
+ load_image(bytes: Uint8Array): string;
767
+ /**
768
+ * Load a PDF document and return its ID.
769
+ *
770
+ * # Arguments
771
+ * * `bytes` - Raw PDF file data
772
+ *
773
+ * # Returns
774
+ * A unique document ID that can be used to reference this document.
775
+ */
776
+ load_pdf(bytes: Uint8Array): string;
777
+ /**
778
+ * Load a PPTX (PowerPoint) document and return its ID.
779
+ *
780
+ * # Arguments
781
+ * * `bytes` - Raw PPTX file data
782
+ *
783
+ * # Returns
784
+ * A unique document ID that can be used to reference this document.
785
+ */
786
+ load_pptx(bytes: Uint8Array): string;
787
+ /**
788
+ * Load an XLSX document and return its ID.
789
+ *
790
+ * # Arguments
791
+ * * `bytes` - Raw XLSX file data
792
+ *
793
+ * # Returns
794
+ * A unique document ID that can be used to reference this document.
795
+ */
796
+ load_xlsx(bytes: Uint8Array): string;
797
+ /**
798
+ * Check if a document requires a password to open.
799
+ *
800
+ * Returns `true` if the document is encrypted and requires authentication
801
+ * before pages can be loaded or rendered.
802
+ */
803
+ needs_password(id: string): boolean;
804
+ /**
805
+ * Create a new document viewer.
806
+ *
807
+ * # Arguments
808
+ * * `domain` - Hostname of the embedding page (e.g. from `window.location.hostname`)
809
+ * * `viewer_version` - SDK version string
810
+ */
811
+ constructor(domain: string, viewer_version: string);
812
+ /**
813
+ * Get the page count of a document.
814
+ */
815
+ page_count(id: string): number;
816
+ /**
817
+ * Get the page groups for a document.
818
+ *
819
+ * Each group covers a contiguous range of global page indices with a
820
+ * shared stitching layout. Use this to build per-group canvases (e.g.,
821
+ * one panel per Excel sheet) and group-named sidebars.
822
+ *
823
+ * - PDF/DOCX: one `linear` group covering all pages, no name.
824
+ * - PPTX: one `linear` group (per-section groups once sections are modeled).
825
+ * - XLSX: one `tiled` group per sheet with the sheet name and page-grid dimensions.
826
+ */
827
+ page_groups(id: string): JsPageGroup[];
828
+ /**
829
+ * Get info for a specific page.
830
+ */
831
+ page_info(id: string, page_index: number): JsPageInfo;
832
+ /**
833
+ * Compose new PDF documents by cherry-picking pages from source documents.
834
+ *
835
+ * The original documents remain unchanged.
836
+ *
837
+ * # Arguments
838
+ * * `compositions` - Array of compositions. Each composition is an array of picks.
839
+ * Each pick is `{ doc: docIndex, pages: "0-2,4" }` where `docIndex` is the index
840
+ * in the `doc_ids` array and `pages` is a page range string (0-based).
841
+ * * `doc_ids` - Array of document IDs to use as sources (order matters for doc indices)
842
+ *
843
+ * # Example
844
+ * ```js
845
+ * // Create two documents: first has pages 0-2 from doc A, second has page 0 from A and 1 from B
846
+ * const newDocIds = udoc.pdf_compose(
847
+ * [
848
+ * [{ doc: 0, pages: "0-2" }],
849
+ * [{ doc: 0, pages: "0" }, { doc: 1, pages: "1" }]
850
+ * ],
851
+ * ["doc_0", "doc_1"]
852
+ * );
853
+ * ```
854
+ *
855
+ * # Returns
856
+ * Array of IDs for the newly created documents (one per composition).
857
+ */
858
+ pdf_compose(compositions: JsCompositions, doc_ids: string[]): string[];
859
+ /**
860
+ * Compress a PDF document.
861
+ *
862
+ * Saves the document with full compression options enabled:
863
+ * - Compress stream data using FlateDecode
864
+ * - Pack objects into compressed object streams (PDF 1.5+)
865
+ * - Use compressed xref streams (PDF 1.5+)
866
+ * - Remove unreferenced objects
867
+ *
868
+ * # Arguments
869
+ * * `doc_id` - Document ID to compress
870
+ *
871
+ * # Returns
872
+ * Compressed PDF data as Uint8Array
873
+ */
874
+ pdf_compress(doc_id: string): Uint8Array;
875
+ /**
876
+ * Decompress a PDF document.
877
+ *
878
+ * Removes all filter encodings from streams, resulting in raw,
879
+ * uncompressed stream data. Useful for debugging or inspection.
880
+ *
881
+ * # Arguments
882
+ * * `doc_id` - Document ID to decompress
883
+ *
884
+ * # Returns
885
+ * Decompressed PDF data as Uint8Array
886
+ */
887
+ pdf_decompress(doc_id: string): Uint8Array;
888
+ /**
889
+ * Extract all embedded fonts from a PDF document.
890
+ *
891
+ * # Arguments
892
+ * * `doc_id` - Document ID to extract fonts from
893
+ *
894
+ * # Returns
895
+ * Array of extracted font objects, each with:
896
+ * - `name`: Font name from the resource dictionary
897
+ * - `fontType`: Font type (Type1, TrueType, etc.)
898
+ * - `extension`: File extension (ttf, cff, t1, etc.)
899
+ * - `data`: Raw font data as Uint8Array
900
+ */
901
+ pdf_extract_fonts(doc_id: string): JsExtractedFont[];
902
+ /**
903
+ * Extract all embedded images from a PDF document.
904
+ *
905
+ * # Arguments
906
+ * * `doc_id` - Document ID to extract images from
907
+ * * `convert_raw_to_png` - When true, converts raw pixel data to PNG format
908
+ *
909
+ * # Returns
910
+ * Array of extracted image objects, each with:
911
+ * - `name`: Image name from the resource dictionary
912
+ * - `format`: Image format (jpeg, png, jp2, etc.)
913
+ * - `width`: Width in pixels
914
+ * - `height`: Height in pixels
915
+ * - `data`: Raw image data as Uint8Array
916
+ */
917
+ pdf_extract_images(doc_id: string, convert_raw_to_png: boolean): JsExtractedImage[];
918
+ /**
919
+ * Save annotations back to a PDF document.
920
+ *
921
+ * Takes the current document and a set of annotations (grouped by page),
922
+ * writes them into the PDF's annotation structures, and returns the
923
+ * modified PDF bytes.
924
+ *
925
+ * # Coordinate space
926
+ *
927
+ * Every geometry field on the supplied annotations (`bounds`, `quads`,
928
+ * `vertices`, `inkList`, `start`/`end`, `calloutLine`, …) must be in
929
+ * the page's **unrotated MediaBox** coordinate space:
930
+ *
931
+ * - Origin = MediaBox top-left of the page in its natural (pre-`/Rotate`)
932
+ * orientation. `(0, 0)` does not move when the page is displayed
933
+ * rotated 90°/180°/270°.
934
+ * - Units = PDF points (1/72 inch).
935
+ * - Axes = `+x` right, `+y` downward (Y-flipped relative to PDF's native
936
+ * bottom-up `/Rect`; this function performs the flip on the way out).
937
+ * - `CropBox` is ignored — coordinates are MediaBox-relative even when
938
+ * the page's CropBox trims the visible area.
939
+ *
940
+ * This is the same space returned by `get_page_annotations` /
941
+ * `get_all_annotations`, so a load-edit-save round-trip is consistent.
942
+ * Pages with no existing `/Annots` array are handled automatically: any
943
+ * pre-existing array is cleared and a fresh one is created.
944
+ *
945
+ * # Arguments
946
+ * * `doc_id` - Document ID
947
+ * * `annotations_by_page` - Object mapping page indices (as strings) to
948
+ * arrays of annotation objects. Same schema as returned by
949
+ * `get_all_annotations`.
950
+ *
951
+ * # Returns
952
+ * The modified PDF file bytes with annotations saved.
953
+ *
954
+ * # Example (JavaScript)
955
+ * ```js
956
+ * const annotations = udoc.get_all_annotations(docId);
957
+ * // ... viewer edits annotations ...
958
+ * const pdfBytes = udoc.pdf_save_annotations(docId, annotations);
959
+ * ```
960
+ */
961
+ pdf_save_annotations(doc_id: string, annotations_by_page: JsAnnotationsByPage): Uint8Array;
962
+ /**
963
+ * Split a PDF document by its outline (bookmarks) structure.
964
+ *
965
+ * Creates multiple documents, one for each outline section at the specified level.
966
+ *
967
+ * # Arguments
968
+ * * `doc_id` - Document ID to split
969
+ * * `max_level` - Maximum outline level to consider (1 = top level only)
970
+ * * `split_mid_page` - When true, filters page content when sections share a page
971
+ *
972
+ * # Returns
973
+ * Object with:
974
+ * - `documentIds`: Array of IDs for the newly created documents
975
+ * - `sections`: Array of section info objects with `title`, `startPage`, `level`
976
+ */
977
+ pdf_split_by_outline(doc_id: string, max_level: number, split_mid_page: boolean): JsSplitByOutlineResult;
978
+ /**
979
+ * Register font URLs.
980
+ *
981
+ * The caller provides a list of all available fonts with their download
982
+ * URLs. During layout, when the engine needs a font, it is fetched from
983
+ * the URL, parsed, and cached for reuse.
984
+ *
985
+ * Call this before loading documents. Registered fonts are automatically
986
+ * applied to every document loaded afterward. URL fonts are always
987
+ * resolved before Google Fonts.
988
+ *
989
+ * # Arguments
990
+ * * `fonts` - Array of font entries: `[{ typeface: "Roboto", bold: false, italic: false, url: "https://..." }, ...]`
991
+ *
992
+ * # Example (JavaScript)
993
+ * ```js
994
+ * // Register available fonts before loading documents
995
+ * udoc.registerFonts([
996
+ * { typeface: "Roboto", bold: false, italic: false, url: "https://cdn.example.com/Roboto-Regular.woff2" },
997
+ * { typeface: "Roboto", bold: true, italic: false, url: "https://cdn.example.com/Roboto-Bold.woff2" },
998
+ * ]);
999
+ *
1000
+ * // Load and render - fonts are fetched on demand during layout
1001
+ * const docId = udoc.loadPptx(pptxBytes);
1002
+ * const pixels = udoc.renderPageToRgba(docId, 0, 800, 600);
1003
+ * ```
1004
+ */
1005
+ registerFonts(fonts: JsFontRegistration[]): void;
1006
+ /**
1007
+ * Remove a document by ID.
1008
+ *
1009
+ * Returns true if the document was removed, false if it didn't exist.
1010
+ */
1011
+ remove_document(id: string): boolean;
1012
+ /**
1013
+ * Render a page using the GPU backend (Vello + WebGPU).
1014
+ *
1015
+ * Returns raw RGBA pixel data in premultiplied alpha format,
1016
+ * identical to `render_page_to_rgba` but GPU-accelerated.
1017
+ *
1018
+ * # Errors
1019
+ * Returns an error if the GPU backend is not initialized
1020
+ * (call `init_gpu()` first), if the document is not found,
1021
+ * or if rendering fails.
1022
+ */
1023
+ render_page_gpu(id: string, page_index: number, width: number, height: number): Promise<Uint8Array>;
1024
+ /**
1025
+ * Render a page to PNG bytes.
1026
+ *
1027
+ * # Arguments
1028
+ * * `id` - Document ID
1029
+ * * `page_index` - Zero-based page index
1030
+ * * `width` - Output width in pixels
1031
+ * * `height` - Output height in pixels
1032
+ *
1033
+ * # Returns
1034
+ * PNG-encoded image data as a byte array.
1035
+ */
1036
+ render_page_to_png(id: string, page_index: number, width: number, height: number): Uint8Array;
1037
+ /**
1038
+ * Render a page to raw RGBA pixel data.
1039
+ *
1040
+ * The returned data is in premultiplied alpha format, suitable for
1041
+ * use with `ImageData` and canvas rendering.
1042
+ *
1043
+ * # Arguments
1044
+ * * `id` - Document ID
1045
+ * * `page_index` - Zero-based page index
1046
+ * * `width` - Output width in pixels
1047
+ * * `height` - Output height in pixels
1048
+ *
1049
+ * # Returns
1050
+ * Raw RGBA pixel data (width * height * 4 bytes).
1051
+ */
1052
+ render_page_to_rgba(id: string, page_index: number, width: number, height: number): Uint8Array;
1053
+ /**
1054
+ * Set the license key.
1055
+ *
1056
+ * # Arguments
1057
+ * * `license_key` - The license key string
1058
+ *
1059
+ * # Returns
1060
+ * License validation result as JSON.
1061
+ */
1062
+ set_license(license_key: string): LicenseResult;
1063
+ /**
1064
+ * Set the visibility of a specific visibility group.
1065
+ *
1066
+ * # Arguments
1067
+ * * `id` - Document ID
1068
+ * * `group_id` - Visibility group ID
1069
+ * * `visible` - Whether the group should be visible
1070
+ *
1071
+ * Returns `true` if the group was found and updated, `false` if not found.
1072
+ */
1073
+ set_visibility_group_visible(id: string, group_id: string, visible: boolean): boolean;
1074
+ /**
1075
+ * Set the anonymous distinct ID for telemetry tracking.
1076
+ *
1077
+ * Call this after `new()` once the ID has been read from localStorage
1078
+ * (or generated). Must be called before loading documents so that
1079
+ * telemetry events include the correct metadata.
1080
+ *
1081
+ * # Arguments
1082
+ * * `distinct_id` - Anonymous UUID for per-user tracking (persisted in localStorage)
1083
+ */
1084
+ setup_telemetry(distinct_id: string): void;
1085
+ /**
1086
+ * Get viewer preferences embedded in the document.
1087
+ *
1088
+ * Returns a `JsViewerPreferences` with optional fields:
1089
+ * - `layoutMode`: `"single-page"` | `"double-page-odd-right"` | `"double-page-odd-left"`
1090
+ * - `scrollMode`: `"spread"` | `"continuous"`
1091
+ */
1092
+ viewer_preferences(id: string): JsViewerPreferences;
1093
+ /**
1094
+ * Get the number of documents currently loaded.
1095
+ */
1096
+ readonly document_count: number;
1092
1097
  }
1093
1098
 
1094
1099
  /**
@@ -1122,84 +1127,85 @@ export function parseFontInfo(data: Uint8Array): JsParsedFontInfo;
1122
1127
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
1123
1128
 
1124
1129
  export interface InitOutput {
1125
- readonly memory: WebAssembly.Memory;
1126
- readonly __wbg_wasm_free: (a: number, b: number) => void;
1127
- readonly parseFontInfo: (a: number, b: number, c: number) => void;
1128
- readonly wasm_all_page_info: (a: number, b: number, c: number, d: number) => void;
1129
- readonly wasm_authenticate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1130
- readonly wasm_disable_telemetry: (a: number) => number;
1131
- readonly wasm_document_count: (a: number) => number;
1132
- readonly wasm_document_format: (a: number, b: number, c: number, d: number) => void;
1133
- readonly wasm_document_ids: (a: number, b: number) => void;
1134
- readonly wasm_enableGoogleFonts: (a: number) => void;
1135
- readonly wasm_get_all_annotations: (a: number, b: number, c: number, d: number) => void;
1136
- readonly wasm_get_bytes: (a: number, b: number, c: number, d: number) => void;
1137
- readonly wasm_get_font_usage: (a: number, b: number, c: number, d: number) => void;
1138
- readonly wasm_get_layout_page: (a: number, b: number, c: number, d: number, e: number) => void;
1139
- readonly wasm_get_limit: (a: number, b: number, c: number, d: bigint) => bigint;
1140
- readonly wasm_get_outline: (a: number, b: number, c: number, d: number) => void;
1141
- readonly wasm_get_page_annotations: (a: number, b: number, c: number, d: number, e: number) => void;
1142
- readonly wasm_get_visibility_groups: (a: number, b: number, c: number, d: number) => void;
1143
- readonly wasm_has_document: (a: number, b: number, c: number) => number;
1144
- readonly wasm_has_feature: (a: number, b: number, c: number) => number;
1145
- readonly wasm_has_gpu: (a: number) => number;
1146
- readonly wasm_init_gpu: (a: number) => number;
1147
- readonly wasm_license_status: (a: number) => number;
1148
- readonly wasm_load: (a: number, b: number, c: number, d: number) => void;
1149
- readonly wasm_load_docx: (a: number, b: number, c: number, d: number) => void;
1150
- readonly wasm_load_image: (a: number, b: number, c: number, d: number) => void;
1151
- readonly wasm_load_pdf: (a: number, b: number, c: number, d: number) => void;
1152
- readonly wasm_load_pptx: (a: number, b: number, c: number, d: number) => void;
1153
- readonly wasm_load_xlsx: (a: number, b: number, c: number, d: number) => void;
1154
- readonly wasm_needs_password: (a: number, b: number, c: number, d: number) => void;
1155
- readonly wasm_new: (a: number, b: number, c: number, d: number) => number;
1156
- readonly wasm_page_count: (a: number, b: number, c: number, d: number) => void;
1157
- readonly wasm_page_groups: (a: number, b: number, c: number, d: number) => void;
1158
- readonly wasm_page_info: (a: number, b: number, c: number, d: number, e: number) => void;
1159
- readonly wasm_pdf_compose: (a: number, b: number, c: number, d: number, e: number) => void;
1160
- readonly wasm_pdf_compress: (a: number, b: number, c: number, d: number) => void;
1161
- readonly wasm_pdf_decompress: (a: number, b: number, c: number, d: number) => void;
1162
- readonly wasm_pdf_extract_fonts: (a: number, b: number, c: number, d: number) => void;
1163
- readonly wasm_pdf_extract_images: (a: number, b: number, c: number, d: number, e: number) => void;
1164
- readonly wasm_pdf_save_annotations: (a: number, b: number, c: number, d: number, e: number) => void;
1165
- readonly wasm_pdf_split_by_outline: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1166
- readonly wasm_registerFonts: (a: number, b: number, c: number, d: number) => void;
1167
- readonly wasm_remove_document: (a: number, b: number, c: number) => number;
1168
- readonly wasm_render_page_gpu: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
1169
- readonly wasm_render_page_to_png: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1170
- readonly wasm_render_page_to_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1171
- readonly wasm_set_license: (a: number, b: number, c: number) => number;
1172
- readonly wasm_set_visibility_group_visible: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1173
- readonly wasm_setup_telemetry: (a: number, b: number, c: number) => void;
1174
- readonly wasm_viewer_preferences: (a: number, b: number, c: number, d: number) => void;
1175
- readonly __wasm_bindgen_func_elem_4195: (a: number, b: number, c: number) => void;
1176
- readonly __wasm_bindgen_func_elem_4179: (a: number, b: number) => void;
1177
- readonly __wasm_bindgen_func_elem_22595: (a: number, b: number, c: number, d: number) => void;
1178
- readonly __wbindgen_export: (a: number, b: number) => number;
1179
- readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
1180
- readonly __wbindgen_export3: (a: number) => void;
1181
- readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
1182
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
1130
+ readonly memory: WebAssembly.Memory;
1131
+ readonly __wbg_wasm_free: (a: number, b: number) => void;
1132
+ readonly parseFontInfo: (a: number, b: number, c: number) => void;
1133
+ readonly wasm_all_page_info: (a: number, b: number, c: number, d: number) => void;
1134
+ readonly wasm_authenticate: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1135
+ readonly wasm_disable_telemetry: (a: number) => number;
1136
+ readonly wasm_document_count: (a: number) => number;
1137
+ readonly wasm_document_format: (a: number, b: number, c: number, d: number) => void;
1138
+ readonly wasm_document_ids: (a: number, b: number) => void;
1139
+ readonly wasm_enableGoogleFonts: (a: number) => void;
1140
+ readonly wasm_get_all_annotations: (a: number, b: number, c: number, d: number) => void;
1141
+ readonly wasm_get_bytes: (a: number, b: number, c: number, d: number) => void;
1142
+ readonly wasm_get_font_usage: (a: number, b: number, c: number, d: number) => void;
1143
+ readonly wasm_get_layout_page: (a: number, b: number, c: number, d: number, e: number) => void;
1144
+ readonly wasm_get_limit: (a: number, b: number, c: number, d: bigint) => bigint;
1145
+ readonly wasm_get_outline: (a: number, b: number, c: number, d: number) => void;
1146
+ readonly wasm_get_page_annotations: (a: number, b: number, c: number, d: number, e: number) => void;
1147
+ readonly wasm_get_visibility_groups: (a: number, b: number, c: number, d: number) => void;
1148
+ readonly wasm_has_document: (a: number, b: number, c: number) => number;
1149
+ readonly wasm_has_feature: (a: number, b: number, c: number) => number;
1150
+ readonly wasm_has_gpu: (a: number) => number;
1151
+ readonly wasm_init_gpu: (a: number) => number;
1152
+ readonly wasm_license_status: (a: number) => number;
1153
+ readonly wasm_load: (a: number, b: number, c: number, d: number) => void;
1154
+ readonly wasm_load_docx: (a: number, b: number, c: number, d: number) => void;
1155
+ readonly wasm_load_image: (a: number, b: number, c: number, d: number) => void;
1156
+ readonly wasm_load_pdf: (a: number, b: number, c: number, d: number) => void;
1157
+ readonly wasm_load_pptx: (a: number, b: number, c: number, d: number) => void;
1158
+ readonly wasm_load_xlsx: (a: number, b: number, c: number, d: number) => void;
1159
+ readonly wasm_needs_password: (a: number, b: number, c: number, d: number) => void;
1160
+ readonly wasm_new: (a: number, b: number, c: number, d: number) => number;
1161
+ readonly wasm_page_count: (a: number, b: number, c: number, d: number) => void;
1162
+ readonly wasm_page_groups: (a: number, b: number, c: number, d: number) => void;
1163
+ readonly wasm_page_info: (a: number, b: number, c: number, d: number, e: number) => void;
1164
+ readonly wasm_pdf_compose: (a: number, b: number, c: number, d: number, e: number) => void;
1165
+ readonly wasm_pdf_compress: (a: number, b: number, c: number, d: number) => void;
1166
+ readonly wasm_pdf_decompress: (a: number, b: number, c: number, d: number) => void;
1167
+ readonly wasm_pdf_extract_fonts: (a: number, b: number, c: number, d: number) => void;
1168
+ readonly wasm_pdf_extract_images: (a: number, b: number, c: number, d: number, e: number) => void;
1169
+ readonly wasm_pdf_save_annotations: (a: number, b: number, c: number, d: number, e: number) => void;
1170
+ readonly wasm_pdf_split_by_outline: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
1171
+ readonly wasm_registerFonts: (a: number, b: number, c: number, d: number) => void;
1172
+ readonly wasm_remove_document: (a: number, b: number, c: number) => number;
1173
+ readonly wasm_render_page_gpu: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
1174
+ readonly wasm_render_page_to_png: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1175
+ readonly wasm_render_page_to_rgba: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1176
+ readonly wasm_set_license: (a: number, b: number, c: number) => number;
1177
+ readonly wasm_set_visibility_group_visible: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
1178
+ readonly wasm_setup_telemetry: (a: number, b: number, c: number) => void;
1179
+ readonly wasm_viewer_preferences: (a: number, b: number, c: number, d: number) => void;
1180
+ readonly __wasm_bindgen_func_elem_22721: (a: number, b: number, c: number, d: number) => void;
1181
+ readonly __wasm_bindgen_func_elem_22734: (a: number, b: number, c: number, d: number) => void;
1182
+ readonly __wasm_bindgen_func_elem_3565: (a: number, b: number, c: number) => void;
1183
+ readonly __wbindgen_export: (a: number, b: number) => number;
1184
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
1185
+ readonly __wbindgen_export3: (a: number) => void;
1186
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
1187
+ readonly __wbindgen_export5: (a: number, b: number) => void;
1188
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
1183
1189
  }
1184
1190
 
1185
1191
  export type SyncInitInput = BufferSource | WebAssembly.Module;
1186
1192
 
1187
1193
  /**
1188
- * Instantiates the given `module`, which can either be bytes or
1189
- * a precompiled `WebAssembly.Module`.
1190
- *
1191
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1192
- *
1193
- * @returns {InitOutput}
1194
- */
1194
+ * Instantiates the given `module`, which can either be bytes or
1195
+ * a precompiled `WebAssembly.Module`.
1196
+ *
1197
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
1198
+ *
1199
+ * @returns {InitOutput}
1200
+ */
1195
1201
  export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
1196
1202
 
1197
1203
  /**
1198
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1199
- * for everything else, calls `WebAssembly.instantiate` directly.
1200
- *
1201
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1202
- *
1203
- * @returns {Promise<InitOutput>}
1204
- */
1204
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
1205
+ * for everything else, calls `WebAssembly.instantiate` directly.
1206
+ *
1207
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
1208
+ *
1209
+ * @returns {Promise<InitOutput>}
1210
+ */
1205
1211
  export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;