@embedpdf/engines 1.0.10 → 1.0.12

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.
Files changed (104) hide show
  1. package/dist/engine-B7CS6Qyp.cjs +2 -0
  2. package/dist/engine-B7CS6Qyp.cjs.map +1 -0
  3. package/dist/engine-M0_XZhss.js +5043 -0
  4. package/dist/engine-M0_XZhss.js.map +1 -0
  5. package/dist/index.cjs +1 -5846
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +1 -1613
  8. package/dist/index.js +339 -5824
  9. package/dist/index.js.map +1 -1
  10. package/dist/lib/converters/index.cjs +2 -0
  11. package/dist/lib/converters/index.cjs.map +1 -0
  12. package/dist/{converters.d.ts → lib/converters/index.d.ts} +7 -10
  13. package/dist/lib/converters/index.js +80 -0
  14. package/dist/{converters.cjs.map → lib/converters/index.js.map} +1 -1
  15. package/dist/lib/index.d.ts +7 -0
  16. package/dist/lib/mock/index.d.ts +25 -0
  17. package/dist/lib/pdfium/cache.d.ts +62 -0
  18. package/dist/{pdfium-direct-engine.d.ts → lib/pdfium/engine.d.ts} +73 -8
  19. package/dist/lib/pdfium/helper.d.ts +21 -0
  20. package/dist/lib/pdfium/index.cjs +2 -0
  21. package/dist/lib/pdfium/index.cjs.map +1 -0
  22. package/dist/lib/pdfium/index.d.ts +3 -0
  23. package/dist/lib/pdfium/index.js +13 -0
  24. package/dist/lib/pdfium/index.js.map +1 -0
  25. package/dist/lib/pdfium/runner.d.ts +16 -0
  26. package/dist/lib/pdfium/web/direct-engine.cjs +2 -0
  27. package/dist/lib/pdfium/web/direct-engine.cjs.map +1 -0
  28. package/dist/lib/pdfium/web/direct-engine.d.ts +3 -0
  29. package/dist/lib/pdfium/web/direct-engine.js +12 -0
  30. package/dist/lib/pdfium/web/direct-engine.js.map +1 -0
  31. package/dist/lib/pdfium/web/worker-engine.cjs +2 -0
  32. package/dist/lib/pdfium/web/worker-engine.cjs.map +1 -0
  33. package/dist/lib/pdfium/web/worker-engine.d.ts +7 -0
  34. package/dist/lib/pdfium/web/worker-engine.js +15 -0
  35. package/dist/lib/pdfium/web/worker-engine.js.map +1 -0
  36. package/dist/lib/pdfium/worker.d.ts +1 -0
  37. package/dist/lib/pdfium-engine.d.ts +1 -0
  38. package/dist/lib/webworker/engine.cjs +2 -0
  39. package/dist/lib/webworker/engine.cjs.map +1 -0
  40. package/dist/{worker.d.ts → lib/webworker/engine.d.ts} +4 -34
  41. package/dist/lib/webworker/engine.js +887 -0
  42. package/dist/lib/webworker/engine.js.map +1 -0
  43. package/dist/lib/webworker/index.d.ts +2 -0
  44. package/dist/lib/webworker/runner.d.ts +128 -0
  45. package/dist/lib/webworker-engine.d.ts +1 -0
  46. package/dist/preact/adapter.d.ts +1 -0
  47. package/dist/preact/index.cjs +2 -0
  48. package/dist/preact/index.cjs.map +1 -0
  49. package/dist/preact/index.d.ts +1 -0
  50. package/dist/preact/index.js +37 -0
  51. package/dist/preact/index.js.map +1 -0
  52. package/dist/react/adapter.d.ts +1 -0
  53. package/dist/react/index.cjs +2 -0
  54. package/dist/react/index.cjs.map +1 -0
  55. package/dist/react/index.d.ts +1 -0
  56. package/dist/react/index.js +37 -0
  57. package/dist/react/index.js.map +1 -0
  58. package/dist/runner-BcS-WEof.cjs +2 -0
  59. package/dist/runner-BcS-WEof.cjs.map +1 -0
  60. package/dist/runner-DUp_7Uu_.js +269 -0
  61. package/dist/runner-DUp_7Uu_.js.map +1 -0
  62. package/dist/shared-preact/hooks/index.d.ts +1 -0
  63. package/dist/{preact.d.ts → shared-preact/hooks/use-pdfium-engine.d.ts} +3 -5
  64. package/dist/shared-preact/index.d.ts +1 -0
  65. package/dist/shared-react/hooks/index.d.ts +1 -0
  66. package/dist/{react.d.ts → shared-react/hooks/use-pdfium-engine.d.ts} +3 -5
  67. package/dist/shared-react/index.d.ts +1 -0
  68. package/dist/vue/hooks/index.d.ts +1 -0
  69. package/dist/vue/hooks/use-pdfium-engine.d.ts +18 -0
  70. package/dist/vue/index.cjs +2 -0
  71. package/dist/vue/index.cjs.map +1 -0
  72. package/dist/vue/index.d.ts +1 -0
  73. package/dist/vue/index.js +39 -0
  74. package/dist/vue/index.js.map +1 -0
  75. package/package.json +41 -41
  76. package/dist/converters.cjs +0 -139
  77. package/dist/converters.js +0 -133
  78. package/dist/converters.js.map +0 -1
  79. package/dist/pdfium-direct-engine.cjs +0 -4400
  80. package/dist/pdfium-direct-engine.cjs.map +0 -1
  81. package/dist/pdfium-direct-engine.js +0 -4398
  82. package/dist/pdfium-direct-engine.js.map +0 -1
  83. package/dist/pdfium-worker-engine.cjs +0 -851
  84. package/dist/pdfium-worker-engine.cjs.map +0 -1
  85. package/dist/pdfium-worker-engine.d.ts +0 -314
  86. package/dist/pdfium-worker-engine.js +0 -849
  87. package/dist/pdfium-worker-engine.js.map +0 -1
  88. package/dist/pdfium.cjs +0 -4667
  89. package/dist/pdfium.cjs.map +0 -1
  90. package/dist/pdfium.d.ts +0 -1311
  91. package/dist/pdfium.js +0 -4661
  92. package/dist/pdfium.js.map +0 -1
  93. package/dist/preact.cjs +0 -41
  94. package/dist/preact.cjs.map +0 -1
  95. package/dist/preact.js +0 -39
  96. package/dist/preact.js.map +0 -1
  97. package/dist/react.cjs +0 -41
  98. package/dist/react.cjs.map +0 -1
  99. package/dist/react.js +0 -39
  100. package/dist/react.js.map +0 -1
  101. package/dist/worker.cjs +0 -839
  102. package/dist/worker.cjs.map +0 -1
  103. package/dist/worker.js +0 -836
  104. package/dist/worker.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,1613 +1 @@
1
- import { SearchTarget, PdfImage, ImageConversionTypes, PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, PdfTask, Rect, PdfAnnotationObject, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PageTextSlice, PdfInkAnnoObject, PdfHighlightAnnoObject, PdfUnderlineAnnoObject, PdfStrikeOutAnnoObject, PdfSquigglyAnnoObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, AppearanceMode, PdfAnnotationObjectBase, WebAlphaColor, MatchFlag, SearchAllPagesResult, PdfEngineMethodName, PdfEngineMethodArgs, TaskReturn, PdfEngineMethodReturnType, PdfMetadataObject, PdfBookmarksObject } from '@embedpdf/models';
2
- import { WrappedPdfiumModule, PdfiumRuntimeMethods, PdfiumModule } from '@embedpdf/pdfium';
3
-
4
- /**
5
- * Format of bitmap
6
- */
7
- declare enum BitmapFormat {
8
- Bitmap_Gray = 1,
9
- Bitmap_BGR = 2,
10
- Bitmap_BGRx = 3,
11
- Bitmap_BGRA = 4
12
- }
13
- /**
14
- * Pdf rendering flag
15
- */
16
- declare enum RenderFlag {
17
- ANNOT = 1,// Set if annotations are to be rendered.
18
- LCD_TEXT = 2,// Set if using text rendering optimized for LCD display.
19
- NO_NATIVETEXT = 4,// Don't use the native text output available on some platforms
20
- GRAYSCALE = 8,// Grayscale output.
21
- DEBUG_INFO = 128,// Set if you want to get some debug info. Please discuss with Foxit first if you need to collect debug info.
22
- NO_CATCH = 256,// Set if you don't want to catch exception.
23
- RENDER_LIMITEDIMAGECACHE = 512,// Limit image cache size.
24
- RENDER_FORCEHALFTONE = 1024,// Always use halftone for image stretching.
25
- PRINTING = 2048,// Render for printing.
26
- REVERSE_BYTE_ORDER = 16
27
- }
28
- /**
29
- * Context used for searching
30
- */
31
- interface SearchContext {
32
- /**
33
- * search target
34
- */
35
- target: SearchTarget;
36
- /**
37
- * current page index
38
- */
39
- currPageIndex: number;
40
- /**
41
- * index of text in the current pdf page, -1 means reach the end
42
- */
43
- startIndex: number;
44
- }
45
- /**
46
- * Error code of pdfium library
47
- */
48
- declare enum PdfiumErrorCode {
49
- Success = 0,
50
- Unknown = 1,
51
- File = 2,
52
- Format = 3,
53
- Password = 4,
54
- Security = 5,
55
- Page = 6,
56
- XFALoad = 7,
57
- XFALayout = 8
58
- }
59
- /**
60
- * Function type for converting ImageData to Blob
61
- * In browser: uses OffscreenCanvas
62
- * In Node.js: can use Sharp or other image processing libraries
63
- */
64
- type ImageDataConverter<T = Blob> = (imageData: PdfImage, imageType?: ImageConversionTypes) => Promise<T>;
65
- declare const browserImageDataToBlobConverter: ImageDataConverter<Blob>;
66
- /**
67
- * Pdf engine that based on pdfium wasm
68
- */
69
- declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
70
- private pdfiumModule;
71
- private logger;
72
- private imageDataConverter;
73
- /**
74
- * pdf documents that opened
75
- */
76
- private readonly cache;
77
- /**
78
- * Create an instance of PdfiumEngine
79
- * @param wasmModule - pdfium wasm module
80
- * @param logger - logger instance
81
- * @param imageDataToBlobConverter - function to convert ImageData to Blob
82
- */
83
- constructor(pdfiumModule: WrappedPdfiumModule, logger?: Logger, imageDataConverter?: ImageDataConverter<T>);
84
- /**
85
- * {@inheritDoc @embedpdf/models!PdfEngine.initialize}
86
- *
87
- * @public
88
- */
89
- initialize(): Task<boolean, PdfErrorReason>;
90
- /**
91
- * {@inheritDoc @embedpdf/models!PdfEngine.destroy}
92
- *
93
- * @public
94
- */
95
- destroy(): Task<boolean, PdfErrorReason>;
96
- /**
97
- * {@inheritDoc @embedpdf/models!PdfEngine.openDocumentUrl}
98
- *
99
- * @public
100
- */
101
- openDocumentUrl(file: PdfFileUrl, options?: PdfUrlOptions): Task<PdfDocumentObject, PdfErrorReason>;
102
- /**
103
- * Check if the server supports range requests:
104
- * Sends a HEAD request and sees if 'Accept-Ranges: bytes'.
105
- */
106
- private checkRangeSupport;
107
- /**
108
- * Fully fetch the file (using fetch) into an ArrayBuffer,
109
- * then call openDocumentFromBuffer.
110
- */
111
- private fetchFullAndOpen;
112
- /**
113
- * Use your synchronous partial-loading approach:
114
- * - In your snippet, it's done via `openDocumentFromLoader`.
115
- * - We'll do a synchronous XHR read callback that pulls
116
- * the desired byte ranges.
117
- */
118
- private openDocumentWithRangeRequest;
119
- /**
120
- * Helper to do a HEAD request or partial GET to find file length.
121
- */
122
- private retrieveFileLength;
123
- /**
124
- * Convert response text (x-user-defined) to a Uint8Array
125
- * for partial data.
126
- */
127
- private convertResponseToUint8Array;
128
- /**
129
- * {@inheritDoc @embedpdf/models!PdfEngine.openDocument}
130
- *
131
- * @public
132
- */
133
- openDocumentFromBuffer(file: PdfFile, password?: string): Task<PdfDocumentObject, PdfErrorReason>;
134
- /**
135
- * {@inheritDoc @embedpdf/models!PdfEngine.openDocumentFromLoader}
136
- *
137
- * @public
138
- */
139
- openDocumentFromLoader(fileLoader: PdfFileLoader, password?: string): Task<PdfDocumentObject, PdfErrorReason>;
140
- /**
141
- * {@inheritDoc @embedpdf/models!PdfEngine.getMetadata}
142
- *
143
- * @public
144
- */
145
- getMetadata(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<{
146
- title: string;
147
- author: string;
148
- subject: string;
149
- keywords: string;
150
- producer: string;
151
- creator: string;
152
- creationDate: string;
153
- modificationDate: string;
154
- }, PdfErrorReason>;
155
- /**
156
- * {@inheritDoc @embedpdf/models!PdfEngine.getDocPermissions}
157
- *
158
- * @public
159
- */
160
- getDocPermissions(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<number, PdfErrorReason>;
161
- /**
162
- * {@inheritDoc @embedpdf/models!PdfEngine.getDocUserPermissions}
163
- *
164
- * @public
165
- */
166
- getDocUserPermissions(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<number, PdfErrorReason>;
167
- /**
168
- * {@inheritDoc @embedpdf/models!PdfEngine.getSignatures}
169
- *
170
- * @public
171
- */
172
- getSignatures(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<PdfSignatureObject[], PdfErrorReason>;
173
- /**
174
- * {@inheritDoc @embedpdf/models!PdfEngine.getBookmarks}
175
- *
176
- * @public
177
- */
178
- getBookmarks(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<{
179
- bookmarks: PdfBookmarkObject[];
180
- }, PdfErrorReason>;
181
- /**
182
- * {@inheritDoc @embedpdf/models!PdfEngine.renderPage}
183
- *
184
- * @public
185
- */
186
- renderPage(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor?: number, rotation?: Rotation, dpr?: number, options?: PdfRenderOptions, imageType?: ImageConversionTypes): PdfTask<T>;
187
- /**
188
- * {@inheritDoc @embedpdf/models!PdfEngine.renderPageRect}
189
- *
190
- * @public
191
- */
192
- renderPageRect(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, rect: Rect, options: PdfRenderOptions, imageType?: ImageConversionTypes): PdfTask<T>;
193
- /**
194
- * {@inheritDoc @embedpdf/models!PdfEngine.getAllAnnotations}
195
- *
196
- * @public
197
- */
198
- getAllAnnotations(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<Record<number, PdfAnnotationObject[]>, PdfErrorReason>;
199
- private readAllAnnotations;
200
- /**
201
- * {@inheritDoc @embedpdf/models!PdfEngine.getPageAnnotations}
202
- *
203
- * @public
204
- */
205
- getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): Task<any, PdfErrorReason> | Task<PdfAnnotationObject[], PdfErrorReason>;
206
- /**
207
- * {@inheritDoc @embedpdf/models!PdfEngine.createPageAnnotation}
208
- *
209
- * @public
210
- */
211
- createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<number>;
212
- /**
213
- * Update an existing page annotation in-place
214
- *
215
- * • Locates the annot by page-local index (`annotation.id`)
216
- * • Re-writes its /Rect and type-specific payload
217
- * • Calls FPDFPage_GenerateContent so the new appearance is rendered
218
- *
219
- * @returns PdfTask<boolean> – true on success
220
- */
221
- updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): PdfTask<boolean>;
222
- /**
223
- * {@inheritDoc @embedpdf/models!PdfEngine.removePageAnnotation}
224
- *
225
- * @public
226
- */
227
- removePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
228
- /**
229
- * {@inheritDoc @embedpdf/models!PdfEngine.getPageTextRects}
230
- *
231
- * @public
232
- */
233
- getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation): Task<any, PdfErrorReason> | Task<PdfTextRectObject[], PdfErrorReason>;
234
- /**
235
- * {@inheritDoc @embedpdf/models!PdfEngine.renderThumbnail}
236
- *
237
- * @public
238
- */
239
- renderThumbnail(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number): PdfTask<T>;
240
- /**
241
- * {@inheritDoc @embedpdf/models!PdfEngine.getAttachments}
242
- *
243
- * @public
244
- */
245
- getAttachments(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<PdfAttachmentObject[], PdfErrorReason>;
246
- /**
247
- * {@inheritDoc @embedpdf/models!PdfEngine.readAttachmentContent}
248
- *
249
- * @public
250
- */
251
- readAttachmentContent(doc: PdfDocumentObject, attachment: PdfAttachmentObject): Task<any, PdfErrorReason> | Task<ArrayBuffer, PdfErrorReason>;
252
- /**
253
- * {@inheritDoc @embedpdf/models!PdfEngine.setFormFieldValue}
254
- *
255
- * @public
256
- */
257
- setFormFieldValue(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfWidgetAnnoObject, value: FormFieldValue): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
258
- /**
259
- * {@inheritDoc @embedpdf/models!PdfEngine.flattenPage}
260
- *
261
- * @public
262
- */
263
- flattenPage(doc: PdfDocumentObject, page: PdfPageObject, flag: PdfPageFlattenFlag): PdfTask<PdfPageFlattenResult>;
264
- /**
265
- * {@inheritDoc @embedpdf/models!PdfEngine.extractPages}
266
- *
267
- * @public
268
- */
269
- extractPages(doc: PdfDocumentObject, pageIndexes: number[]): Task<any, PdfErrorReason> | Task<ArrayBuffer, PdfErrorReason>;
270
- /**
271
- * {@inheritDoc @embedpdf/models!PdfEngine.extractText}
272
- *
273
- * @public
274
- */
275
- extractText(doc: PdfDocumentObject, pageIndexes: number[]): Task<any, PdfErrorReason> | Task<string, PdfErrorReason>;
276
- /**
277
- * {@inheritDoc @embedpdf/models!PdfEngine.getTextSlices}
278
- *
279
- * @public
280
- */
281
- getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): PdfTask<string[]>;
282
- /**
283
- * {@inheritDoc @embedpdf/models!PdfEngine.merge}
284
- *
285
- * @public
286
- */
287
- merge(files: PdfFile[]): Task<any, PdfErrorReason> | Task<PdfFile, PdfErrorReason>;
288
- /**
289
- * Merges specific pages from multiple PDF documents in a custom order
290
- *
291
- * @param mergeConfigs Array of configurations specifying which pages to merge from which documents
292
- * @returns A PdfTask that resolves with the merged PDF file
293
- * @public
294
- */
295
- mergePages(mergeConfigs: Array<{
296
- docId: string;
297
- pageIndices: number[];
298
- }>): Task<any, PdfErrorReason> | Task<PdfFile, PdfErrorReason>;
299
- /**
300
- * {@inheritDoc @embedpdf/models!PdfEngine.saveAsCopy}
301
- *
302
- * @public
303
- */
304
- saveAsCopy(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<ArrayBuffer, PdfErrorReason>;
305
- /**
306
- * {@inheritDoc @embedpdf/models!PdfEngine.closeDocument}
307
- *
308
- * @public
309
- */
310
- closeDocument(doc: PdfDocumentObject): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
311
- /**
312
- * Memory allocation
313
- * @param size - size of memory space
314
- * @returns pointer to memory space
315
- *
316
- * @public
317
- */
318
- malloc(size: number): number;
319
- /**
320
- * Free memory space
321
- * @param ptr pointer to memory space
322
- *
323
- * @public
324
- */
325
- free(ptr: number): void;
326
- /**
327
- * Set the rect of specified annotation
328
- * @param page - page info that the annotation is belonged to
329
- * @param pagePtr - pointer of page object
330
- * @param annotationPtr - pointer to annotation object
331
- * @param inkList - ink lists that added to the annotation
332
- * @returns whether the ink lists is setted
333
- *
334
- * @private
335
- */
336
- addInkStroke(page: PdfPageObject, pagePtr: number, annotationPtr: number, annotation: PdfInkAnnoObject): boolean;
337
- /**
338
- * Add highlight content to annotation
339
- * @param page - page info
340
- * @param annotationPtr - pointer to highlight annotation
341
- * @param annotation - highlight annotation
342
- * @returns whether highlight content is added to annotation
343
- *
344
- * @private
345
- */
346
- addTextMarkupContent(page: PdfPageObject, pagePtr: number, annotationPtr: number, annotation: PdfHighlightAnnoObject | PdfUnderlineAnnoObject | PdfStrikeOutAnnoObject | PdfSquigglyAnnoObject): boolean;
347
- /**
348
- * Add contents to stamp annotation
349
- * @param docPtr - pointer to pdf document object
350
- * @param page - page info
351
- * @param pagePtr - pointer to page object
352
- * @param annotationPtr - pointer to stamp annotation
353
- * @param rect - rect of stamp annotation
354
- * @param contents - contents of stamp annotation
355
- * @returns whether contents is added to annotation
356
- *
357
- * @private
358
- */
359
- addStampContent(docPtr: number, page: PdfPageObject, pagePtr: number, annotationPtr: number, rect: Rect, contents: PdfStampAnnoObjectContents): boolean;
360
- /**
361
- * Add image object to annotation
362
- * @param docPtr - pointer to pdf document object
363
- * @param page - page info
364
- * @param pagePtr - pointer to page object
365
- * @param annotationPtr - pointer to stamp annotation
366
- * @param position - position of image
367
- * @param imageData - data of image
368
- * @returns whether image is added to annotation
369
- *
370
- * @private
371
- */
372
- addImageObject(docPtr: number, page: PdfPageObject, pagePtr: number, annotationPtr: number, position: Position, imageData: ImageData): boolean;
373
- /**
374
- * Save document to array buffer
375
- * @param docPtr - pointer to pdf document
376
- * @returns array buffer contains the pdf content
377
- *
378
- * @private
379
- */
380
- saveDocument(docPtr: number): ArrayBuffer;
381
- /**
382
- * Read metadata from pdf document
383
- * @param docPtr - pointer to pdf document
384
- * @param key - key of metadata field
385
- * @returns metadata value
386
- *
387
- * @private
388
- */
389
- readMetaText(docPtr: number, key: string): string;
390
- /**
391
- * Read bookmarks in the pdf document
392
- * @param docPtr - pointer to pdf document
393
- * @param rootBookmarkPtr - pointer to root bookmark
394
- * @returns bookmarks in the pdf document
395
- *
396
- * @private
397
- */
398
- readPdfBookmarks(docPtr: number, rootBookmarkPtr?: number): PdfBookmarkObject[];
399
- /**
400
- * Read bookmark in the pdf document
401
- * @param docPtr - pointer to pdf document
402
- * @param bookmarkPtr - pointer to bookmark object
403
- * @returns pdf bookmark object
404
- *
405
- * @private
406
- */
407
- private readPdfBookmark;
408
- /**
409
- * Read text rects in pdf page
410
- * @param page - pdf page info
411
- * @param docPtr - pointer to pdf document
412
- * @param pagePtr - pointer to pdf page
413
- * @param textPagePtr - pointer to pdf text page
414
- * @returns text rects in the pdf page
415
- *
416
- * @public
417
- */
418
- private readPageTextRects;
419
- /**
420
- * Return geometric + logical text layout for one page
421
- * (glyph-only implementation, no FPDFText_GetRect).
422
- *
423
- * @public
424
- */
425
- getPageGeometry(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfPageGeometry>;
426
- /**
427
- * Group consecutive glyphs that belong to the same CPDF_TextObject
428
- * using FPDFText_GetTextObject(), and calculate rotation from glyph positions.
429
- */
430
- private buildRunsFromGlyphs;
431
- /**
432
- * Extract glyph geometry + metadata for `charIndex`
433
- *
434
- * Returns device–space coordinates:
435
- * x,y → **top-left** corner (integer-pixels)
436
- * w,h → width / height (integer-pixels, ≥ 1)
437
- *
438
- * And two flags:
439
- * isSpace → true if the glyph's Unicode code-point is U+0020
440
- */
441
- private readGlyphInfo;
442
- /**
443
- * Geometry-only text extraction
444
- * ------------------------------------------
445
- * Returns every glyph on the requested page
446
- * in the logical order delivered by PDFium.
447
- *
448
- * The promise resolves to an array of objects:
449
- * {
450
- * idx: number; // glyph index on the page (0…n-1)
451
- * origin: { x: number; y: number };
452
- * size: { width: number; height: number };
453
- * angle: number; // degrees, counter-clock-wise
454
- * isSpace: boolean; // true → U+0020
455
- * }
456
- *
457
- * No Unicode is included; front-end decides whether to hydrate it.
458
- */
459
- getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfGlyphObject[]>;
460
- private readCharBox;
461
- /**
462
- * Read page annotations
463
- * @param page - page info
464
- * @param docPtr - pointer to pdf document
465
- * @param pagePtr - pointer to pdf page
466
- * @param textPagePtr - pointe to pdf text page
467
- * @param scaleFactor - scale factor
468
- * @param rotation - rotation angle
469
- * @returns annotations on the pdf page
470
- *
471
- * @private
472
- */
473
- private readPageAnnotations;
474
- /**
475
- * Read pdf annotation from pdf document
476
- * @param page - pdf page infor
477
- * @param docPtr - pointer to pdf document object
478
- * @param pagePtr - pointer to pdf page object
479
- * @param textPagePtr - pointer to pdf text page object
480
- * @param formHandle - form handle
481
- * @param index - index of annotation in the pdf page
482
- * @param scaleFactor - factor of scalling
483
- * @param rotation - rotation angle
484
- * @returns pdf annotation
485
- *
486
- * @private
487
- */
488
- private readPageAnnotation;
489
- /**
490
- * Return the colour stored directly in the annotation dictionary's `/C` entry.
491
- *
492
- * Most PDFs created by Acrobat, Microsoft Office, LaTeX, etc. include this entry.
493
- * When the key is absent (common in macOS Preview, Chrome, Drawboard) the call
494
- * fails and the function returns `undefined`.
495
- *
496
- * @param annotationPtr - pointer to an `FPDF_ANNOTATION`
497
- * @returns An RGBA tuple (0-255 channels) or `undefined` if no `/C` entry exists
498
- *
499
- * @private
500
- */
501
- private readAnnotationColor;
502
- /**
503
- * Resolve the visible fill colour for **Highlight / Underline / StrikeOut /
504
- * Squiggly** markup annotations.
505
- *
506
- * Resolution order (first non-`undefined` wins):
507
- * 1. `/C` dictionary entry – fast, present in Acrobat / Office PDFs
508
- * 2. Appearance-stream objects – drills into paths & nested forms
509
- * 3. Hard-coded fallback (Acrobat-style opaque yellow)
510
- *
511
- * @param annotationPtr - pointer to an `FPDF_ANNOTATION`
512
- * @param fallback - colour to use when the PDF stores no tint at all
513
- * @returns WebAlphaColor with hex color and opacity (0-1)
514
- *
515
- * @private
516
- */
517
- private resolveAnnotationColor;
518
- /**
519
- * Set the fill/stroke colour for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
520
- *
521
- * @param annotationPtr - pointer to the annotation whose colour is being set
522
- * @param webAlphaColor - WebAlphaColor with hex color and opacity (0-1)
523
- * @param shouldClearAP - whether to clear the /AP entry
524
- * @param which - which colour to set (0 = fill, 1 = stroke)
525
- * @returns `true` if the operation was successful
526
- *
527
- * @private
528
- */
529
- private setAnnotationColor;
530
- /**
531
- * Border‐style + width helper
532
- *
533
- * Tries the new PDFium helper `EPDFAnnot_GetBorderStyle()` (patch series
534
- * 9 July 2025).
535
- *
536
- * @param annotationPtr pointer to an `FPDF_ANNOTATION`
537
- * @returns `{ ok, style, width }`
538
- * • `ok` – `true` when the call succeeded
539
- * • `style` – `PdfAnnotationBorderStyle` enum
540
- * • `width` – stroke-width in points (defaults to 0 pt)
541
- */
542
- private getBorderStyle;
543
- private setBorderStyle;
544
- /**
545
- * Border-effect (“cloudy”) helper
546
- *
547
- * Calls the new PDFium function `EPDFAnnot_GetBorderEffect()` (July 2025).
548
- *
549
- * @param annotationPtr pointer to an `FPDF_ANNOTATION`
550
- * @returns `{ ok, intensity }`
551
- * • `ok` – `true` when the annotation *does* have a
552
- * valid cloudy-border effect
553
- * • `intensity` – radius/intensity value (0 when `ok` is false)
554
- */
555
- private getBorderEffect;
556
- /**
557
- * Rectangle-differences helper ( /RD array on Square / Circle annots )
558
- *
559
- * Calls `EPDFAnnot_GetRectangleDifferences()` introduced in July 2025.
560
- *
561
- * @param annotationPtr pointer to an `FPDF_ANNOTATION`
562
- * @returns `{ ok, left, top, right, bottom }`
563
- * • `ok` – `true` when the annotation *has* an /RD entry
564
- * • the four floats are 0 when `ok` is false
565
- */
566
- private getRectangleDifferences;
567
- /**
568
- * Dash-pattern helper ( /BS → /D array, dashed borders only )
569
- *
570
- * Uses the two new PDFium helpers:
571
- * • `EPDFAnnot_GetBorderDashPatternCount`
572
- * • `EPDFAnnot_GetBorderDashPattern`
573
- *
574
- * @param annotationPtr pointer to an `FPDF_ANNOTATION`
575
- * @returns `{ ok, pattern }`
576
- * • `ok` – `true` when the annot is dashed *and* the array
577
- * was retrieved successfully
578
- * • `pattern` – numeric array of dash/space lengths (empty when `ok` is false)
579
- */
580
- private getBorderDashPattern;
581
- /**
582
- * Read `/QuadPoints` from any annotation and convert each quadrilateral to
583
- * device-space coordinates.
584
- *
585
- * The four points are returned in natural reading order:
586
- * `p1 → p2` (top edge) and `p4 → p3` (bottom edge).
587
- * This preserves the true shape for rotated / skewed text, whereas callers
588
- * that only need axis-aligned boxes can collapse each quad themselves.
589
- *
590
- * @param page - logical page info object (`PdfPageObject`)
591
- * @param annotationPtr - pointer to the annotation whose quads are needed
592
- * @returns Array of `Rect` objects (`[]` if the annotation has no quads)
593
- *
594
- * @private
595
- */
596
- private getQuadPointsAnno;
597
- /**
598
- * Set the quadrilaterals for a **Highlight / Underline / StrikeOut / Squiggly** markup annotation.
599
- *
600
- * @param page - logical page info object (`PdfPageObject`)
601
- * @param annotationPtr - pointer to the annotation whose quads are needed
602
- * @param rects - array of `Rect` objects (`[]` if the annotation has no quads)
603
- * @returns `true` if the operation was successful
604
- *
605
- * @private
606
- */
607
- private syncQuadPointsAnno;
608
- /**
609
- * Read ink list from annotation
610
- * @param page - logical page info object (`PdfPageObject`)
611
- * @param annotationPtr - pointer to the annotation whose ink list is needed
612
- * @returns ink list
613
- */
614
- private getInkList;
615
- /**
616
- * Add ink list to annotation
617
- * @param page - logical page info object (`PdfPageObject`)
618
- * @param annotationPtr - pointer to the annotation whose ink list is needed
619
- * @param annotation - annotation object (`PdfInkAnnoObject`)
620
- * @returns `true` if the operation was successful
621
- */
622
- private setInkList;
623
- /**
624
- * Read pdf text annotation
625
- * @param page - pdf page infor
626
- * @param pagePtr - pointer to pdf page object
627
- * @param annotationPtr - pointer to pdf annotation
628
- * @param index - index of annotation in the pdf page
629
- * @returns pdf text annotation
630
- *
631
- * @private
632
- */
633
- private readPdfTextAnno;
634
- /**
635
- * Read pdf freetext annotation
636
- * @param page - pdf page infor
637
- * @param pagePtr - pointer to pdf page object
638
- * @param annotationPtr - pointer to pdf annotation
639
- * @param index - index of annotation in the pdf page
640
- * @returns pdf freetext annotation
641
- *
642
- * @private
643
- */
644
- private readPdfFreeTextAnno;
645
- /**
646
- * Read pdf link annotation from pdf document
647
- * @param page - pdf page infor
648
- * @param docPtr - pointer to pdf document object
649
- * @param pagePtr - pointer to pdf page object
650
- * @param textPagePtr - pointer to pdf text page object
651
- * @param annotationPtr - pointer to pdf annotation
652
- * @param index - index of annotation in the pdf page
653
- * @returns pdf link annotation
654
- *
655
- * @private
656
- */
657
- private readPdfLinkAnno;
658
- /**
659
- * Read pdf widget annotation
660
- * @param page - pdf page infor
661
- * @param pagePtr - pointer to pdf page object
662
- * @param annotationPtr - pointer to pdf annotation
663
- * @param formHandle - form handle
664
- * @param index - index of annotation in the pdf page
665
- * @returns pdf widget annotation
666
- *
667
- * @private
668
- */
669
- private readPdfWidgetAnno;
670
- /**
671
- * Read pdf file attachment annotation
672
- * @param page - pdf page infor
673
- * @param pagePtr - pointer to pdf page object
674
- * @param annotationPtr - pointer to pdf annotation
675
- * @param index - index of annotation in the pdf page
676
- * @returns pdf file attachment annotation
677
- *
678
- * @private
679
- */
680
- private readPdfFileAttachmentAnno;
681
- /**
682
- * Read pdf ink annotation
683
- * @param page - pdf page infor
684
- * @param pagePtr - pointer to pdf page object
685
- * @param annotationPtr - pointer to pdf annotation
686
- * @param index - index of annotation in the pdf page
687
- * @returns pdf ink annotation
688
- *
689
- * @private
690
- */
691
- private readPdfInkAnno;
692
- /**
693
- * Read pdf polygon annotation
694
- * @param page - pdf page infor
695
- * @param pagePtr - pointer to pdf page object
696
- * @param annotationPtr - pointer to pdf annotation
697
- * @param index - index of annotation in the pdf page
698
- * @returns pdf polygon annotation
699
- *
700
- * @private
701
- */
702
- private readPdfPolygonAnno;
703
- /**
704
- * Read pdf polyline annotation
705
- * @param page - pdf page infor
706
- * @param pagePtr - pointer to pdf page object
707
- * @param annotationPtr - pointer to pdf annotation
708
- * @param index - index of annotation in the pdf page
709
- * @returns pdf polyline annotation
710
- *
711
- * @private
712
- */
713
- private readPdfPolylineAnno;
714
- /**
715
- * Read pdf line annotation
716
- * @param page - pdf page infor
717
- * @param pagePtr - pointer to pdf page object
718
- * @param annotationPtr - pointer to pdf annotation
719
- * @param index - index of annotation in the pdf page
720
- * @returns pdf line annotation
721
- *
722
- * @private
723
- */
724
- private readPdfLineAnno;
725
- /**
726
- * Read pdf highlight annotation
727
- * @param page - pdf page infor
728
- * @param pagePtr - pointer to pdf page object
729
- * @param annotationPtr - pointer to pdf annotation
730
- * @param index - index of annotation in the pdf page
731
- * @returns pdf highlight annotation
732
- *
733
- * @private
734
- */
735
- private readPdfHighlightAnno;
736
- /**
737
- * Read pdf underline annotation
738
- * @param page - pdf page infor
739
- * @param pagePtr - pointer to pdf page object
740
- * @param annotationPtr - pointer to pdf annotation
741
- * @param index - index of annotation in the pdf page
742
- * @returns pdf underline annotation
743
- *
744
- * @private
745
- */
746
- private readPdfUnderlineAnno;
747
- /**
748
- * Read strikeout annotation
749
- * @param page - pdf page infor
750
- * @param pagePtr - pointer to pdf page object
751
- * @param annotationPtr - pointer to pdf annotation
752
- * @param index - index of annotation in the pdf page
753
- * @returns pdf strikeout annotation
754
- *
755
- * @private
756
- */
757
- private readPdfStrikeOutAnno;
758
- /**
759
- * Read pdf squiggly annotation
760
- * @param page - pdf page infor
761
- * @param pagePtr - pointer to pdf page object
762
- * @param annotationPtr - pointer to pdf annotation
763
- * @param index - index of annotation in the pdf page
764
- * @returns pdf squiggly annotation
765
- *
766
- * @private
767
- */
768
- private readPdfSquigglyAnno;
769
- /**
770
- * Read pdf caret annotation
771
- * @param page - pdf page infor
772
- * @param pagePtr - pointer to pdf page object
773
- * @param annotationPtr - pointer to pdf annotation
774
- * @param index - index of annotation in the pdf page
775
- * @returns pdf caret annotation
776
- *
777
- * @private
778
- */
779
- private readPdfCaretAnno;
780
- /**
781
- * Read pdf stamp annotation
782
- * @param docPtr - pointer to pdf document object
783
- * @param page - pdf page infor
784
- * @param pagePtr - pointer to pdf page object
785
- * @param annotationPtr - pointer to pdf annotation
786
- * @param index - index of annotation in the pdf page
787
- * @returns pdf stamp annotation
788
- *
789
- * @private
790
- */
791
- private readPdfStampAnno;
792
- /**
793
- * Read pdf object in pdf page
794
- * @param pageObjectPtr - pointer to pdf object in page
795
- * @returns pdf object in page
796
- *
797
- * @private
798
- */
799
- private readPdfPageObject;
800
- /**
801
- * Read pdf path object
802
- * @param pathObjectPtr - pointer to pdf path object in page
803
- * @returns pdf path object
804
- *
805
- * @private
806
- */
807
- private readPathObject;
808
- /**
809
- * Read segment of pdf path object
810
- * @param annotationObjectPtr - pointer to pdf path object
811
- * @param segmentIndex - index of segment
812
- * @returns pdf segment in pdf path
813
- *
814
- * @private
815
- */
816
- private readPdfSegment;
817
- /**
818
- * Read pdf image object from pdf document
819
- * @param pageObjectPtr - pointer to pdf image object in page
820
- * @returns pdf image object
821
- *
822
- * @private
823
- */
824
- private readImageObject;
825
- /**
826
- * Read form object from pdf document
827
- * @param formObjectPtr - pointer to pdf form object in page
828
- * @returns pdf form object
829
- *
830
- * @private
831
- */
832
- private readFormObject;
833
- /**
834
- * Read pdf object in pdf page
835
- * @param pageObjectPtr - pointer to pdf object in page
836
- * @returns pdf object in page
837
- *
838
- * @private
839
- */
840
- private readPdfPageObjectTransformMatrix;
841
- /**
842
- * Return the stroke-width declared in the annotation’s /Border or /BS entry.
843
- * Falls back to 1 pt when nothing is defined.
844
- *
845
- * @param annotationPtr - pointer to pdf annotation
846
- * @returns stroke-width
847
- *
848
- * @private
849
- */
850
- private getStrokeWidth;
851
- /**
852
- * Fetches the `/F` flag bit-field from an annotation.
853
- *
854
- * @param annotationPtr pointer to an `FPDF_ANNOTATION`
855
- * @returns `{ raw, flags }`
856
- * • `raw` – the 32-bit integer returned by PDFium
857
- * • `flags` – object with individual booleans
858
- */
859
- private getAnnotationFlags;
860
- /**
861
- * Read circle annotation
862
- * @param page - pdf page infor
863
- * @param pagePtr - pointer to pdf page object
864
- * @param annotationPtr - pointer to pdf annotation
865
- * @param index - index of annotation in the pdf page
866
- * @returns pdf circle annotation
867
- *
868
- * @private
869
- */
870
- private readPdfCircleAnno;
871
- /**
872
- * Read square annotation
873
- * @param page - pdf page infor
874
- * @param pagePtr - pointer to pdf page object
875
- * @param annotationPtr - pointer to pdf annotation
876
- * @param index - index of annotation in the pdf page
877
- * @returns pdf square annotation
878
- *
879
- * @private
880
- */
881
- private readPdfSquareAnno;
882
- /**
883
- * Read basic info of unsupported pdf annotation
884
- * @param page - pdf page infor
885
- * @param pagePtr - pointer to pdf page object
886
- * @param type - type of annotation
887
- * @param annotationPtr - pointer to pdf annotation
888
- * @param index - index of annotation in the pdf page
889
- * @returns pdf annotation
890
- *
891
- * @private
892
- */
893
- private readPdfAnno;
894
- /**
895
- * Resolve `/IRT` → parent-annotation index on the same page.
896
- *
897
- * @param pagePtr - pointer to FPDF_PAGE
898
- * @param annotationPtr - pointer to FPDF_ANNOTATION
899
- * @returns index (`0…count-1`) or `undefined` when the annotation is *not* a reply
900
- *
901
- * @private
902
- */
903
- private getInReplyToId;
904
- /**
905
- * Fetch a string value (`/T`, `/M`, `/State`, …) from an annotation.
906
- *
907
- * @returns decoded UTF-8 string or `undefined` when the key is absent
908
- *
909
- * @private
910
- */
911
- private getAnnotString;
912
- /**
913
- * Set a string value (`/T`, `/M`, `/State`, …) to an annotation.
914
- *
915
- * @returns `true` if the operation was successful
916
- *
917
- * @private
918
- */
919
- private setAnnotString;
920
- /**
921
- * Read vertices of pdf annotation
922
- * @param page - pdf page infor
923
- * @param pagePtr - pointer to pdf page object
924
- * @param annotationPtr - pointer to pdf annotation
925
- * @returns vertices of pdf annotation
926
- *
927
- * @private
928
- */
929
- private readPdfAnnoVertices;
930
- /**
931
- * Read the target of pdf bookmark
932
- * @param docPtr - pointer to pdf document object
933
- * @param getActionPtr - callback function to retrive the pointer of action
934
- * @param getDestinationPtr - callback function to retrive the pointer of destination
935
- * @returns target of pdf bookmark
936
- *
937
- * @private
938
- */
939
- private readPdfBookmarkTarget;
940
- /**
941
- * Read field of pdf widget annotation
942
- * @param formHandle - form handle
943
- * @param annotationPtr - pointer to pdf annotation
944
- * @returns field of pdf widget annotation
945
- *
946
- * @private
947
- */
948
- private readPdfWidgetAnnoField;
949
- /**
950
- * {@inheritDoc @embedpdf/models!PdfEngine.renderAnnotation}
951
- *
952
- * @public
953
- */
954
- renderAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, scaleFactor: number, rotation: Rotation, dpr?: number, // device-pixel-ratio (canvas)
955
- mode?: AppearanceMode, imageType?: ImageConversionTypes): PdfTask<T>;
956
- /**
957
- * render rectangle of pdf page to image
958
- * @param docPtr - pointer to pdf document object
959
- * @param page - pdf page infor
960
- * @param rect - rectangle info
961
- * @param scaleFactor - factor of scalling
962
- * @param rotation - rotation angle
963
- * @param options - render options
964
- * @returns image data
965
- *
966
- * @private
967
- */
968
- private renderPageRectToImageData;
969
- /**
970
- * Read the target of pdf link annotation
971
- * @param docPtr - pointer to pdf document object
972
- * @param getActionPtr - callback function to retrive the pointer of action
973
- * @param getDestinationPtr - callback function to retrive the pointer of destination
974
- * @returns target of link
975
- *
976
- * @private
977
- */
978
- private readPdfLinkAnnoTarget;
979
- /**
980
- * Read pdf action from pdf document
981
- * @param docPtr - pointer to pdf document object
982
- * @param actionPtr - pointer to pdf action object
983
- * @returns pdf action object
984
- *
985
- * @private
986
- */
987
- private readPdfAction;
988
- /**
989
- * Read pdf destination object
990
- * @param docPtr - pointer to pdf document object
991
- * @param destinationPtr - pointer to pdf destination
992
- * @returns pdf destination object
993
- *
994
- * @private
995
- */
996
- private readPdfDestination;
997
- /**
998
- * Read attachmet from pdf document
999
- * @param docPtr - pointer to pdf document object
1000
- * @param index - index of attachment
1001
- * @returns attachment content
1002
- *
1003
- * @private
1004
- */
1005
- private readPdfAttachment;
1006
- /**
1007
- * Convert coordinate of point from device coordinate to page coordinate
1008
- * @param page - pdf page infor
1009
- * @param position - position of point
1010
- * @returns converted position
1011
- *
1012
- * @private
1013
- */
1014
- private convertDevicePointToPagePoint;
1015
- /**
1016
- * Convert coordinate of point from page coordinate to device coordinate
1017
- * @param page - pdf page infor
1018
- * @param position - position of point
1019
- * @returns converted position
1020
- *
1021
- * @private
1022
- */
1023
- private convertPagePointToDevicePoint;
1024
- /**
1025
- * Convert coordinate of rectangle from page coordinate to device coordinate
1026
- * @param page - pdf page infor
1027
- * @param pagePtr - pointer to pdf page object
1028
- * @param pageRect - rectangle that needs to be converted
1029
- * @returns converted rectangle
1030
- *
1031
- * @private
1032
- */
1033
- private convertPageRectToDeviceRect;
1034
- /**
1035
- * Read the appearance stream of annotation
1036
- * @param annotationPtr - pointer to pdf annotation
1037
- * @param mode - appearance mode
1038
- * @returns appearance stream
1039
- *
1040
- * @private
1041
- */
1042
- private readPageAnnoAppearanceStreams;
1043
- /**
1044
- * Read the appearance stream of annotation
1045
- * @param annotationPtr - pointer to pdf annotation
1046
- * @param mode - appearance mode
1047
- * @returns appearance stream
1048
- *
1049
- * @private
1050
- */
1051
- private readPageAnnoAppearanceStream;
1052
- /**
1053
- * Change the visible colour (and opacity) of an existing annotation.
1054
- *
1055
- * For markup annotations (highlight / underline / strikeout / squiggly) we
1056
- * first clear the AP dictionary entry, otherwise the stored appearance stream
1057
- * will override the new tint. For all other sub-types we keep the existing
1058
- * AP so custom artwork isn't lost.
1059
- *
1060
- * @param doc logical document object
1061
- * @param page logical page object
1062
- * @param annotation the annotation we want to recolour
1063
- * @param colour RGBA tuple (0-255 per channel)
1064
- * @param which 0 = stroke/fill colour (PDFium's "colourType" param)
1065
- *
1066
- * @returns `true` when the operation succeeded
1067
- */
1068
- updateAnnotationColor(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number): PdfTask<boolean>;
1069
- /**
1070
- * Set the rect of specified annotation
1071
- * @param page - page info that the annotation is belonged to
1072
- * @param pagePtr - pointer of page object
1073
- * @param annotationPtr - pointer to annotation object
1074
- * @param rect - target rectangle
1075
- * @returns whether the rect is setted
1076
- *
1077
- * @private
1078
- */
1079
- setPageAnnoRect(page: PdfPageObject, pagePtr: number, annotationPtr: number, rect: Rect): boolean;
1080
- /**
1081
- * Read the rectangle of annotation
1082
- * @param annotationPtr - pointer to pdf annotation
1083
- * @returns rectangle of annotation
1084
- *
1085
- * @private
1086
- */
1087
- private readPageAnnoRect;
1088
- /**
1089
- * Get highlight rects for a specific character range (for search highlighting)
1090
- * @param page - pdf page info
1091
- * @param pagePtr - pointer to pdf page
1092
- * @param textPagePtr - pointer to pdf text page
1093
- * @param startIndex - starting character index
1094
- * @param charCount - number of characters in the range
1095
- * @returns array of rectangles for highlighting the specified character range
1096
- *
1097
- * @private
1098
- */
1099
- private getHighlightRects;
1100
- /**
1101
- * Search for a keyword across all pages in the document
1102
- * Returns all search results throughout the entire document
1103
- *
1104
- * @param doc - Pdf document object
1105
- * @param keyword - Search keyword
1106
- * @param flags - Match flags for search
1107
- * @returns Promise of all search results in the document
1108
- *
1109
- * @public
1110
- */
1111
- searchAllPages(doc: PdfDocumentObject, keyword: string, flags?: MatchFlag[]): Task<SearchAllPagesResult, PdfErrorReason>;
1112
- /**
1113
- * Extract word-aligned context for a search hit.
1114
- *
1115
- * @param fullText full UTF-16 page text (fetch this once per page!)
1116
- * @param start index of 1st char that matched
1117
- * @param count number of chars in the match
1118
- * @param windowChars minimum context chars to keep left & right
1119
- */
1120
- private buildContext;
1121
- /**
1122
- * Tidy the text to remove any non-printable characters and whitespace
1123
- * @param s - text to tidy
1124
- * @returns tidied text
1125
- *
1126
- * @private
1127
- */
1128
- private tidy;
1129
- /**
1130
- * Search for all occurrences of a keyword on a single page
1131
- * This method efficiently loads the page only once and finds all matches
1132
- *
1133
- * @param docPtr - pointer to pdf document
1134
- * @param page - pdf page object
1135
- * @param pageIndex - index of the page
1136
- * @param keywordPtr - pointer to the search keyword
1137
- * @param flag - search flags
1138
- * @returns array of search results on this page
1139
- *
1140
- * @private
1141
- */
1142
- private searchAllInPage;
1143
- }
1144
-
1145
- /**
1146
- * Read string from WASM heap
1147
- * @param wasmModule - pdfium wasm module instance
1148
- * @param readChars - function to read chars
1149
- * @param parseChars - function to parse chars
1150
- * @param defaultLength - default length of chars that needs to read
1151
- * @returns string from the heap
1152
- *
1153
- * @public
1154
- */
1155
- declare function readString(wasmModule: PdfiumRuntimeMethods & PdfiumModule, readChars: (buffer: number, bufferLength: number) => number, parseChars: (buffer: number) => string, defaultLength?: number): string;
1156
- /**
1157
- * Read arraybyffer from WASM heap
1158
- * @param wasmModule - pdfium wasm module instance
1159
- * @param readChars - function to read chars
1160
- * @returns arraybuffer from the heap
1161
- *
1162
- * @public
1163
- */
1164
- declare function readArrayBuffer(wasmModule: PdfiumRuntimeMethods & PdfiumModule, readChars: (buffer: number, bufferLength: number) => number): ArrayBuffer;
1165
-
1166
- /**
1167
- * Request body that represent method calls of PdfEngine, it contains the
1168
- * method name and arguments
1169
- */
1170
- type PdfEngineMethodRequestBody = {
1171
- [P in PdfEngineMethodName]: {
1172
- name: P;
1173
- args: PdfEngineMethodArgs<P>;
1174
- };
1175
- }[PdfEngineMethodName];
1176
- /**
1177
- * Response body that represent return value of PdfEngine
1178
- */
1179
- type PdfEngineMethodResponseBody = {
1180
- [P in PdfEngineMethodName]: TaskReturn<PdfEngineMethodReturnType<P>>;
1181
- }[PdfEngineMethodName];
1182
- /**
1183
- * Request that abort the specified task
1184
- */
1185
- interface AbortRequest {
1186
- /**
1187
- * message id
1188
- */
1189
- id: string;
1190
- /**
1191
- * request type
1192
- */
1193
- type: 'AbortRequest';
1194
- }
1195
- /**
1196
- * Request that execute pdf engine method
1197
- */
1198
- interface ExecuteRequest {
1199
- /**
1200
- * message id
1201
- */
1202
- id: string;
1203
- /**
1204
- * request type
1205
- */
1206
- type: 'ExecuteRequest';
1207
- /**
1208
- * request body
1209
- */
1210
- data: PdfEngineMethodRequestBody;
1211
- }
1212
- /**
1213
- * Response that execute pdf engine method
1214
- */
1215
- interface ExecuteResponse {
1216
- /**
1217
- * message id
1218
- */
1219
- id: string;
1220
- /**
1221
- * response type
1222
- */
1223
- type: 'ExecuteResponse';
1224
- /**
1225
- * response body
1226
- */
1227
- data: PdfEngineMethodResponseBody;
1228
- }
1229
- /**
1230
- * Response that indicate engine is ready
1231
- */
1232
- interface ReadyResponse {
1233
- /**
1234
- * message id
1235
- */
1236
- id: string;
1237
- /**
1238
- * response type
1239
- */
1240
- type: 'ReadyResponse';
1241
- }
1242
- /**
1243
- * Request type
1244
- */
1245
- type Request = ExecuteRequest | AbortRequest;
1246
- /**
1247
- * Response type
1248
- */
1249
- type Response = ExecuteResponse | ReadyResponse;
1250
- /**
1251
- * Pdf engine runner, it will execute pdf engine based on the request it received and
1252
- * send back the response with post message
1253
- */
1254
- declare class EngineRunner {
1255
- logger: Logger;
1256
- engine: PdfEngine | undefined;
1257
- /**
1258
- * Create instance of EngineRunnder
1259
- * @param logger - logger instance
1260
- */
1261
- constructor(logger?: Logger);
1262
- /**
1263
- * Listening on post message
1264
- */
1265
- listen(): void;
1266
- /**
1267
- * Handle post message
1268
- */
1269
- handle(evt: MessageEvent<Request>): void;
1270
- /**
1271
- * Send the ready response when pdf engine is ready
1272
- * @returns
1273
- *
1274
- * @protected
1275
- */
1276
- ready(): void;
1277
- /**
1278
- * Execute the request
1279
- * @param request - request that represent the pdf engine call
1280
- * @returns
1281
- *
1282
- * @protected
1283
- */
1284
- execute: (request: ExecuteRequest) => void;
1285
- /**
1286
- * Send back the response
1287
- * @param response - response that needs sent back
1288
- *
1289
- * @protected
1290
- */
1291
- respond(response: Response): void;
1292
- }
1293
-
1294
- /**
1295
- * EngineRunner for pdfium-based wasm engine
1296
- */
1297
- declare class PdfiumEngineRunner extends EngineRunner {
1298
- private wasmBinary;
1299
- /**
1300
- * Create an instance of PdfiumEngineRunner
1301
- * @param wasmBinary - wasm binary that contains the pdfium wasm file
1302
- */
1303
- constructor(wasmBinary: ArrayBuffer);
1304
- /**
1305
- * Initialize runner
1306
- */
1307
- prepare(): Promise<void>;
1308
- }
1309
-
1310
- /**
1311
- * Task that executed by webworker
1312
- */
1313
- declare class WorkerTask<R> extends Task<R, PdfErrorReason> {
1314
- worker: Worker;
1315
- private messageId;
1316
- /**
1317
- * Create a task that bind to web worker with specified message id
1318
- * @param worker - web worker instance
1319
- * @param messageId - id of message
1320
- *
1321
- * @public
1322
- */
1323
- constructor(worker: Worker, messageId: string);
1324
- /**
1325
- * {@inheritDoc @embedpdf/models!Task.abort}
1326
- *
1327
- * @override
1328
- */
1329
- abort(e: PdfErrorReason): void;
1330
- }
1331
- /**
1332
- * PDF engine that runs within webworker
1333
- */
1334
- declare class WebWorkerEngine implements PdfEngine {
1335
- private worker;
1336
- private logger;
1337
- static readyTaskId: string;
1338
- /**
1339
- * Task that represent the state of preparation
1340
- */
1341
- readyTask: WorkerTask<boolean>;
1342
- /**
1343
- * All the tasks that is executing
1344
- */
1345
- tasks: Map<string, WorkerTask<any>>;
1346
- /**
1347
- * Create an instance of WebWorkerEngine, it will create a worker with
1348
- * specified url.
1349
- * @param worker - webworker instance, this worker needs to contains the running instance of {@link EngineRunner}
1350
- * @param logger - logger instance
1351
- *
1352
- * @public
1353
- */
1354
- constructor(worker: Worker, logger?: Logger);
1355
- /**
1356
- * Handle event from web worker. There are 2 kinds of event
1357
- * 1. ReadyResponse: web worker is ready
1358
- * 2. ExecuteResponse: result of execution
1359
- * @param evt - message event from web worker
1360
- * @returns
1361
- *
1362
- * @private
1363
- */
1364
- handle: (evt: MessageEvent<any>) => void;
1365
- /**
1366
- * Generate a unique message id
1367
- * @returns message id
1368
- *
1369
- * @private
1370
- */
1371
- generateRequestId(id: string): string;
1372
- /**
1373
- * {@inheritDoc @embedpdf/models!PdfEngine.initialize}
1374
- *
1375
- * @public
1376
- */
1377
- initialize(): WorkerTask<boolean>;
1378
- /**
1379
- * {@inheritDoc @embedpdf/models!PdfEngine.destroy}
1380
- *
1381
- * @public
1382
- */
1383
- destroy(): WorkerTask<boolean>;
1384
- /**
1385
- * {@inheritDoc @embedpdf/models!PdfEngine.openDocumentUrl}
1386
- *
1387
- * @public
1388
- */
1389
- openDocumentUrl(file: PdfFileUrl, options?: PdfUrlOptions): WorkerTask<PdfDocumentObject>;
1390
- /**
1391
- * {@inheritDoc @embedpdf/models!PdfEngine.openDocument}
1392
- *
1393
- * @public
1394
- */
1395
- openDocumentFromBuffer(file: PdfFile, password: string): WorkerTask<PdfDocumentObject>;
1396
- /**
1397
- * {@inheritDoc @embedpdf/models!PdfEngine.openDocumentFromLoader}
1398
- *
1399
- * @public
1400
- */
1401
- openDocumentFromLoader(file: PdfFileLoader, password: string): WorkerTask<PdfDocumentObject>;
1402
- /**
1403
- * {@inheritDoc @embedpdf/models!PdfEngine.getMetadata}
1404
- *
1405
- * @public
1406
- */
1407
- getMetadata(doc: PdfDocumentObject): WorkerTask<PdfMetadataObject>;
1408
- updateAnnotationColor(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObjectBase, color: WebAlphaColor, which?: number): WorkerTask<boolean>;
1409
- /**
1410
- * {@inheritDoc @embedpdf/models!PdfEngine.getDocPermissions}
1411
- *
1412
- * @public
1413
- */
1414
- getDocPermissions(doc: PdfDocumentObject): WorkerTask<number>;
1415
- /**
1416
- * {@inheritDoc @embedpdf/models!PdfEngine.getDocUserPermissions}
1417
- *
1418
- * @public
1419
- */
1420
- getDocUserPermissions(doc: PdfDocumentObject): WorkerTask<number>;
1421
- /**
1422
- * {@inheritDoc @embedpdf/models!PdfEngine.getBookmarks}
1423
- *
1424
- * @public
1425
- */
1426
- getBookmarks(doc: PdfDocumentObject): WorkerTask<PdfBookmarksObject>;
1427
- /**
1428
- * {@inheritDoc @embedpdf/models!PdfEngine.getSignatures}
1429
- *
1430
- * @public
1431
- */
1432
- getSignatures(doc: PdfDocumentObject): WorkerTask<PdfSignatureObject[]>;
1433
- /**
1434
- * {@inheritDoc @embedpdf/models!PdfEngine.renderPage}
1435
- *
1436
- * @public
1437
- */
1438
- renderPage(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, options: PdfRenderOptions, imageType?: ImageConversionTypes): WorkerTask<Blob>;
1439
- /**
1440
- * {@inheritDoc @embedpdf/models!PdfEngine.renderPageRect}
1441
- *
1442
- * @public
1443
- */
1444
- renderPageRect(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, rect: Rect, options: PdfRenderOptions, imageType?: ImageConversionTypes): WorkerTask<Blob>;
1445
- /**
1446
- * {@inheritDoc @embedpdf/models!PdfEngine.renderAnnotation}
1447
- *
1448
- * @public
1449
- */
1450
- renderAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, scaleFactor: number, rotation: Rotation, dpr: number, mode: AppearanceMode, imageType: ImageConversionTypes): WorkerTask<Blob>;
1451
- /**
1452
- * {@inheritDoc @embedpdf/models!PdfEngine.getAllAnnotations}
1453
- *
1454
- * @public
1455
- */
1456
- getAllAnnotations(doc: PdfDocumentObject): WorkerTask<Record<number, PdfAnnotationObject[]>>;
1457
- /**
1458
- * {@inheritDoc @embedpdf/models!PdfEngine.getPageAnnotations}
1459
- *
1460
- * @public
1461
- */
1462
- getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): WorkerTask<PdfAnnotationObject[]>;
1463
- /**
1464
- * {@inheritDoc @embedpdf/models!PdfEngine.createPageAnnotation}
1465
- *
1466
- * @public
1467
- */
1468
- createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): WorkerTask<number>;
1469
- updatePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): WorkerTask<boolean>;
1470
- /**
1471
- * {@inheritDoc @embedpdf/models!PdfEngine.removePageAnnotation}
1472
- *
1473
- * @public
1474
- */
1475
- removePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): WorkerTask<boolean>;
1476
- /**
1477
- * {@inheritDoc @embedpdf/models!PdfEngine.getPageTextRects}
1478
- *
1479
- * @public
1480
- */
1481
- getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation): WorkerTask<PdfTextRectObject[]>;
1482
- /**
1483
- * {@inheritDoc @embedpdf/models!PdfEngine.renderThumbnail}
1484
- *
1485
- * @public
1486
- */
1487
- renderThumbnail(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number): WorkerTask<Blob>;
1488
- /**
1489
- * {@inheritDoc @embedpdf/models!PdfEngine.searchAllPages}
1490
- *
1491
- * @public
1492
- */
1493
- searchAllPages(doc: PdfDocumentObject, keyword: string, flags?: MatchFlag[]): WorkerTask<SearchAllPagesResult>;
1494
- /**
1495
- * {@inheritDoc @embedpdf/models!PdfEngine.saveAsCopy}
1496
- *
1497
- * @public
1498
- */
1499
- saveAsCopy(doc: PdfDocumentObject): WorkerTask<ArrayBuffer>;
1500
- /**
1501
- * {@inheritDoc @embedpdf/models!PdfEngine.getAttachments}
1502
- *
1503
- * @public
1504
- */
1505
- getAttachments(doc: PdfDocumentObject): WorkerTask<PdfAttachmentObject[]>;
1506
- /**
1507
- * {@inheritDoc @embedpdf/models!PdfEngine.readAttachmentContent}
1508
- *
1509
- * @public
1510
- */
1511
- readAttachmentContent(doc: PdfDocumentObject, attachment: PdfAttachmentObject): WorkerTask<ArrayBuffer>;
1512
- /**
1513
- * {@inheritDoc @embedpdf/models!PdfEngine.setFormFieldValue}
1514
- *
1515
- * @public
1516
- */
1517
- setFormFieldValue(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfWidgetAnnoObject, value: FormFieldValue): WorkerTask<boolean>;
1518
- /**
1519
- * {@inheritDoc @embedpdf/models!PdfEngine.flattenPage}
1520
- *
1521
- * @public
1522
- */
1523
- flattenPage(doc: PdfDocumentObject, page: PdfPageObject, flag: PdfPageFlattenFlag): WorkerTask<PdfPageFlattenResult>;
1524
- /**
1525
- * {@inheritDoc @embedpdf/models!PdfEngine.extractPages}
1526
- *
1527
- * @public
1528
- */
1529
- extractPages(doc: PdfDocumentObject, pageIndexes: number[]): WorkerTask<ArrayBuffer>;
1530
- /**
1531
- * {@inheritDoc @embedpdf/models!PdfEngine.extractText}
1532
- *
1533
- * @public
1534
- */
1535
- extractText(doc: PdfDocumentObject, pageIndexes: number[]): WorkerTask<string>;
1536
- /**
1537
- * {@inheritDoc @embedpdf/models!PdfEngine.getTextSlices}
1538
- *
1539
- * @public
1540
- */
1541
- getTextSlices(doc: PdfDocumentObject, slices: PageTextSlice[]): WorkerTask<string[]>;
1542
- /**
1543
- * {@inheritDoc @embedpdf/models!PdfEngine.getPageGlyphs}
1544
- *
1545
- * @public
1546
- */
1547
- getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): WorkerTask<PdfGlyphObject[]>;
1548
- /**
1549
- * {@inheritDoc @embedpdf/models!PdfEngine.getPageGeometry}
1550
- *
1551
- * @public
1552
- */
1553
- getPageGeometry(doc: PdfDocumentObject, page: PdfPageObject): WorkerTask<PdfPageGeometry>;
1554
- /**
1555
- * {@inheritDoc @embedpdf/models!PdfEngine.merge}
1556
- *
1557
- * @public
1558
- */
1559
- merge(files: PdfFile[]): WorkerTask<PdfFile>;
1560
- /**
1561
- * {@inheritDoc @embedpdf/models!PdfEngine.mergePages}
1562
- *
1563
- * @public
1564
- */
1565
- mergePages(mergeConfigs: Array<{
1566
- docId: string;
1567
- pageIndices: number[];
1568
- }>): WorkerTask<PdfFile>;
1569
- /**
1570
- * {@inheritDoc @embedpdf/models!PdfEngine.closeDocument}
1571
- *
1572
- * @public
1573
- */
1574
- closeDocument(doc: PdfDocumentObject): WorkerTask<boolean>;
1575
- /**
1576
- * Send the request to webworker inside and register the task
1577
- * @param task - task that waiting for the response
1578
- * @param request - request that needs send to web worker
1579
- * @param transferables - transferables that need to transfer to webworker
1580
- * @returns
1581
- *
1582
- * @internal
1583
- */
1584
- proxy<R>(task: WorkerTask<R>, request: ExecuteRequest, transferables?: any[]): void;
1585
- }
1586
-
1587
- /**
1588
- * Create mock of pdf engine
1589
- * @param partialEngine - partial configuration of engine
1590
- * @returns - mock of pdf engine
1591
- *
1592
- * @public
1593
- */
1594
- declare function createMockPdfEngine(partialEngine?: Partial<PdfEngine>): PdfEngine;
1595
- /**
1596
- * Create mock of pdf document
1597
- * @param doc - partial configuration of document
1598
- * @returns mock of pdf document
1599
- *
1600
- * @public
1601
- */
1602
- declare function createMockPdfDocument(doc?: Partial<PdfDocumentObject>): PdfDocumentObject;
1603
- /**
1604
- * Create mock of pdf file
1605
- * @param file - partial configuration of file
1606
- * @returns mock of pdf file
1607
- *
1608
- * @public
1609
- */
1610
- declare function createMockPdfFile(file?: Partial<PdfFile>): PdfFile;
1611
-
1612
- export { BitmapFormat, EngineRunner, PdfiumEngine, PdfiumEngineRunner, PdfiumErrorCode, RenderFlag, WebWorkerEngine, WorkerTask, browserImageDataToBlobConverter, createMockPdfDocument, createMockPdfEngine, createMockPdfFile, readArrayBuffer, readString };
1613
- export type { AbortRequest, ExecuteRequest, ExecuteResponse, ImageDataConverter, PdfEngineMethodRequestBody, PdfEngineMethodResponseBody, ReadyResponse, Request, Response, SearchContext };
1
+ export * from './lib';