pdfium-native 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -41
- package/binding.gyp +27 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/page.d.ts +13 -3
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +22 -3
- package/dist/page.js.map +1 -1
- package/dist/types.d.ts +213 -7
- package/dist/types.d.ts.map +1 -1
- package/lib/index.ts +9 -2
- package/lib/page.ts +22 -4
- package/lib/types.ts +256 -7
- package/package.json +16 -3
- package/scripts/bundle-lib.mjs +24 -3
- package/scripts/download-pdfium.mjs +2 -1
- package/scripts/generate-fixtures.mjs +308 -1
- package/scripts/install.mjs +19 -1
- package/src/annotations_worker.h +274 -0
- package/src/bookmarks_worker.h +162 -0
- package/src/document.h +48 -5
- package/src/form_fields_worker.h +250 -0
- package/src/links_worker.h +158 -0
- package/src/napi_helpers.h +76 -1
- package/src/objects_worker.h +322 -0
- package/src/page.h +62 -9
- package/src/pdfium_addon.cc +93 -17
- package/src/render_worker.h +37 -17
- package/src/search_worker.h +121 -0
- package/src/text_worker.h +69 -0
- package/src/page_workers.h +0 -724
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
export interface PageSize {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
}
|
|
5
1
|
export interface PageRenderOptions {
|
|
6
2
|
/** Scale factor (default: 1, meaning 72 DPI). Use 3–4 for print quality. */
|
|
7
3
|
scale?: number;
|
|
@@ -15,95 +11,305 @@ export interface PageRenderOptions {
|
|
|
15
11
|
quality?: number;
|
|
16
12
|
/** Write to this file path instead of returning a Buffer. */
|
|
17
13
|
output?: string;
|
|
14
|
+
/** Page rotation: 0 = none, 1 = 90° CW, 2 = 180°, 3 = 270° CW. */
|
|
15
|
+
rotation?: 0 | 1 | 2 | 3;
|
|
16
|
+
/** Render with transparent background instead of white (PNG only). */
|
|
17
|
+
transparent?: boolean;
|
|
18
|
+
/** Whether to render annotations (default: true). */
|
|
19
|
+
renderAnnotations?: boolean;
|
|
20
|
+
/** Render in grayscale. */
|
|
21
|
+
grayscale?: boolean;
|
|
22
|
+
/** Enable LCD-optimized text rendering (sub-pixel anti-aliasing). */
|
|
23
|
+
lcdText?: boolean;
|
|
18
24
|
}
|
|
19
25
|
export interface PageObjectBounds {
|
|
26
|
+
/** Left edge in page points. */
|
|
20
27
|
left: number;
|
|
28
|
+
/** Bottom edge in page points. */
|
|
21
29
|
bottom: number;
|
|
30
|
+
/** Right edge in page points. */
|
|
22
31
|
right: number;
|
|
32
|
+
/** Top edge in page points. */
|
|
23
33
|
top: number;
|
|
24
34
|
}
|
|
25
35
|
export interface RGBA {
|
|
36
|
+
/** Red channel (0–255). */
|
|
26
37
|
r: number;
|
|
38
|
+
/** Green channel (0–255). */
|
|
27
39
|
g: number;
|
|
40
|
+
/** Blue channel (0–255). */
|
|
28
41
|
b: number;
|
|
42
|
+
/** Alpha channel (0–255, where 255 is fully opaque). */
|
|
29
43
|
a: number;
|
|
30
44
|
}
|
|
31
45
|
interface BasePageObject {
|
|
46
|
+
/** Bounding box in page coordinates (points). */
|
|
32
47
|
bounds: PageObjectBounds;
|
|
48
|
+
/** Fill color, or null if none. */
|
|
33
49
|
fillColor: RGBA | null;
|
|
50
|
+
/** Stroke color, or null if none. */
|
|
34
51
|
strokeColor: RGBA | null;
|
|
35
52
|
}
|
|
53
|
+
export type TextRenderMode = 'fill' | 'stroke' | 'fillStroke' | 'invisible' | 'fillClip' | 'strokeClip' | 'fillStrokeClip' | 'clip' | 'unknown';
|
|
36
54
|
export interface TextPageObject extends BasePageObject {
|
|
37
55
|
type: 'text';
|
|
56
|
+
/** The text content of this object. */
|
|
38
57
|
text: string;
|
|
58
|
+
/** Font size in points. */
|
|
39
59
|
fontSize: number;
|
|
60
|
+
/** PostScript name of the font. */
|
|
40
61
|
fontName: string;
|
|
62
|
+
/** Font weight (e.g. 400 = normal, 700 = bold). Absent if unavailable. */
|
|
63
|
+
fontWeight?: number;
|
|
64
|
+
/** Italic angle in degrees counterclockwise from vertical. Negative means right-sloping. */
|
|
65
|
+
italicAngle?: number;
|
|
66
|
+
/** Text render mode (e.g. 'fill', 'stroke', 'fillStroke'). */
|
|
67
|
+
renderMode?: TextRenderMode;
|
|
68
|
+
/** Font family name. */
|
|
69
|
+
fontFamily?: string;
|
|
70
|
+
/** Whether the font is embedded in the PDF. */
|
|
71
|
+
isEmbedded?: boolean;
|
|
72
|
+
/** Raw PDF font descriptor flags bitmask (see PDF spec Table 123). */
|
|
73
|
+
fontFlags?: number;
|
|
41
74
|
}
|
|
75
|
+
export type ImageColorspace = 'deviceGray' | 'deviceRGB' | 'deviceCMYK' | 'calGray' | 'calRGB' | 'lab' | 'iccBased' | 'separation' | 'deviceN' | 'indexed' | 'pattern' | 'unknown';
|
|
42
76
|
export interface ImagePageObject extends BasePageObject {
|
|
43
77
|
type: 'image';
|
|
78
|
+
/** Intrinsic image width in pixels. */
|
|
44
79
|
imageWidth: number;
|
|
80
|
+
/** Intrinsic image height in pixels. */
|
|
45
81
|
imageHeight: number;
|
|
82
|
+
/** Horizontal DPI of the image. */
|
|
83
|
+
horizontalDpi?: number;
|
|
84
|
+
/** Vertical DPI of the image. */
|
|
85
|
+
verticalDpi?: number;
|
|
86
|
+
/** Number of bits per pixel. */
|
|
87
|
+
bitsPerPixel?: number;
|
|
88
|
+
/** Image color space (e.g. 'deviceRGB', 'deviceCMYK'). */
|
|
89
|
+
colorspace?: ImageColorspace;
|
|
90
|
+
/** Compression filters applied to the image (e.g. 'FlateDecode', 'DCTDecode'). */
|
|
91
|
+
filters?: string[];
|
|
46
92
|
}
|
|
47
93
|
export interface OtherPageObject extends BasePageObject {
|
|
48
94
|
type: 'path' | 'shading' | 'form' | 'unknown';
|
|
49
95
|
}
|
|
50
96
|
export type PageObject = TextPageObject | ImagePageObject | OtherPageObject;
|
|
51
|
-
export type PageObjectType = PageObject['type'];
|
|
52
97
|
export interface SearchOptions {
|
|
98
|
+
/** Match case when searching (default: false). */
|
|
53
99
|
caseSensitive?: boolean;
|
|
100
|
+
/** Only match whole words (default: false). */
|
|
54
101
|
wholeWord?: boolean;
|
|
102
|
+
/** Allow overlapping matches (default: false). */
|
|
103
|
+
consecutive?: boolean;
|
|
55
104
|
}
|
|
56
105
|
export interface SearchMatch {
|
|
106
|
+
/** 0-based character index where the match starts. */
|
|
57
107
|
charIndex: number;
|
|
108
|
+
/** Number of characters in the match. */
|
|
58
109
|
length: number;
|
|
110
|
+
/** The actual matched text from the page. */
|
|
111
|
+
matchedText?: string;
|
|
112
|
+
/** Bounding rectangles covering the matched text. */
|
|
59
113
|
rects: SearchRect[];
|
|
60
114
|
}
|
|
61
115
|
export interface SearchRect {
|
|
116
|
+
/** Left edge in page points. */
|
|
62
117
|
left: number;
|
|
118
|
+
/** Top edge in page points. */
|
|
63
119
|
top: number;
|
|
120
|
+
/** Right edge in page points. */
|
|
64
121
|
right: number;
|
|
122
|
+
/** Bottom edge in page points. */
|
|
65
123
|
bottom: number;
|
|
66
124
|
}
|
|
67
|
-
export type AnnotationType = 'text' | 'link' | 'freetext' | 'line' | 'square' | 'circle' | 'highlight' | 'underline' | 'squiggly' | 'strikeout' | 'stamp' | 'ink' | 'popup' | 'widget' | 'redact' | 'unknown';
|
|
125
|
+
export type AnnotationType = 'text' | 'link' | 'freetext' | 'line' | 'square' | 'circle' | 'polygon' | 'polyline' | 'highlight' | 'underline' | 'squiggly' | 'strikeout' | 'stamp' | 'caret' | 'ink' | 'popup' | 'fileattachment' | 'sound' | 'widget' | 'redact' | 'watermark' | 'unknown';
|
|
126
|
+
export interface AnnotationBorder {
|
|
127
|
+
/** Horizontal corner radius. */
|
|
128
|
+
horizontalRadius: number;
|
|
129
|
+
/** Vertical corner radius. */
|
|
130
|
+
verticalRadius: number;
|
|
131
|
+
/** Border width in points. */
|
|
132
|
+
width: number;
|
|
133
|
+
}
|
|
134
|
+
export interface QuadPoints {
|
|
135
|
+
/** Top-left X. */
|
|
136
|
+
x1: number;
|
|
137
|
+
/** Top-left Y. */
|
|
138
|
+
y1: number;
|
|
139
|
+
/** Top-right X. */
|
|
140
|
+
x2: number;
|
|
141
|
+
/** Top-right Y. */
|
|
142
|
+
y2: number;
|
|
143
|
+
/** Bottom-left X. */
|
|
144
|
+
x3: number;
|
|
145
|
+
/** Bottom-left Y. */
|
|
146
|
+
y3: number;
|
|
147
|
+
/** Bottom-right X. */
|
|
148
|
+
x4: number;
|
|
149
|
+
/** Bottom-right Y. */
|
|
150
|
+
y4: number;
|
|
151
|
+
}
|
|
68
152
|
export interface Annotation {
|
|
153
|
+
/** Annotation subtype (e.g. 'highlight', 'text', 'link'). */
|
|
69
154
|
type: AnnotationType;
|
|
155
|
+
/** Bounding box in page coordinates, if available. */
|
|
70
156
|
bounds?: PageObjectBounds;
|
|
157
|
+
/** Text contents of the annotation. */
|
|
71
158
|
contents: string;
|
|
159
|
+
/** Annotation color, or null if none. */
|
|
72
160
|
color: RGBA | null;
|
|
161
|
+
/** Interior (fill) color for markup annotations. */
|
|
162
|
+
interiorColor?: RGBA;
|
|
163
|
+
/** Author of the annotation. */
|
|
164
|
+
author: string;
|
|
165
|
+
/** Subject of the annotation. */
|
|
166
|
+
subject: string;
|
|
167
|
+
/** Creation date as a PDF date string (e.g. "D:20250328..."). */
|
|
168
|
+
creationDate: string;
|
|
169
|
+
/** Modification date as a PDF date string. */
|
|
170
|
+
modDate: string;
|
|
171
|
+
/** Raw annotation flags bitmask (see PDF spec Table 165). */
|
|
172
|
+
flags: number;
|
|
173
|
+
/** Border style of the annotation. */
|
|
174
|
+
border?: AnnotationBorder;
|
|
175
|
+
/** Quad points for text markup annotations (highlight, underline, etc.). */
|
|
176
|
+
quadPoints?: QuadPoints[];
|
|
177
|
+
}
|
|
178
|
+
export type LinkActionType = 'goto' | 'remoteGoto' | 'uri' | 'launch' | 'embeddedGoto' | 'unknown';
|
|
179
|
+
export type FormFieldType = 'pushButton' | 'checkbox' | 'radioButton' | 'comboBox' | 'listBox' | 'textField' | 'signature' | 'unknown';
|
|
180
|
+
export interface FormFieldOption {
|
|
181
|
+
/** Display label for this option. */
|
|
182
|
+
label: string;
|
|
183
|
+
/** Whether this option is currently selected. */
|
|
184
|
+
isSelected: boolean;
|
|
185
|
+
}
|
|
186
|
+
export interface FormField {
|
|
187
|
+
/** Form field type. */
|
|
188
|
+
type: FormFieldType;
|
|
189
|
+
/** Fully qualified field name. */
|
|
190
|
+
name: string;
|
|
191
|
+
/** Current field value. */
|
|
192
|
+
value: string;
|
|
193
|
+
/** Alternate (tooltip) name, if set. */
|
|
194
|
+
alternateName?: string;
|
|
195
|
+
/** Export value for checkboxes and radio buttons. */
|
|
196
|
+
exportValue?: string;
|
|
197
|
+
/** Raw form field flags bitmask. */
|
|
198
|
+
flags: number;
|
|
199
|
+
/** Bounding box in page coordinates, if available. */
|
|
200
|
+
bounds?: PageObjectBounds;
|
|
201
|
+
/** Whether the field is checked (checkbox/radio only). */
|
|
202
|
+
isChecked: boolean;
|
|
203
|
+
/** Available options for combo box and list box fields. */
|
|
204
|
+
options?: FormFieldOption[];
|
|
73
205
|
}
|
|
74
206
|
export interface Link {
|
|
207
|
+
/** Bounding box in page coordinates, if available. */
|
|
75
208
|
bounds?: PageObjectBounds;
|
|
209
|
+
/** External URL target, if this is a URI link. */
|
|
76
210
|
url?: string;
|
|
211
|
+
/** Target page index for internal (goto) links. */
|
|
77
212
|
pageIndex?: number;
|
|
213
|
+
/** The type of action this link performs. */
|
|
214
|
+
actionType?: LinkActionType;
|
|
215
|
+
/** Destination X coordinate (for internal links). */
|
|
216
|
+
destX?: number;
|
|
217
|
+
/** Destination Y coordinate (for internal links). */
|
|
218
|
+
destY?: number;
|
|
219
|
+
/** Destination zoom level (for internal links). */
|
|
220
|
+
destZoom?: number;
|
|
221
|
+
/** File path for remote goto or launch actions. */
|
|
222
|
+
filePath?: string;
|
|
78
223
|
}
|
|
79
224
|
export interface Bookmark {
|
|
225
|
+
/** Display title of the bookmark. */
|
|
80
226
|
title: string;
|
|
227
|
+
/** Target page index, if the bookmark points to a page. */
|
|
81
228
|
pageIndex?: number;
|
|
229
|
+
/** Whether this bookmark node is initially open (expanded) in the viewer. */
|
|
230
|
+
open: boolean;
|
|
231
|
+
/** The type of action this bookmark performs. */
|
|
232
|
+
actionType?: LinkActionType;
|
|
233
|
+
/** External URL target for URI bookmarks. */
|
|
234
|
+
url?: string;
|
|
235
|
+
/** Destination X coordinate. */
|
|
236
|
+
destX?: number;
|
|
237
|
+
/** Destination Y coordinate. */
|
|
238
|
+
destY?: number;
|
|
239
|
+
/** Destination zoom level. */
|
|
240
|
+
destZoom?: number;
|
|
241
|
+
/** Child bookmarks forming a tree. */
|
|
82
242
|
children?: Bookmark[];
|
|
83
243
|
}
|
|
244
|
+
export interface DocumentPermissions {
|
|
245
|
+
/** Printing the document. */
|
|
246
|
+
print: boolean;
|
|
247
|
+
/** Modifying document contents. */
|
|
248
|
+
modify: boolean;
|
|
249
|
+
/** Copying or extracting text and graphics. */
|
|
250
|
+
copy: boolean;
|
|
251
|
+
/** Adding or modifying annotations. */
|
|
252
|
+
annotate: boolean;
|
|
253
|
+
/** Filling in form fields. */
|
|
254
|
+
fillForms: boolean;
|
|
255
|
+
/** Extracting text and graphics for accessibility. */
|
|
256
|
+
extractForAccessibility: boolean;
|
|
257
|
+
/** Assembling the document (insert, rotate, delete pages). */
|
|
258
|
+
assemble: boolean;
|
|
259
|
+
/** High-resolution printing. */
|
|
260
|
+
printHighQuality: boolean;
|
|
261
|
+
}
|
|
84
262
|
export interface DocumentMetadata {
|
|
263
|
+
/** Document title. */
|
|
85
264
|
title: string;
|
|
265
|
+
/** Document author. */
|
|
86
266
|
author: string;
|
|
267
|
+
/** Document subject. */
|
|
87
268
|
subject: string;
|
|
269
|
+
/** Document keywords. */
|
|
88
270
|
keywords: string;
|
|
271
|
+
/** Application that created the original document. */
|
|
89
272
|
creator: string;
|
|
273
|
+
/** Application that produced the PDF. */
|
|
90
274
|
producer: string;
|
|
275
|
+
/** Creation date as a PDF date string. */
|
|
91
276
|
creationDate: string;
|
|
277
|
+
/** Last modification date as a PDF date string. */
|
|
92
278
|
modDate: string;
|
|
279
|
+
/** PDF version as an integer (e.g. 17 for PDF 1.7). */
|
|
93
280
|
pdfVersion: number;
|
|
281
|
+
/** Document permission flags. All true if unprotected. */
|
|
282
|
+
permissions: DocumentPermissions;
|
|
283
|
+
/** Whether the PDF is a tagged PDF (structured content). */
|
|
284
|
+
isTagged: boolean;
|
|
285
|
+
/** Document language (e.g. 'en-US'). Empty string if not set. */
|
|
286
|
+
language: string;
|
|
287
|
+
/** Number of digital signatures in the document. */
|
|
288
|
+
signatureCount: number;
|
|
289
|
+
/** Number of file attachments in the document. */
|
|
290
|
+
attachmentCount: number;
|
|
291
|
+
/** Permanent file identifier (hex string). */
|
|
292
|
+
permanentId?: string;
|
|
293
|
+
/** Changing file identifier (hex string, updated on each save). */
|
|
294
|
+
changingId?: string;
|
|
94
295
|
}
|
|
95
296
|
export interface NativePage {
|
|
96
297
|
readonly number: number;
|
|
97
298
|
readonly width: number;
|
|
98
299
|
readonly height: number;
|
|
99
|
-
readonly size: PageSize;
|
|
100
300
|
readonly objectCount: number;
|
|
301
|
+
readonly rotation: number;
|
|
302
|
+
readonly hasTransparency: boolean;
|
|
303
|
+
readonly label?: string;
|
|
304
|
+
readonly cropBox?: PageObjectBounds;
|
|
305
|
+
readonly trimBox?: PageObjectBounds;
|
|
101
306
|
getText(): Promise<string>;
|
|
102
307
|
render(options?: PageRenderOptions): Promise<Buffer | void>;
|
|
103
308
|
getObject(index: number): Promise<PageObject>;
|
|
104
309
|
getLinks(): Promise<Link[]>;
|
|
105
310
|
search(text: string, options?: SearchOptions): Promise<SearchMatch[]>;
|
|
106
311
|
getAnnotations(): Promise<Annotation[]>;
|
|
312
|
+
getFormFields(): Promise<FormField[]>;
|
|
107
313
|
close(): void;
|
|
108
314
|
}
|
|
109
315
|
export interface NativeDocument {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACxB,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,qEAAqE;IACrE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,IAAI;IACnB,2BAA2B;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,6BAA6B;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,4BAA4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,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACtE,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IACxC,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACtC,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5C,YAAY,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAClF"}
|
package/lib/index.ts
CHANGED
|
@@ -44,20 +44,27 @@ export {
|
|
|
44
44
|
export { PDFiumPage } from './page.js';
|
|
45
45
|
export type {
|
|
46
46
|
Annotation,
|
|
47
|
+
AnnotationBorder,
|
|
47
48
|
AnnotationType,
|
|
48
49
|
Bookmark,
|
|
49
50
|
DocumentMetadata,
|
|
51
|
+
DocumentPermissions,
|
|
52
|
+
FormField,
|
|
53
|
+
FormFieldOption,
|
|
54
|
+
FormFieldType,
|
|
55
|
+
ImageColorspace,
|
|
50
56
|
ImagePageObject,
|
|
51
57
|
Link,
|
|
58
|
+
LinkActionType,
|
|
52
59
|
OtherPageObject,
|
|
53
60
|
PageObject,
|
|
54
61
|
PageObjectBounds,
|
|
55
|
-
PageObjectType,
|
|
56
62
|
PageRenderOptions,
|
|
57
|
-
|
|
63
|
+
QuadPoints,
|
|
58
64
|
RGBA,
|
|
59
65
|
SearchMatch,
|
|
60
66
|
SearchOptions,
|
|
61
67
|
SearchRect,
|
|
62
68
|
TextPageObject,
|
|
69
|
+
TextRenderMode,
|
|
63
70
|
} from './types.js';
|
package/lib/page.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
Annotation,
|
|
3
|
+
FormField,
|
|
3
4
|
Link,
|
|
4
5
|
NativePage,
|
|
5
6
|
PageObject,
|
|
7
|
+
PageObjectBounds,
|
|
6
8
|
PageRenderOptions,
|
|
7
|
-
PageSize,
|
|
8
9
|
SearchMatch,
|
|
9
10
|
SearchOptions,
|
|
10
11
|
} from './types.js';
|
|
@@ -17,20 +18,32 @@ export class PDFiumPage {
|
|
|
17
18
|
readonly width: number;
|
|
18
19
|
/** Page height in points (1 pt = 1/72 inch). */
|
|
19
20
|
readonly height: number;
|
|
20
|
-
/** Page dimensions in points. */
|
|
21
|
-
readonly size: PageSize;
|
|
22
21
|
/** 0-based page index. */
|
|
23
22
|
readonly number: number;
|
|
24
23
|
/** Number of page objects (text spans, paths, images, etc.). */
|
|
25
24
|
readonly objectCount: number;
|
|
25
|
+
/** Page rotation: 0 = none, 1 = 90° CW, 2 = 180°, 3 = 270° CW. */
|
|
26
|
+
readonly rotation: number;
|
|
27
|
+
/** Whether the page has transparency. */
|
|
28
|
+
readonly hasTransparency: boolean;
|
|
29
|
+
/** Page label (e.g. 'i', 'ii', '1', '2'). Only set if the document defines page labels. */
|
|
30
|
+
readonly label?: string;
|
|
31
|
+
/** Crop box (visible region), if explicitly set. */
|
|
32
|
+
readonly cropBox?: PageObjectBounds;
|
|
33
|
+
/** Trim box (intended finished page size), if explicitly set. */
|
|
34
|
+
readonly trimBox?: PageObjectBounds;
|
|
26
35
|
|
|
27
36
|
/** @internal */
|
|
28
37
|
constructor(private native: NativePage) {
|
|
29
38
|
this.width = native.width;
|
|
30
39
|
this.height = native.height;
|
|
31
|
-
this.size = native.size;
|
|
32
40
|
this.number = native.number;
|
|
33
41
|
this.objectCount = native.objectCount;
|
|
42
|
+
this.rotation = native.rotation;
|
|
43
|
+
this.hasTransparency = native.hasTransparency;
|
|
44
|
+
if (native.label !== undefined) this.label = native.label;
|
|
45
|
+
if (native.cropBox !== undefined) this.cropBox = native.cropBox;
|
|
46
|
+
if (native.trimBox !== undefined) this.trimBox = native.trimBox;
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
/** Extracts all text from the page. */
|
|
@@ -77,4 +90,9 @@ export class PDFiumPage {
|
|
|
77
90
|
getAnnotations(): Promise<Annotation[]> {
|
|
78
91
|
return this.native.getAnnotations();
|
|
79
92
|
}
|
|
93
|
+
|
|
94
|
+
/** Returns all form fields on the page. */
|
|
95
|
+
getFormFields(): Promise<FormField[]> {
|
|
96
|
+
return this.native.getFormFields();
|
|
97
|
+
}
|
|
80
98
|
}
|