@embedpdf/engines 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/chunk-NDTYBBMQ.js +4615 -0
- package/dist/chunk-NDTYBBMQ.js.map +1 -0
- package/dist/chunk-YZLT3A2D.js +1101 -0
- package/dist/chunk-YZLT3A2D.js.map +1 -0
- package/dist/converters.cjs +124 -0
- package/dist/converters.cjs.map +1 -0
- package/dist/converters.d.cts +69 -0
- package/dist/converters.d.ts +69 -0
- package/dist/converters.js +94 -0
- package/dist/converters.js.map +1 -0
- package/dist/index.cjs +6054 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +367 -0
- package/dist/index.js.map +1 -0
- package/dist/pdfium.cjs +5715 -0
- package/dist/pdfium.cjs.map +1 -0
- package/dist/pdfium.d.cts +1083 -0
- package/dist/pdfium.d.ts +1083 -0
- package/dist/pdfium.js +22 -0
- package/dist/pdfium.js.map +1 -0
- package/dist/runner-BvRtPCKL.d.cts +131 -0
- package/dist/runner-BvRtPCKL.d.ts +131 -0
- package/dist/worker.cjs +1122 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +274 -0
- package/dist/worker.d.ts +274 -0
- package/dist/worker.js +11 -0
- package/dist/worker.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,1083 @@
|
|
|
1
|
+
import { SearchTarget, PdfImage, PdfEngine, Logger, Task, PdfErrorReason, PdfFileUrl, PdfUrlOptions, PdfDocumentObject, PdfFile, PdfFileLoader, PdfSignatureObject, PdfBookmarkObject, PdfPageObject, Rotation, PdfRenderOptions, PdfTask, Rect, PdfAnnotationObject, PdfAnnotationTransformation, PdfTextRectObject, PdfAttachmentObject, PdfWidgetAnnoObject, FormFieldValue, PdfPageFlattenFlag, PdfPageFlattenResult, PdfInkListObject, PdfStampAnnoObjectContents, Position, PdfPageGeometry, PdfGlyphObject, MatchFlag, SearchAllPagesResult } from '@embedpdf/models';
|
|
2
|
+
import { WrappedPdfiumModule, PdfiumRuntimeMethods, PdfiumModule } from '@embedpdf/pdfium';
|
|
3
|
+
import { e as EngineRunner } from './runner-BvRtPCKL.cjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Format of bitmap
|
|
7
|
+
*/
|
|
8
|
+
declare enum BitmapFormat {
|
|
9
|
+
Bitmap_Gray = 1,
|
|
10
|
+
Bitmap_BGR = 2,
|
|
11
|
+
Bitmap_BGRx = 3,
|
|
12
|
+
Bitmap_BGRA = 4
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pdf rendering flag
|
|
16
|
+
*/
|
|
17
|
+
declare enum RenderFlag {
|
|
18
|
+
ANNOT = 1,// Set if annotations are to be rendered.
|
|
19
|
+
LCD_TEXT = 2,// Set if using text rendering optimized for LCD display.
|
|
20
|
+
NO_NATIVETEXT = 4,// Don't use the native text output available on some platforms
|
|
21
|
+
GRAYSCALE = 8,// Grayscale output.
|
|
22
|
+
DEBUG_INFO = 128,// Set if you want to get some debug info. Please discuss with Foxit first if you need to collect debug info.
|
|
23
|
+
NO_CATCH = 256,// Set if you don't want to catch exception.
|
|
24
|
+
RENDER_LIMITEDIMAGECACHE = 512,// Limit image cache size.
|
|
25
|
+
RENDER_FORCEHALFTONE = 1024,// Always use halftone for image stretching.
|
|
26
|
+
PRINTING = 2048,// Render for printing.
|
|
27
|
+
REVERSE_BYTE_ORDER = 16
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Context used for searching
|
|
31
|
+
*/
|
|
32
|
+
interface SearchContext {
|
|
33
|
+
/**
|
|
34
|
+
* search target
|
|
35
|
+
*/
|
|
36
|
+
target: SearchTarget;
|
|
37
|
+
/**
|
|
38
|
+
* current page index
|
|
39
|
+
*/
|
|
40
|
+
currPageIndex: number;
|
|
41
|
+
/**
|
|
42
|
+
* index of text in the current pdf page, -1 means reach the end
|
|
43
|
+
*/
|
|
44
|
+
startIndex: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Error code of pdfium library
|
|
48
|
+
*/
|
|
49
|
+
declare enum PdfiumErrorCode {
|
|
50
|
+
Success = 0,
|
|
51
|
+
Unknown = 1,
|
|
52
|
+
File = 2,
|
|
53
|
+
Format = 3,
|
|
54
|
+
Password = 4,
|
|
55
|
+
Security = 5,
|
|
56
|
+
Page = 6,
|
|
57
|
+
XFALoad = 7,
|
|
58
|
+
XFALayout = 8
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Function type for converting ImageData to Blob
|
|
62
|
+
* In browser: uses OffscreenCanvas
|
|
63
|
+
* In Node.js: can use Sharp or other image processing libraries
|
|
64
|
+
*/
|
|
65
|
+
type ImageDataConverter<T = Blob> = (imageData: PdfImage) => Promise<T>;
|
|
66
|
+
declare const browserImageDataToBlobConverter: ImageDataConverter<Blob>;
|
|
67
|
+
/**
|
|
68
|
+
* Pdf engine that based on pdfium wasm
|
|
69
|
+
*/
|
|
70
|
+
declare class PdfiumEngine<T = Blob> implements PdfEngine<T> {
|
|
71
|
+
private pdfiumModule;
|
|
72
|
+
private logger;
|
|
73
|
+
private imageDataConverter;
|
|
74
|
+
/**
|
|
75
|
+
* pdf documents that opened
|
|
76
|
+
*/
|
|
77
|
+
private readonly cache;
|
|
78
|
+
/**
|
|
79
|
+
* Create an instance of PdfiumEngine
|
|
80
|
+
* @param wasmModule - pdfium wasm module
|
|
81
|
+
* @param logger - logger instance
|
|
82
|
+
* @param imageDataToBlobConverter - function to convert ImageData to Blob
|
|
83
|
+
*/
|
|
84
|
+
constructor(pdfiumModule: WrappedPdfiumModule, logger?: Logger, imageDataConverter?: ImageDataConverter<T>);
|
|
85
|
+
/**
|
|
86
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.initialize}
|
|
87
|
+
*
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
initialize(): Task<boolean, PdfErrorReason>;
|
|
91
|
+
/**
|
|
92
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.destroy}
|
|
93
|
+
*
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
destroy(): Task<boolean, PdfErrorReason>;
|
|
97
|
+
/**
|
|
98
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.openDocumentUrl}
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
openDocumentUrl(file: PdfFileUrl, options?: PdfUrlOptions): Task<PdfDocumentObject, PdfErrorReason>;
|
|
103
|
+
/**
|
|
104
|
+
* Check if the server supports range requests:
|
|
105
|
+
* Sends a HEAD request and sees if 'Accept-Ranges: bytes'.
|
|
106
|
+
*/
|
|
107
|
+
private checkRangeSupport;
|
|
108
|
+
/**
|
|
109
|
+
* Fully fetch the file (using fetch) into an ArrayBuffer,
|
|
110
|
+
* then call openDocumentFromBuffer.
|
|
111
|
+
*/
|
|
112
|
+
private fetchFullAndOpen;
|
|
113
|
+
/**
|
|
114
|
+
* Use your synchronous partial-loading approach:
|
|
115
|
+
* - In your snippet, it's done via `openDocumentFromLoader`.
|
|
116
|
+
* - We'll do a synchronous XHR read callback that pulls
|
|
117
|
+
* the desired byte ranges.
|
|
118
|
+
*/
|
|
119
|
+
private openDocumentWithRangeRequest;
|
|
120
|
+
/**
|
|
121
|
+
* Helper to do a HEAD request or partial GET to find file length.
|
|
122
|
+
*/
|
|
123
|
+
private retrieveFileLength;
|
|
124
|
+
/**
|
|
125
|
+
* Convert response text (x-user-defined) to a Uint8Array
|
|
126
|
+
* for partial data.
|
|
127
|
+
*/
|
|
128
|
+
private convertResponseToUint8Array;
|
|
129
|
+
/**
|
|
130
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.openDocument}
|
|
131
|
+
*
|
|
132
|
+
* @public
|
|
133
|
+
*/
|
|
134
|
+
openDocumentFromBuffer(file: PdfFile, password?: string): Task<PdfDocumentObject, PdfErrorReason>;
|
|
135
|
+
/**
|
|
136
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.openDocumentFromLoader}
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
openDocumentFromLoader(fileLoader: PdfFileLoader, password?: string): Task<PdfDocumentObject, PdfErrorReason>;
|
|
141
|
+
/**
|
|
142
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getMetadata}
|
|
143
|
+
*
|
|
144
|
+
* @public
|
|
145
|
+
*/
|
|
146
|
+
getMetadata(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<{
|
|
147
|
+
title: string;
|
|
148
|
+
author: string;
|
|
149
|
+
subject: string;
|
|
150
|
+
keywords: string;
|
|
151
|
+
producer: string;
|
|
152
|
+
creator: string;
|
|
153
|
+
creationDate: string;
|
|
154
|
+
modificationDate: string;
|
|
155
|
+
}, PdfErrorReason>;
|
|
156
|
+
/**
|
|
157
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getDocPermissions}
|
|
158
|
+
*
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
getDocPermissions(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<number, PdfErrorReason>;
|
|
162
|
+
/**
|
|
163
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getDocUserPermissions}
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
getDocUserPermissions(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<number, PdfErrorReason>;
|
|
168
|
+
/**
|
|
169
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getSignatures}
|
|
170
|
+
*
|
|
171
|
+
* @public
|
|
172
|
+
*/
|
|
173
|
+
getSignatures(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<PdfSignatureObject[], PdfErrorReason>;
|
|
174
|
+
/**
|
|
175
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getBookmarks}
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
getBookmarks(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<{
|
|
180
|
+
bookmarks: PdfBookmarkObject[];
|
|
181
|
+
}, PdfErrorReason>;
|
|
182
|
+
/**
|
|
183
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.renderPage}
|
|
184
|
+
*
|
|
185
|
+
* @public
|
|
186
|
+
*/
|
|
187
|
+
renderPage(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor?: number, rotation?: Rotation, dpr?: number, options?: PdfRenderOptions): PdfTask<T>;
|
|
188
|
+
/**
|
|
189
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.renderPageRect}
|
|
190
|
+
*
|
|
191
|
+
* @public
|
|
192
|
+
*/
|
|
193
|
+
renderPageRect(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number, rect: Rect, options: PdfRenderOptions): PdfTask<T>;
|
|
194
|
+
/**
|
|
195
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getAllAnnotations}
|
|
196
|
+
*
|
|
197
|
+
* @public
|
|
198
|
+
*/
|
|
199
|
+
getAllAnnotations(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<Record<number, PdfAnnotationObject[]>, PdfErrorReason>;
|
|
200
|
+
private readAllAnnotations;
|
|
201
|
+
/**
|
|
202
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getPageAnnotations}
|
|
203
|
+
*
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
getPageAnnotations(doc: PdfDocumentObject, page: PdfPageObject): Task<any, PdfErrorReason> | Task<PdfAnnotationObject[], PdfErrorReason>;
|
|
207
|
+
/**
|
|
208
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.createPageAnnotation}
|
|
209
|
+
*
|
|
210
|
+
* @public
|
|
211
|
+
*/
|
|
212
|
+
createPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
|
|
213
|
+
/**
|
|
214
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.transformPageAnnotation}
|
|
215
|
+
*
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
transformPageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject, transformation: PdfAnnotationTransformation): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
|
|
219
|
+
/**
|
|
220
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.removePageAnnotation}
|
|
221
|
+
*
|
|
222
|
+
* @public
|
|
223
|
+
*/
|
|
224
|
+
removePageAnnotation(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfAnnotationObject): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
|
|
225
|
+
/**
|
|
226
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getPageTextRects}
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
getPageTextRects(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation): Task<any, PdfErrorReason> | Task<PdfTextRectObject[], PdfErrorReason>;
|
|
231
|
+
/**
|
|
232
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.renderThumbnail}
|
|
233
|
+
*
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
renderThumbnail(doc: PdfDocumentObject, page: PdfPageObject, scaleFactor: number, rotation: Rotation, dpr: number): PdfTask<T>;
|
|
237
|
+
/**
|
|
238
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.getAttachments}
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
getAttachments(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<PdfAttachmentObject[], PdfErrorReason>;
|
|
243
|
+
/**
|
|
244
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.readAttachmentContent}
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
readAttachmentContent(doc: PdfDocumentObject, attachment: PdfAttachmentObject): Task<any, PdfErrorReason> | Task<ArrayBuffer, PdfErrorReason>;
|
|
249
|
+
/**
|
|
250
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.setFormFieldValue}
|
|
251
|
+
*
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
setFormFieldValue(doc: PdfDocumentObject, page: PdfPageObject, annotation: PdfWidgetAnnoObject, value: FormFieldValue): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
|
|
255
|
+
/**
|
|
256
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.flattenPage}
|
|
257
|
+
*
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
flattenPage(doc: PdfDocumentObject, page: PdfPageObject, flag: PdfPageFlattenFlag): PdfTask<PdfPageFlattenResult>;
|
|
261
|
+
/**
|
|
262
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.extractPages}
|
|
263
|
+
*
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
extractPages(doc: PdfDocumentObject, pageIndexes: number[]): Task<any, PdfErrorReason> | Task<ArrayBuffer, PdfErrorReason>;
|
|
267
|
+
/**
|
|
268
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.extractText}
|
|
269
|
+
*
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
extractText(doc: PdfDocumentObject, pageIndexes: number[]): Task<any, PdfErrorReason> | Task<string, PdfErrorReason>;
|
|
273
|
+
/**
|
|
274
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.merge}
|
|
275
|
+
*
|
|
276
|
+
* @public
|
|
277
|
+
*/
|
|
278
|
+
merge(files: PdfFile[]): Task<any, PdfErrorReason> | Task<PdfFile, PdfErrorReason>;
|
|
279
|
+
/**
|
|
280
|
+
* Merges specific pages from multiple PDF documents in a custom order
|
|
281
|
+
*
|
|
282
|
+
* @param mergeConfigs Array of configurations specifying which pages to merge from which documents
|
|
283
|
+
* @returns A PdfTask that resolves with the merged PDF file
|
|
284
|
+
* @public
|
|
285
|
+
*/
|
|
286
|
+
mergePages(mergeConfigs: Array<{
|
|
287
|
+
docId: string;
|
|
288
|
+
pageIndices: number[];
|
|
289
|
+
}>): Task<any, PdfErrorReason> | Task<PdfFile, PdfErrorReason>;
|
|
290
|
+
/**
|
|
291
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.saveAsCopy}
|
|
292
|
+
*
|
|
293
|
+
* @public
|
|
294
|
+
*/
|
|
295
|
+
saveAsCopy(doc: PdfDocumentObject): Task<any, PdfErrorReason> | Task<ArrayBuffer, PdfErrorReason>;
|
|
296
|
+
/**
|
|
297
|
+
* {@inheritDoc @embedpdf/models!PdfEngine.closeDocument}
|
|
298
|
+
*
|
|
299
|
+
* @public
|
|
300
|
+
*/
|
|
301
|
+
closeDocument(doc: PdfDocumentObject): Task<boolean, PdfErrorReason> | Task<any, PdfErrorReason>;
|
|
302
|
+
/**
|
|
303
|
+
* Memory allocation
|
|
304
|
+
* @param size - size of memory space
|
|
305
|
+
* @returns pointer to memory space
|
|
306
|
+
*
|
|
307
|
+
* @public
|
|
308
|
+
*/
|
|
309
|
+
malloc(size: number): number;
|
|
310
|
+
/**
|
|
311
|
+
* Free memory space
|
|
312
|
+
* @param ptr pointer to memory space
|
|
313
|
+
*
|
|
314
|
+
* @public
|
|
315
|
+
*/
|
|
316
|
+
free(ptr: number): void;
|
|
317
|
+
/**
|
|
318
|
+
* Set the rect of specified annotation
|
|
319
|
+
* @param page - page info that the annotation is belonged to
|
|
320
|
+
* @param pagePtr - pointer of page object
|
|
321
|
+
* @param annotationPtr - pointer to annotation object
|
|
322
|
+
* @param inkList - ink lists that added to the annotation
|
|
323
|
+
* @returns whether the ink lists is setted
|
|
324
|
+
*
|
|
325
|
+
* @private
|
|
326
|
+
*/
|
|
327
|
+
addInkStroke(page: PdfPageObject, pagePtr: number, annotationPtr: number, inkList: PdfInkListObject[]): boolean;
|
|
328
|
+
/**
|
|
329
|
+
* Add contents to stamp annotation
|
|
330
|
+
* @param docPtr - pointer to pdf document object
|
|
331
|
+
* @param page - page info
|
|
332
|
+
* @param pagePtr - pointer to page object
|
|
333
|
+
* @param annotationPtr - pointer to stamp annotation
|
|
334
|
+
* @param rect - rect of stamp annotation
|
|
335
|
+
* @param contents - contents of stamp annotation
|
|
336
|
+
* @returns whether contents is added to annotation
|
|
337
|
+
*
|
|
338
|
+
* @private
|
|
339
|
+
*/
|
|
340
|
+
addStampContent(docPtr: number, page: PdfPageObject, pagePtr: number, annotationPtr: number, rect: Rect, contents: PdfStampAnnoObjectContents): boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Add image object to annotation
|
|
343
|
+
* @param docPtr - pointer to pdf document object
|
|
344
|
+
* @param page - page info
|
|
345
|
+
* @param pagePtr - pointer to page object
|
|
346
|
+
* @param annotationPtr - pointer to stamp annotation
|
|
347
|
+
* @param position - position of image
|
|
348
|
+
* @param imageData - data of image
|
|
349
|
+
* @returns whether image is added to annotation
|
|
350
|
+
*
|
|
351
|
+
* @private
|
|
352
|
+
*/
|
|
353
|
+
addImageObject(docPtr: number, page: PdfPageObject, pagePtr: number, annotationPtr: number, position: Position, imageData: ImageData): boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Save document to array buffer
|
|
356
|
+
* @param docPtr - pointer to pdf document
|
|
357
|
+
* @returns array buffer contains the pdf content
|
|
358
|
+
*
|
|
359
|
+
* @private
|
|
360
|
+
*/
|
|
361
|
+
saveDocument(docPtr: number): ArrayBuffer;
|
|
362
|
+
/**
|
|
363
|
+
* Read metadata from pdf document
|
|
364
|
+
* @param docPtr - pointer to pdf document
|
|
365
|
+
* @param key - key of metadata field
|
|
366
|
+
* @returns metadata value
|
|
367
|
+
*
|
|
368
|
+
* @private
|
|
369
|
+
*/
|
|
370
|
+
readMetaText(docPtr: number, key: string): string;
|
|
371
|
+
/**
|
|
372
|
+
* Read bookmarks in the pdf document
|
|
373
|
+
* @param docPtr - pointer to pdf document
|
|
374
|
+
* @param rootBookmarkPtr - pointer to root bookmark
|
|
375
|
+
* @returns bookmarks in the pdf document
|
|
376
|
+
*
|
|
377
|
+
* @private
|
|
378
|
+
*/
|
|
379
|
+
readPdfBookmarks(docPtr: number, rootBookmarkPtr?: number): PdfBookmarkObject[];
|
|
380
|
+
/**
|
|
381
|
+
* Read bookmark in the pdf document
|
|
382
|
+
* @param docPtr - pointer to pdf document
|
|
383
|
+
* @param bookmarkPtr - pointer to bookmark object
|
|
384
|
+
* @returns pdf bookmark object
|
|
385
|
+
*
|
|
386
|
+
* @private
|
|
387
|
+
*/
|
|
388
|
+
private readPdfBookmark;
|
|
389
|
+
/**
|
|
390
|
+
* Read text rects in pdf page
|
|
391
|
+
* @param page - pdf page info
|
|
392
|
+
* @param docPtr - pointer to pdf document
|
|
393
|
+
* @param pagePtr - pointer to pdf page
|
|
394
|
+
* @param textPagePtr - pointer to pdf text page
|
|
395
|
+
* @returns text rects in the pdf page
|
|
396
|
+
*
|
|
397
|
+
* @public
|
|
398
|
+
*/
|
|
399
|
+
private readPageTextRects;
|
|
400
|
+
/**
|
|
401
|
+
* Return geometric + logical text layout for one page
|
|
402
|
+
* (glyph-only implementation, no FPDFText_GetRect).
|
|
403
|
+
*
|
|
404
|
+
* @public
|
|
405
|
+
*/
|
|
406
|
+
getPageGeometry(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfPageGeometry>;
|
|
407
|
+
/**
|
|
408
|
+
* Group consecutive glyphs that belong to the same CPDF_TextObject
|
|
409
|
+
* using FPDFText_GetTextObject(), and calculate rotation from glyph positions.
|
|
410
|
+
*/
|
|
411
|
+
private buildRunsFromGlyphs;
|
|
412
|
+
/**
|
|
413
|
+
* Extract glyph geometry + metadata for `charIndex`
|
|
414
|
+
*
|
|
415
|
+
* Returns device–space coordinates:
|
|
416
|
+
* x,y → **top-left** corner (integer-pixels)
|
|
417
|
+
* w,h → width / height (integer-pixels, ≥ 1)
|
|
418
|
+
*
|
|
419
|
+
* And two flags:
|
|
420
|
+
* isSpace → true if the glyph's Unicode code-point is U+0020
|
|
421
|
+
*/
|
|
422
|
+
private readGlyphInfo;
|
|
423
|
+
/**
|
|
424
|
+
* Geometry-only text extraction
|
|
425
|
+
* ------------------------------------------
|
|
426
|
+
* Returns every glyph on the requested page
|
|
427
|
+
* in the logical order delivered by PDFium.
|
|
428
|
+
*
|
|
429
|
+
* The promise resolves to an array of objects:
|
|
430
|
+
* {
|
|
431
|
+
* idx: number; // glyph index on the page (0…n-1)
|
|
432
|
+
* origin: { x: number; y: number };
|
|
433
|
+
* size: { width: number; height: number };
|
|
434
|
+
* angle: number; // degrees, counter-clock-wise
|
|
435
|
+
* isSpace: boolean; // true → U+0020
|
|
436
|
+
* }
|
|
437
|
+
*
|
|
438
|
+
* No Unicode is included; front-end decides whether to hydrate it.
|
|
439
|
+
*/
|
|
440
|
+
getPageGlyphs(doc: PdfDocumentObject, page: PdfPageObject): PdfTask<PdfGlyphObject[]>;
|
|
441
|
+
private readCharBox;
|
|
442
|
+
/**
|
|
443
|
+
* Read page annotations
|
|
444
|
+
* @param page - page info
|
|
445
|
+
* @param docPtr - pointer to pdf document
|
|
446
|
+
* @param pagePtr - pointer to pdf page
|
|
447
|
+
* @param textPagePtr - pointe to pdf text page
|
|
448
|
+
* @param scaleFactor - scale factor
|
|
449
|
+
* @param rotation - rotation angle
|
|
450
|
+
* @returns annotations on the pdf page
|
|
451
|
+
*
|
|
452
|
+
* @private
|
|
453
|
+
*/
|
|
454
|
+
private readPageAnnotations;
|
|
455
|
+
/**
|
|
456
|
+
* Read pdf annotation from pdf document
|
|
457
|
+
* @param page - pdf page infor
|
|
458
|
+
* @param docPtr - pointer to pdf document object
|
|
459
|
+
* @param pagePtr - pointer to pdf page object
|
|
460
|
+
* @param textPagePtr - pointer to pdf text page object
|
|
461
|
+
* @param formHandle - form handle
|
|
462
|
+
* @param index - index of annotation in the pdf page
|
|
463
|
+
* @param scaleFactor - factor of scalling
|
|
464
|
+
* @param rotation - rotation angle
|
|
465
|
+
* @returns pdf annotation
|
|
466
|
+
*
|
|
467
|
+
* @private
|
|
468
|
+
*/
|
|
469
|
+
private readPageAnnotation;
|
|
470
|
+
/**
|
|
471
|
+
* Return the colour stored directly in the annotation dictionary's `/C` entry.
|
|
472
|
+
*
|
|
473
|
+
* Most PDFs created by Acrobat, Microsoft Office, LaTeX, etc. include this entry.
|
|
474
|
+
* When the key is absent (common in macOS Preview, Chrome, Drawboard) the call
|
|
475
|
+
* fails and the function returns `undefined`.
|
|
476
|
+
*
|
|
477
|
+
* @param annotationPtr - pointer to an `FPDF_ANNOTATION`
|
|
478
|
+
* @returns An RGBA tuple (0-255 channels) or `undefined` if no `/C` entry exists
|
|
479
|
+
*
|
|
480
|
+
* @private
|
|
481
|
+
*/
|
|
482
|
+
private readAnnotationColor;
|
|
483
|
+
/**
|
|
484
|
+
* Extract the fill (or, if absent, the stroke) colour from a **path object**
|
|
485
|
+
* inside an appearance stream.
|
|
486
|
+
*
|
|
487
|
+
* Works for simple highlights produced by Chrome, Preview, etc. that paint a
|
|
488
|
+
* single filled rectangle with the desired tint.
|
|
489
|
+
*
|
|
490
|
+
* @param pathPtr - pointer to a `FPDF_PAGEOBJECT` of type **PATH**
|
|
491
|
+
* @returns RGBA tuple or `undefined` when no colour is set on the path
|
|
492
|
+
*
|
|
493
|
+
* @private
|
|
494
|
+
*/
|
|
495
|
+
private getColorFromPath;
|
|
496
|
+
/**
|
|
497
|
+
* Recursively walk a page-object tree (PATHs and nested FORM XObjects) until
|
|
498
|
+
* a colour can be extracted.
|
|
499
|
+
*
|
|
500
|
+
* Acrobat often wraps its highlight rectangle in a Form XObject referenced by
|
|
501
|
+
* the "Do" operator, so this function drills down unlimited depth.
|
|
502
|
+
*
|
|
503
|
+
* @param objPtr - pointer to a `FPDF_PAGEOBJECT`
|
|
504
|
+
* @returns First RGBA tint found, or `undefined` if none of the descendants
|
|
505
|
+
* carry an explicit fill/stroke colour
|
|
506
|
+
*
|
|
507
|
+
* @private
|
|
508
|
+
*/
|
|
509
|
+
private walkPageObjTree;
|
|
510
|
+
/**
|
|
511
|
+
* Iterate over every top-level object in the annotation's **appearance stream**
|
|
512
|
+
* and invoke {@link walkPageObjTree} to locate a usable tint.
|
|
513
|
+
*
|
|
514
|
+
* Catches:
|
|
515
|
+
* • Simple filled path (Preview, Chrome)
|
|
516
|
+
* • Form XObject containing the path (Acrobat)
|
|
517
|
+
*
|
|
518
|
+
* @param annotPtr - pointer to an `FPDF_ANNOTATION`
|
|
519
|
+
* @returns RGBA tuple or `undefined` when no colour can be resolved from AP
|
|
520
|
+
*
|
|
521
|
+
* @private
|
|
522
|
+
*/
|
|
523
|
+
private colorFromAppearance;
|
|
524
|
+
/**
|
|
525
|
+
* Resolve the visible fill colour for **Highlight / Underline / StrikeOut /
|
|
526
|
+
* Squiggly** markup annotations.
|
|
527
|
+
*
|
|
528
|
+
* Resolution order (first non-`undefined` wins):
|
|
529
|
+
* 1. `/C` dictionary entry – fast, present in Acrobat / Office PDFs
|
|
530
|
+
* 2. Appearance-stream objects – drills into paths & nested forms
|
|
531
|
+
* 3. Hard-coded fallback (Acrobat-style opaque yellow)
|
|
532
|
+
*
|
|
533
|
+
* @param annotationPtr - pointer to an `FPDF_ANNOTATION`
|
|
534
|
+
* @param fallback - colour to use when the PDF stores no tint at all
|
|
535
|
+
* @returns Guaranteed RGBA tuple (never `undefined`)
|
|
536
|
+
*
|
|
537
|
+
* @private
|
|
538
|
+
*/
|
|
539
|
+
private resolveAnnotationColor;
|
|
540
|
+
/**
|
|
541
|
+
* Read `/QuadPoints` from any annotation and convert each quadrilateral to
|
|
542
|
+
* device-space coordinates.
|
|
543
|
+
*
|
|
544
|
+
* The four points are returned in natural reading order:
|
|
545
|
+
* `p1 → p2` (top edge) and `p4 → p3` (bottom edge).
|
|
546
|
+
* This preserves the true shape for rotated / skewed text, whereas callers
|
|
547
|
+
* that only need axis-aligned boxes can collapse each quad themselves.
|
|
548
|
+
*
|
|
549
|
+
* @param page - logical page info object (`PdfPageObject`)
|
|
550
|
+
* @param annotationPtr - pointer to the annotation whose quads are needed
|
|
551
|
+
* @returns Array of `Quad` objects (`[]` if the annotation has no quads)
|
|
552
|
+
*
|
|
553
|
+
* @private
|
|
554
|
+
*/
|
|
555
|
+
private readAnnotationQuads;
|
|
556
|
+
/**
|
|
557
|
+
* Read pdf text annotation
|
|
558
|
+
* @param page - pdf page infor
|
|
559
|
+
* @param pagePtr - pointer to pdf page object
|
|
560
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
561
|
+
* @param index - index of annotation in the pdf page
|
|
562
|
+
* @returns pdf text annotation
|
|
563
|
+
*
|
|
564
|
+
* @private
|
|
565
|
+
*/
|
|
566
|
+
private readPdfTextAnno;
|
|
567
|
+
/**
|
|
568
|
+
* Read pdf freetext annotation
|
|
569
|
+
* @param page - pdf page infor
|
|
570
|
+
* @param pagePtr - pointer to pdf page object
|
|
571
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
572
|
+
* @param index - index of annotation in the pdf page
|
|
573
|
+
* @returns pdf freetext annotation
|
|
574
|
+
*
|
|
575
|
+
* @private
|
|
576
|
+
*/
|
|
577
|
+
private readPdfFreeTextAnno;
|
|
578
|
+
/**
|
|
579
|
+
* Read pdf link annotation from pdf document
|
|
580
|
+
* @param page - pdf page infor
|
|
581
|
+
* @param docPtr - pointer to pdf document object
|
|
582
|
+
* @param pagePtr - pointer to pdf page object
|
|
583
|
+
* @param textPagePtr - pointer to pdf text page object
|
|
584
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
585
|
+
* @param index - index of annotation in the pdf page
|
|
586
|
+
* @returns pdf link annotation
|
|
587
|
+
*
|
|
588
|
+
* @private
|
|
589
|
+
*/
|
|
590
|
+
private readPdfLinkAnno;
|
|
591
|
+
/**
|
|
592
|
+
* Read pdf widget annotation
|
|
593
|
+
* @param page - pdf page infor
|
|
594
|
+
* @param pagePtr - pointer to pdf page object
|
|
595
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
596
|
+
* @param formHandle - form handle
|
|
597
|
+
* @param index - index of annotation in the pdf page
|
|
598
|
+
* @returns pdf widget annotation
|
|
599
|
+
*
|
|
600
|
+
* @private
|
|
601
|
+
*/
|
|
602
|
+
private readPdfWidgetAnno;
|
|
603
|
+
/**
|
|
604
|
+
* Read pdf file attachment annotation
|
|
605
|
+
* @param page - pdf page infor
|
|
606
|
+
* @param pagePtr - pointer to pdf page object
|
|
607
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
608
|
+
* @param index - index of annotation in the pdf page
|
|
609
|
+
* @returns pdf file attachment annotation
|
|
610
|
+
*
|
|
611
|
+
* @private
|
|
612
|
+
*/
|
|
613
|
+
private readPdfFileAttachmentAnno;
|
|
614
|
+
/**
|
|
615
|
+
* Read pdf ink annotation
|
|
616
|
+
* @param page - pdf page infor
|
|
617
|
+
* @param pagePtr - pointer to pdf page object
|
|
618
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
619
|
+
* @param index - index of annotation in the pdf page
|
|
620
|
+
* @returns pdf ink annotation
|
|
621
|
+
*
|
|
622
|
+
* @private
|
|
623
|
+
*/
|
|
624
|
+
private readPdfInkAnno;
|
|
625
|
+
/**
|
|
626
|
+
* Read pdf polygon annotation
|
|
627
|
+
* @param page - pdf page infor
|
|
628
|
+
* @param pagePtr - pointer to pdf page object
|
|
629
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
630
|
+
* @param index - index of annotation in the pdf page
|
|
631
|
+
* @returns pdf polygon annotation
|
|
632
|
+
*
|
|
633
|
+
* @private
|
|
634
|
+
*/
|
|
635
|
+
private readPdfPolygonAnno;
|
|
636
|
+
/**
|
|
637
|
+
* Read pdf polyline annotation
|
|
638
|
+
* @param page - pdf page infor
|
|
639
|
+
* @param pagePtr - pointer to pdf page object
|
|
640
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
641
|
+
* @param index - index of annotation in the pdf page
|
|
642
|
+
* @returns pdf polyline annotation
|
|
643
|
+
*
|
|
644
|
+
* @private
|
|
645
|
+
*/
|
|
646
|
+
private readPdfPolylineAnno;
|
|
647
|
+
/**
|
|
648
|
+
* Read pdf line annotation
|
|
649
|
+
* @param page - pdf page infor
|
|
650
|
+
* @param pagePtr - pointer to pdf page object
|
|
651
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
652
|
+
* @param index - index of annotation in the pdf page
|
|
653
|
+
* @returns pdf line annotation
|
|
654
|
+
*
|
|
655
|
+
* @private
|
|
656
|
+
*/
|
|
657
|
+
private readPdfLineAnno;
|
|
658
|
+
/**
|
|
659
|
+
* Read pdf highlight annotation
|
|
660
|
+
* @param page - pdf page infor
|
|
661
|
+
* @param pagePtr - pointer to pdf page object
|
|
662
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
663
|
+
* @param index - index of annotation in the pdf page
|
|
664
|
+
* @returns pdf highlight annotation
|
|
665
|
+
*
|
|
666
|
+
* @private
|
|
667
|
+
*/
|
|
668
|
+
private readPdfHighlightAnno;
|
|
669
|
+
/**
|
|
670
|
+
* Read pdf underline annotation
|
|
671
|
+
* @param page - pdf page infor
|
|
672
|
+
* @param pagePtr - pointer to pdf page object
|
|
673
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
674
|
+
* @param index - index of annotation in the pdf page
|
|
675
|
+
* @returns pdf underline annotation
|
|
676
|
+
*
|
|
677
|
+
* @private
|
|
678
|
+
*/
|
|
679
|
+
private readPdfUnderlineAnno;
|
|
680
|
+
/**
|
|
681
|
+
* Read strikeout annotation
|
|
682
|
+
* @param page - pdf page infor
|
|
683
|
+
* @param pagePtr - pointer to pdf page object
|
|
684
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
685
|
+
* @param index - index of annotation in the pdf page
|
|
686
|
+
* @returns pdf strikeout annotation
|
|
687
|
+
*
|
|
688
|
+
* @private
|
|
689
|
+
*/
|
|
690
|
+
private readPdfStrikeOutAnno;
|
|
691
|
+
/**
|
|
692
|
+
* Read pdf squiggly annotation
|
|
693
|
+
* @param page - pdf page infor
|
|
694
|
+
* @param pagePtr - pointer to pdf page object
|
|
695
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
696
|
+
* @param index - index of annotation in the pdf page
|
|
697
|
+
* @returns pdf squiggly annotation
|
|
698
|
+
*
|
|
699
|
+
* @private
|
|
700
|
+
*/
|
|
701
|
+
private readPdfSquigglyAnno;
|
|
702
|
+
/**
|
|
703
|
+
* Read pdf caret annotation
|
|
704
|
+
* @param page - pdf page infor
|
|
705
|
+
* @param pagePtr - pointer to pdf page object
|
|
706
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
707
|
+
* @param index - index of annotation in the pdf page
|
|
708
|
+
* @returns pdf caret annotation
|
|
709
|
+
*
|
|
710
|
+
* @private
|
|
711
|
+
*/
|
|
712
|
+
private readPdfCaretAnno;
|
|
713
|
+
/**
|
|
714
|
+
* Read pdf stamp annotation
|
|
715
|
+
* @param docPtr - pointer to pdf document object
|
|
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 stamp annotation
|
|
721
|
+
*
|
|
722
|
+
* @private
|
|
723
|
+
*/
|
|
724
|
+
private readPdfStampAnno;
|
|
725
|
+
/**
|
|
726
|
+
* Read pdf object in pdf page
|
|
727
|
+
* @param pageObjectPtr - pointer to pdf object in page
|
|
728
|
+
* @returns pdf object in page
|
|
729
|
+
*
|
|
730
|
+
* @private
|
|
731
|
+
*/
|
|
732
|
+
private readPdfPageObject;
|
|
733
|
+
/**
|
|
734
|
+
* Read pdf path object
|
|
735
|
+
* @param pathObjectPtr - pointer to pdf path object in page
|
|
736
|
+
* @returns pdf path object
|
|
737
|
+
*
|
|
738
|
+
* @private
|
|
739
|
+
*/
|
|
740
|
+
private readPathObject;
|
|
741
|
+
/**
|
|
742
|
+
* Read segment of pdf path object
|
|
743
|
+
* @param annotationObjectPtr - pointer to pdf path object
|
|
744
|
+
* @param segmentIndex - index of segment
|
|
745
|
+
* @returns pdf segment in pdf path
|
|
746
|
+
*
|
|
747
|
+
* @private
|
|
748
|
+
*/
|
|
749
|
+
private readPdfSegment;
|
|
750
|
+
/**
|
|
751
|
+
* Read pdf image object from pdf document
|
|
752
|
+
* @param pageObjectPtr - pointer to pdf image object in page
|
|
753
|
+
* @returns pdf image object
|
|
754
|
+
*
|
|
755
|
+
* @private
|
|
756
|
+
*/
|
|
757
|
+
private readImageObject;
|
|
758
|
+
/**
|
|
759
|
+
* Read form object from pdf document
|
|
760
|
+
* @param formObjectPtr - pointer to pdf form object in page
|
|
761
|
+
* @returns pdf form object
|
|
762
|
+
*
|
|
763
|
+
* @private
|
|
764
|
+
*/
|
|
765
|
+
private readFormObject;
|
|
766
|
+
/**
|
|
767
|
+
* Read pdf object in pdf page
|
|
768
|
+
* @param pageObjectPtr - pointer to pdf object in page
|
|
769
|
+
* @returns pdf object in page
|
|
770
|
+
*
|
|
771
|
+
* @private
|
|
772
|
+
*/
|
|
773
|
+
private readPdfPageObjectTransformMatrix;
|
|
774
|
+
/**
|
|
775
|
+
* Read circle annotation
|
|
776
|
+
* @param page - pdf page infor
|
|
777
|
+
* @param pagePtr - pointer to pdf page object
|
|
778
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
779
|
+
* @param index - index of annotation in the pdf page
|
|
780
|
+
* @returns pdf circle annotation
|
|
781
|
+
*
|
|
782
|
+
* @private
|
|
783
|
+
*/
|
|
784
|
+
private readPdfCircleAnno;
|
|
785
|
+
/**
|
|
786
|
+
* Read square annotation
|
|
787
|
+
* @param page - pdf page infor
|
|
788
|
+
* @param pagePtr - pointer to pdf page object
|
|
789
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
790
|
+
* @param index - index of annotation in the pdf page
|
|
791
|
+
* @returns pdf square annotation
|
|
792
|
+
*
|
|
793
|
+
* @private
|
|
794
|
+
*/
|
|
795
|
+
private readPdfSquareAnno;
|
|
796
|
+
/**
|
|
797
|
+
* Read basic info of unsupported pdf annotation
|
|
798
|
+
* @param page - pdf page infor
|
|
799
|
+
* @param pagePtr - pointer to pdf page object
|
|
800
|
+
* @param type - type of annotation
|
|
801
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
802
|
+
* @param index - index of annotation in the pdf page
|
|
803
|
+
* @returns pdf annotation
|
|
804
|
+
*
|
|
805
|
+
* @private
|
|
806
|
+
*/
|
|
807
|
+
private readPdfAnno;
|
|
808
|
+
/**
|
|
809
|
+
* Resolve `/IRT` → parent-annotation index on the same page.
|
|
810
|
+
*
|
|
811
|
+
* @param pagePtr - pointer to FPDF_PAGE
|
|
812
|
+
* @param annotationPtr - pointer to FPDF_ANNOTATION
|
|
813
|
+
* @returns index (`0…count-1`) or `undefined` when the annotation is *not* a reply
|
|
814
|
+
*
|
|
815
|
+
* @private
|
|
816
|
+
*/
|
|
817
|
+
private getInReplyToId;
|
|
818
|
+
/**
|
|
819
|
+
* Parse a PDF date string **D:YYYYMMDDHHmmSSOHH'mm'** to ISO-8601.
|
|
820
|
+
*
|
|
821
|
+
* Returns `undefined` if the input is malformed.
|
|
822
|
+
*
|
|
823
|
+
* @private
|
|
824
|
+
*/
|
|
825
|
+
private toIsoDate;
|
|
826
|
+
/**
|
|
827
|
+
* Fetch a string value (`/T`, `/M`, `/State`, …) from an annotation.
|
|
828
|
+
*
|
|
829
|
+
* @returns decoded UTF-8 string or `undefined` when the key is absent
|
|
830
|
+
*
|
|
831
|
+
* @private
|
|
832
|
+
*/
|
|
833
|
+
private getAnnotString;
|
|
834
|
+
/**
|
|
835
|
+
* Read linked popup of pdf annotation
|
|
836
|
+
* @param page - pdf page infor
|
|
837
|
+
* @param pagePtr - pointer to pdf page object
|
|
838
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
839
|
+
* @param index - index of annotation in the pdf page
|
|
840
|
+
* @returns pdf popup linked to annotation
|
|
841
|
+
*
|
|
842
|
+
* @private
|
|
843
|
+
*/
|
|
844
|
+
private readPdfAnnoLinkedPopup;
|
|
845
|
+
/**
|
|
846
|
+
* Read vertices of pdf annotation
|
|
847
|
+
* @param page - pdf page infor
|
|
848
|
+
* @param pagePtr - pointer to pdf page object
|
|
849
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
850
|
+
* @returns vertices of pdf annotation
|
|
851
|
+
*
|
|
852
|
+
* @private
|
|
853
|
+
*/
|
|
854
|
+
private readPdfAnnoVertices;
|
|
855
|
+
/**
|
|
856
|
+
* Read the target of pdf bookmark
|
|
857
|
+
* @param docPtr - pointer to pdf document object
|
|
858
|
+
* @param getActionPtr - callback function to retrive the pointer of action
|
|
859
|
+
* @param getDestinationPtr - callback function to retrive the pointer of destination
|
|
860
|
+
* @returns target of pdf bookmark
|
|
861
|
+
*
|
|
862
|
+
* @private
|
|
863
|
+
*/
|
|
864
|
+
private readPdfBookmarkTarget;
|
|
865
|
+
/**
|
|
866
|
+
* Read field of pdf widget annotation
|
|
867
|
+
* @param formHandle - form handle
|
|
868
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
869
|
+
* @returns field of pdf widget annotation
|
|
870
|
+
*
|
|
871
|
+
* @private
|
|
872
|
+
*/
|
|
873
|
+
private readPdfWidgetAnnoField;
|
|
874
|
+
/**
|
|
875
|
+
* render rectangle of pdf page to image
|
|
876
|
+
* @param docPtr - pointer to pdf document object
|
|
877
|
+
* @param page - pdf page infor
|
|
878
|
+
* @param rect - rectangle info
|
|
879
|
+
* @param scaleFactor - factor of scalling
|
|
880
|
+
* @param rotation - rotation angle
|
|
881
|
+
* @param options - render options
|
|
882
|
+
* @returns image data
|
|
883
|
+
*
|
|
884
|
+
* @private
|
|
885
|
+
*/
|
|
886
|
+
private renderPageRectToImageData;
|
|
887
|
+
/**
|
|
888
|
+
* Read the target of pdf link annotation
|
|
889
|
+
* @param docPtr - pointer to pdf document object
|
|
890
|
+
* @param getActionPtr - callback function to retrive the pointer of action
|
|
891
|
+
* @param getDestinationPtr - callback function to retrive the pointer of destination
|
|
892
|
+
* @returns target of link
|
|
893
|
+
*
|
|
894
|
+
* @private
|
|
895
|
+
*/
|
|
896
|
+
private readPdfLinkAnnoTarget;
|
|
897
|
+
/**
|
|
898
|
+
* Read pdf action from pdf document
|
|
899
|
+
* @param docPtr - pointer to pdf document object
|
|
900
|
+
* @param actionPtr - pointer to pdf action object
|
|
901
|
+
* @returns pdf action object
|
|
902
|
+
*
|
|
903
|
+
* @private
|
|
904
|
+
*/
|
|
905
|
+
private readPdfAction;
|
|
906
|
+
/**
|
|
907
|
+
* Read pdf destination object
|
|
908
|
+
* @param docPtr - pointer to pdf document object
|
|
909
|
+
* @param destinationPtr - pointer to pdf destination
|
|
910
|
+
* @returns pdf destination object
|
|
911
|
+
*
|
|
912
|
+
* @private
|
|
913
|
+
*/
|
|
914
|
+
private readPdfDestination;
|
|
915
|
+
/**
|
|
916
|
+
* Read attachmet from pdf document
|
|
917
|
+
* @param docPtr - pointer to pdf document object
|
|
918
|
+
* @param index - index of attachment
|
|
919
|
+
* @returns attachment content
|
|
920
|
+
*
|
|
921
|
+
* @private
|
|
922
|
+
*/
|
|
923
|
+
private readPdfAttachment;
|
|
924
|
+
/**
|
|
925
|
+
* Convert coordinate of point from device coordinate to page coordinate
|
|
926
|
+
* @param page - pdf page infor
|
|
927
|
+
* @param position - position of point
|
|
928
|
+
* @returns converted position
|
|
929
|
+
*
|
|
930
|
+
* @private
|
|
931
|
+
*/
|
|
932
|
+
private convertDevicePointToPagePoint;
|
|
933
|
+
/**
|
|
934
|
+
* Convert coordinate of point from page coordinate to device coordinate
|
|
935
|
+
* @param page - pdf page infor
|
|
936
|
+
* @param position - position of point
|
|
937
|
+
* @returns converted position
|
|
938
|
+
*
|
|
939
|
+
* @private
|
|
940
|
+
*/
|
|
941
|
+
private convertPagePointToDevicePoint;
|
|
942
|
+
/**
|
|
943
|
+
* Convert coordinate of rectangle from page coordinate to device coordinate
|
|
944
|
+
* @param page - pdf page infor
|
|
945
|
+
* @param pagePtr - pointer to pdf page object
|
|
946
|
+
* @param pageRect - rectangle that needs to be converted
|
|
947
|
+
* @returns converted rectangle
|
|
948
|
+
*
|
|
949
|
+
* @private
|
|
950
|
+
*/
|
|
951
|
+
private convertPageRectToDeviceRect;
|
|
952
|
+
/**
|
|
953
|
+
* Read the appearance stream of annotation
|
|
954
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
955
|
+
* @param mode - appearance mode
|
|
956
|
+
* @returns appearance stream
|
|
957
|
+
*
|
|
958
|
+
* @private
|
|
959
|
+
*/
|
|
960
|
+
private readPageAnnoAppearanceStreams;
|
|
961
|
+
/**
|
|
962
|
+
* Read the appearance stream of annotation
|
|
963
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
964
|
+
* @param mode - appearance mode
|
|
965
|
+
* @returns appearance stream
|
|
966
|
+
*
|
|
967
|
+
* @private
|
|
968
|
+
*/
|
|
969
|
+
private readPageAnnoAppearanceStream;
|
|
970
|
+
/**
|
|
971
|
+
* Set the rect of specified annotation
|
|
972
|
+
* @param page - page info that the annotation is belonged to
|
|
973
|
+
* @param pagePtr - pointer of page object
|
|
974
|
+
* @param annotationPtr - pointer to annotation object
|
|
975
|
+
* @param rect - target rectangle
|
|
976
|
+
* @returns whether the rect is setted
|
|
977
|
+
*
|
|
978
|
+
* @private
|
|
979
|
+
*/
|
|
980
|
+
setPageAnnoRect(page: PdfPageObject, pagePtr: number, annotationPtr: number, rect: Rect): boolean;
|
|
981
|
+
/**
|
|
982
|
+
* Read the rectangle of annotation
|
|
983
|
+
* @param annotationPtr - pointer to pdf annotation
|
|
984
|
+
* @returns rectangle of annotation
|
|
985
|
+
*
|
|
986
|
+
* @private
|
|
987
|
+
*/
|
|
988
|
+
private readPageAnnoRect;
|
|
989
|
+
/**
|
|
990
|
+
* Get highlight rects for a specific character range (for search highlighting)
|
|
991
|
+
* @param page - pdf page info
|
|
992
|
+
* @param pagePtr - pointer to pdf page
|
|
993
|
+
* @param textPagePtr - pointer to pdf text page
|
|
994
|
+
* @param startIndex - starting character index
|
|
995
|
+
* @param charCount - number of characters in the range
|
|
996
|
+
* @returns array of rectangles for highlighting the specified character range
|
|
997
|
+
*
|
|
998
|
+
* @private
|
|
999
|
+
*/
|
|
1000
|
+
private getHighlightRects;
|
|
1001
|
+
/**
|
|
1002
|
+
* Search for a keyword across all pages in the document
|
|
1003
|
+
* Returns all search results throughout the entire document
|
|
1004
|
+
*
|
|
1005
|
+
* @param doc - Pdf document object
|
|
1006
|
+
* @param keyword - Search keyword
|
|
1007
|
+
* @param flags - Match flags for search
|
|
1008
|
+
* @returns Promise of all search results in the document
|
|
1009
|
+
*
|
|
1010
|
+
* @public
|
|
1011
|
+
*/
|
|
1012
|
+
searchAllPages(doc: PdfDocumentObject, keyword: string, flags?: MatchFlag[]): Task<SearchAllPagesResult, PdfErrorReason>;
|
|
1013
|
+
/**
|
|
1014
|
+
* Extract word-aligned context for a search hit.
|
|
1015
|
+
*
|
|
1016
|
+
* @param fullText full UTF-16 page text (fetch this once per page!)
|
|
1017
|
+
* @param start index of 1st char that matched
|
|
1018
|
+
* @param count number of chars in the match
|
|
1019
|
+
* @param windowChars minimum context chars to keep left & right
|
|
1020
|
+
*/
|
|
1021
|
+
private buildContext;
|
|
1022
|
+
/**
|
|
1023
|
+
* Tidy the text to remove any non-printable characters and whitespace
|
|
1024
|
+
* @param s - text to tidy
|
|
1025
|
+
* @returns tidied text
|
|
1026
|
+
*
|
|
1027
|
+
* @private
|
|
1028
|
+
*/
|
|
1029
|
+
private tidy;
|
|
1030
|
+
/**
|
|
1031
|
+
* Search for all occurrences of a keyword on a single page
|
|
1032
|
+
* This method efficiently loads the page only once and finds all matches
|
|
1033
|
+
*
|
|
1034
|
+
* @param docPtr - pointer to pdf document
|
|
1035
|
+
* @param page - pdf page object
|
|
1036
|
+
* @param pageIndex - index of the page
|
|
1037
|
+
* @param keywordPtr - pointer to the search keyword
|
|
1038
|
+
* @param flag - search flags
|
|
1039
|
+
* @returns array of search results on this page
|
|
1040
|
+
*
|
|
1041
|
+
* @private
|
|
1042
|
+
*/
|
|
1043
|
+
private searchAllInPage;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Read string from WASM heap
|
|
1048
|
+
* @param wasmModule - pdfium wasm module instance
|
|
1049
|
+
* @param readChars - function to read chars
|
|
1050
|
+
* @param parseChars - function to parse chars
|
|
1051
|
+
* @param defaultLength - default length of chars that needs to read
|
|
1052
|
+
* @returns string from the heap
|
|
1053
|
+
*
|
|
1054
|
+
* @public
|
|
1055
|
+
*/
|
|
1056
|
+
declare function readString(wasmModule: PdfiumRuntimeMethods & PdfiumModule, readChars: (buffer: number, bufferLength: number) => number, parseChars: (buffer: number) => string, defaultLength?: number): string;
|
|
1057
|
+
/**
|
|
1058
|
+
* Read arraybyffer from WASM heap
|
|
1059
|
+
* @param wasmModule - pdfium wasm module instance
|
|
1060
|
+
* @param readChars - function to read chars
|
|
1061
|
+
* @returns arraybuffer from the heap
|
|
1062
|
+
*
|
|
1063
|
+
* @public
|
|
1064
|
+
*/
|
|
1065
|
+
declare function readArrayBuffer(wasmModule: PdfiumRuntimeMethods & PdfiumModule, readChars: (buffer: number, bufferLength: number) => number): ArrayBuffer;
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* EngineRunner for pdfium-based wasm engine
|
|
1069
|
+
*/
|
|
1070
|
+
declare class PdfiumEngineRunner extends EngineRunner {
|
|
1071
|
+
private wasmBinary;
|
|
1072
|
+
/**
|
|
1073
|
+
* Create an instance of PdfiumEngineRunner
|
|
1074
|
+
* @param wasmBinary - wasm binary that contains the pdfium wasm file
|
|
1075
|
+
*/
|
|
1076
|
+
constructor(wasmBinary: ArrayBuffer);
|
|
1077
|
+
/**
|
|
1078
|
+
* Initialize runner
|
|
1079
|
+
*/
|
|
1080
|
+
prepare(): Promise<void>;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
export { BitmapFormat, type ImageDataConverter, PdfiumEngine, PdfiumEngineRunner, PdfiumErrorCode, RenderFlag, type SearchContext, browserImageDataToBlobConverter, readArrayBuffer, readString };
|