@llamaindex/liteparse 2.13.1 → 2.14.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/README.md +38 -0
- package/dist/cli.js +1236 -398
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +712 -0
- package/dist/lib.cjs.map +1 -0
- package/dist/lib.d.cts +911 -0
- package/dist/lib.d.ts +339 -38
- package/dist/lib.js +654 -323
- package/dist/lib.js.map +1 -1
- package/dist/pool-worker.js +253 -0
- package/dist/pool-worker.js.map +1 -0
- package/liteparse.linux-x64-gnu.node +0 -0
- package/package.json +22 -12
- package/dist/cli-json.d.ts +0 -154
- package/dist/cli-json.d.ts.map +0 -1
- package/dist/cli-json.js +0 -241
- package/dist/cli-json.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/lib.d.ts.map +0 -1
- package/dist/native.d.ts +0 -345
- package/dist/native.d.ts.map +0 -1
- package/dist/native.js +0 -71
- package/dist/native.js.map +0 -1
package/dist/lib.d.cts
ADDED
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
interface NativeWordBox {
|
|
2
|
+
text: string;
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
}
|
|
8
|
+
interface NativeTextItem {
|
|
9
|
+
text: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
fontName?: string;
|
|
15
|
+
fontSize?: number;
|
|
16
|
+
fontHeight?: number;
|
|
17
|
+
fontAscent?: number;
|
|
18
|
+
fontDescent?: number;
|
|
19
|
+
fontWeight?: number;
|
|
20
|
+
textWidth?: number;
|
|
21
|
+
fontIsBuggy?: boolean;
|
|
22
|
+
mcid?: number;
|
|
23
|
+
fillColor?: string;
|
|
24
|
+
strokeColor?: string;
|
|
25
|
+
charCodes?: number[];
|
|
26
|
+
trailingSpaceGenerated?: boolean;
|
|
27
|
+
confidence?: number;
|
|
28
|
+
rotation?: number;
|
|
29
|
+
words?: NativeWordBox[];
|
|
30
|
+
}
|
|
31
|
+
interface NativeRect {
|
|
32
|
+
x: number;
|
|
33
|
+
y: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
}
|
|
37
|
+
interface NativeParsedPage {
|
|
38
|
+
pageNum: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
contentBounds?: NativeRect;
|
|
42
|
+
text: string;
|
|
43
|
+
markdown: string;
|
|
44
|
+
textItems: NativeTextItem[];
|
|
45
|
+
complexity?: NativePageComplexityStats;
|
|
46
|
+
vectorGraphics?: NativeVectorGraphics;
|
|
47
|
+
annotations?: NativeDocumentAnnotation[];
|
|
48
|
+
formFields?: NativeFormField[];
|
|
49
|
+
structureTree?: NativeStructureTree;
|
|
50
|
+
blocks?: NativeLayoutBlock[];
|
|
51
|
+
}
|
|
52
|
+
interface NativeLayoutCell {
|
|
53
|
+
text: string;
|
|
54
|
+
bbox?: NativeRect;
|
|
55
|
+
}
|
|
56
|
+
interface NativeLayoutBlock {
|
|
57
|
+
kind: string;
|
|
58
|
+
text?: string;
|
|
59
|
+
level?: number;
|
|
60
|
+
bold?: boolean;
|
|
61
|
+
italic?: boolean;
|
|
62
|
+
ordered?: boolean;
|
|
63
|
+
marker?: string;
|
|
64
|
+
lines?: string[];
|
|
65
|
+
lang?: string;
|
|
66
|
+
header?: NativeLayoutCell[];
|
|
67
|
+
rows?: NativeLayoutCell[][];
|
|
68
|
+
id?: string;
|
|
69
|
+
format?: string;
|
|
70
|
+
bbox?: NativeRect;
|
|
71
|
+
}
|
|
72
|
+
interface NativeStructureAttribute {
|
|
73
|
+
name: string;
|
|
74
|
+
booleanValue?: boolean;
|
|
75
|
+
numberValue?: number;
|
|
76
|
+
stringValue?: string;
|
|
77
|
+
}
|
|
78
|
+
interface NativeStructureTree {
|
|
79
|
+
roots: NativeStructureTreeElement[];
|
|
80
|
+
}
|
|
81
|
+
interface NativeStructureTreeElement {
|
|
82
|
+
elementType: string;
|
|
83
|
+
id?: string;
|
|
84
|
+
actualText?: string;
|
|
85
|
+
altText?: string;
|
|
86
|
+
title?: string;
|
|
87
|
+
attributes: NativeStructureAttribute[];
|
|
88
|
+
markedContentIds: number[];
|
|
89
|
+
children: NativeStructureTreeElement[];
|
|
90
|
+
annotations: NativeDocumentAnnotation[];
|
|
91
|
+
}
|
|
92
|
+
interface NativeVectorGraphics {
|
|
93
|
+
shapes: Array<{
|
|
94
|
+
bbox: {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
};
|
|
100
|
+
stroke: boolean;
|
|
101
|
+
strokeColor?: string;
|
|
102
|
+
fill: boolean;
|
|
103
|
+
fillColor?: string;
|
|
104
|
+
hasCurve: boolean;
|
|
105
|
+
}>;
|
|
106
|
+
lines: Array<{
|
|
107
|
+
x1: number;
|
|
108
|
+
y1: number;
|
|
109
|
+
x2: number;
|
|
110
|
+
y2: number;
|
|
111
|
+
stroke: boolean;
|
|
112
|
+
strokeWidth?: number;
|
|
113
|
+
strokeColor?: string;
|
|
114
|
+
fill: boolean;
|
|
115
|
+
fillColor?: string;
|
|
116
|
+
}>;
|
|
117
|
+
}
|
|
118
|
+
interface NativeAnnotationRect {
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
width: number;
|
|
122
|
+
height: number;
|
|
123
|
+
}
|
|
124
|
+
interface NativeDocumentAnnotation {
|
|
125
|
+
subtype: string;
|
|
126
|
+
contents?: string;
|
|
127
|
+
created?: string;
|
|
128
|
+
modified?: string;
|
|
129
|
+
title?: string;
|
|
130
|
+
rect?: NativeAnnotationRect;
|
|
131
|
+
quadpointRects: NativeAnnotationRect[];
|
|
132
|
+
uri?: string;
|
|
133
|
+
}
|
|
134
|
+
interface NativeFormField {
|
|
135
|
+
id: string;
|
|
136
|
+
fieldType: string;
|
|
137
|
+
page: number;
|
|
138
|
+
annotationIndex: number;
|
|
139
|
+
widgetIndex: number;
|
|
140
|
+
objectNumber?: number;
|
|
141
|
+
name?: string;
|
|
142
|
+
alternateName?: string;
|
|
143
|
+
value?: string;
|
|
144
|
+
exportValue?: string;
|
|
145
|
+
fieldFlags: number;
|
|
146
|
+
controlCount?: number;
|
|
147
|
+
controlIndex?: number;
|
|
148
|
+
checked?: boolean;
|
|
149
|
+
rect?: NativeAnnotationRect;
|
|
150
|
+
options: string[];
|
|
151
|
+
selectedOptions: string[];
|
|
152
|
+
}
|
|
153
|
+
interface NativeExtractedImage {
|
|
154
|
+
id: string;
|
|
155
|
+
name: string;
|
|
156
|
+
path?: string;
|
|
157
|
+
page: number;
|
|
158
|
+
bbox: {
|
|
159
|
+
x: number;
|
|
160
|
+
y: number;
|
|
161
|
+
width: number;
|
|
162
|
+
height: number;
|
|
163
|
+
};
|
|
164
|
+
width: number;
|
|
165
|
+
height: number;
|
|
166
|
+
rotation: number;
|
|
167
|
+
format: string;
|
|
168
|
+
duplicateOf?: string;
|
|
169
|
+
bytes: Buffer;
|
|
170
|
+
}
|
|
171
|
+
interface NativeParseResult {
|
|
172
|
+
totalPages: number;
|
|
173
|
+
pages: NativeParsedPage[];
|
|
174
|
+
pageErrors: Array<{
|
|
175
|
+
pageNum: number;
|
|
176
|
+
message: string;
|
|
177
|
+
}>;
|
|
178
|
+
text: string;
|
|
179
|
+
images: NativeExtractedImage[];
|
|
180
|
+
screenshots: NativeScreenshotResult[];
|
|
181
|
+
imageErrorCount: number;
|
|
182
|
+
formType?: number;
|
|
183
|
+
creator?: string;
|
|
184
|
+
producer?: string;
|
|
185
|
+
docMeta?: NativeDocumentMetadata;
|
|
186
|
+
xfaPackets?: NativeXfaPacket[];
|
|
187
|
+
}
|
|
188
|
+
interface NativeDocumentMetadata {
|
|
189
|
+
creationDate?: string;
|
|
190
|
+
modDate?: string;
|
|
191
|
+
fileVersion?: number;
|
|
192
|
+
isEncrypted?: boolean;
|
|
193
|
+
securityHandlerRevision?: number;
|
|
194
|
+
permissions?: number;
|
|
195
|
+
eofSectionCount?: number;
|
|
196
|
+
startxrefCount?: number;
|
|
197
|
+
trailerIdPairDiffers?: boolean;
|
|
198
|
+
rawFileSize?: number;
|
|
199
|
+
xmp?: string;
|
|
200
|
+
xmpTruncated?: boolean;
|
|
201
|
+
signatureCount?: number;
|
|
202
|
+
signatureByteRangeReachesEof?: boolean;
|
|
203
|
+
}
|
|
204
|
+
interface NativeXfaPacket {
|
|
205
|
+
index: number;
|
|
206
|
+
name?: string;
|
|
207
|
+
contentLength: number;
|
|
208
|
+
content?: string;
|
|
209
|
+
}
|
|
210
|
+
interface NativeScreenshotResult {
|
|
211
|
+
pageNum: number;
|
|
212
|
+
width: number;
|
|
213
|
+
height: number;
|
|
214
|
+
imageBuffer: Buffer;
|
|
215
|
+
isSolidFill: boolean;
|
|
216
|
+
rects: NativeScreenshotRect[];
|
|
217
|
+
}
|
|
218
|
+
interface NativeScreenshotRect {
|
|
219
|
+
x: number;
|
|
220
|
+
y: number;
|
|
221
|
+
width: number;
|
|
222
|
+
height: number;
|
|
223
|
+
color: string;
|
|
224
|
+
isLine: boolean;
|
|
225
|
+
}
|
|
226
|
+
interface NativeLayoutComplexityStats {
|
|
227
|
+
columnCount: number;
|
|
228
|
+
ruledTableCount: number;
|
|
229
|
+
ruledTableCoverage: number;
|
|
230
|
+
textTableRunCount: number;
|
|
231
|
+
figureCount: number;
|
|
232
|
+
figureCoverage: number;
|
|
233
|
+
isComplex: boolean;
|
|
234
|
+
reasons: string[];
|
|
235
|
+
}
|
|
236
|
+
interface NativePageComplexityStats {
|
|
237
|
+
pageNumber: number;
|
|
238
|
+
textLength: number;
|
|
239
|
+
textCoverage: number;
|
|
240
|
+
hasSubstantialImages: boolean;
|
|
241
|
+
imageBlockCount: number;
|
|
242
|
+
imageCoverage: number;
|
|
243
|
+
largestImageCoverage: number;
|
|
244
|
+
fullPageImage: boolean;
|
|
245
|
+
uncoveredVectorArea?: number;
|
|
246
|
+
isGarbled: boolean;
|
|
247
|
+
pageArea: number;
|
|
248
|
+
needsOcr: boolean;
|
|
249
|
+
reasons: string[];
|
|
250
|
+
layout?: NativeLayoutComplexityStats;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** A pooled parse exceeded `parseTimeoutMs` and its worker was killed.
|
|
254
|
+
*
|
|
255
|
+
* Only thrown in pool mode, where the deadline is enforced by killing the
|
|
256
|
+
* worker process — the timed-out parse is guaranteed dead, not still running
|
|
257
|
+
* in the background. `source` names the document (file path, or `<N bytes>`
|
|
258
|
+
* for byte inputs); log it to identify the documents that stall your
|
|
259
|
+
* pipeline.
|
|
260
|
+
*/
|
|
261
|
+
declare class ParseTimeoutError extends Error {
|
|
262
|
+
readonly source: string;
|
|
263
|
+
readonly timeoutMs: number;
|
|
264
|
+
constructor(message: string, source: string, timeoutMs: number);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
type LiteParseInput = string | Buffer | Uint8Array;
|
|
268
|
+
type OutputFormat = "json" | "text" | "markdown";
|
|
269
|
+
type ImageMode = "off" | "placeholder" | "embed";
|
|
270
|
+
/** Options for pool mode: parsing in persistent, killable worker processes. */
|
|
271
|
+
interface PoolOptions {
|
|
272
|
+
/**
|
|
273
|
+
* Route `parse()` through a pool of this many persistent worker processes.
|
|
274
|
+
* Call `close()` when done (an idle pool never keeps the event loop alive,
|
|
275
|
+
* but explicit shutdown frees workers immediately).
|
|
276
|
+
*/
|
|
277
|
+
poolSize?: number;
|
|
278
|
+
/**
|
|
279
|
+
* Hard per-parse deadline in milliseconds. Requires `poolSize`.
|
|
280
|
+
* The pool enforces the deadline by SIGKILLing the worker. On expiry
|
|
281
|
+
* the parse rejects with {@link ParseTimeoutError} (naming the document)
|
|
282
|
+
* and a fresh worker replaces the killed one.
|
|
283
|
+
*/
|
|
284
|
+
parseTimeoutMs?: number;
|
|
285
|
+
}
|
|
286
|
+
interface LiteParseConfig {
|
|
287
|
+
ocrLanguage: string;
|
|
288
|
+
ocrEnabled: boolean;
|
|
289
|
+
ocrServerUrl?: string;
|
|
290
|
+
/** Extra HTTP headers sent with every request to `ocrServerUrl`. */
|
|
291
|
+
ocrServerHeaders?: Record<string, string>;
|
|
292
|
+
tessdataPath?: string;
|
|
293
|
+
maxPages: number;
|
|
294
|
+
targetPages?: string;
|
|
295
|
+
/** Render parsed pages to PNG and return them in `ParseResult.screenshots`. */
|
|
296
|
+
extractScreenshots: boolean;
|
|
297
|
+
/** Continue after page-level extraction failures and collect `pageErrors`. */
|
|
298
|
+
continueOnPageError: boolean;
|
|
299
|
+
dpi: number;
|
|
300
|
+
outputFormat: OutputFormat;
|
|
301
|
+
/** How to surface raster images in markdown output (default: "placeholder"). */
|
|
302
|
+
imageMode: ImageMode;
|
|
303
|
+
/** Extract embedded image bytes and metadata (default: false). */
|
|
304
|
+
extractImages: boolean;
|
|
305
|
+
/** Directory where extracted embedded image files are written. Requires `extractImages`. */
|
|
306
|
+
imageOutputDir?: string;
|
|
307
|
+
/** Render hyperlink annotations as `[text](url)` in markdown output (default: true). */
|
|
308
|
+
extractLinks: boolean;
|
|
309
|
+
/** Keep running headers/footers in markdown output instead of stripping repeated page-band lines and page chrome (default: false). */
|
|
310
|
+
keepHeadersFooters: boolean;
|
|
311
|
+
/** Extract all PDF annotations into each parsed page (default: false). */
|
|
312
|
+
extractAnnotations: boolean;
|
|
313
|
+
/** Extract AcroForm widget fields and values (default: false). */
|
|
314
|
+
extractFormFields: boolean;
|
|
315
|
+
/** Extract the tagged-PDF logical structure tree (default: false). */
|
|
316
|
+
extractStructureTree: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* Emit each page's classified layout blocks with bounding boxes
|
|
319
|
+
* (default: false). This is the same decomposition the Markdown renderer
|
|
320
|
+
* consumes, exposed as data; enabling it never changes the rendered Markdown.
|
|
321
|
+
*/
|
|
322
|
+
extractBlocks: boolean;
|
|
323
|
+
/** Extract raw XFA packets (name + XML content) into `ParseResult.xfaPackets` (default: false). */
|
|
324
|
+
extractXfaPackets: boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Collect document provenance metadata into `result.docMeta`. Default
|
|
327
|
+
* false: Absent for inputs converted from a non-PDF format.
|
|
328
|
+
*/
|
|
329
|
+
extractDocumentMetadata: boolean;
|
|
330
|
+
/** Emit each page's `contentBounds` (union bbox of top-level content objects) (default: false). */
|
|
331
|
+
extractContentBounds: boolean;
|
|
332
|
+
/** Detect solid rectangles/lines in rendered page screenshots (default: false). */
|
|
333
|
+
detectScreenshotRects: boolean;
|
|
334
|
+
/** Draw AcroForm field appearances into rendered rasters (screenshots and OCR inputs; runs document open/JS actions; default: false). */
|
|
335
|
+
renderFormFields: boolean;
|
|
336
|
+
preserveVerySmallText: boolean;
|
|
337
|
+
password?: string;
|
|
338
|
+
quiet: boolean;
|
|
339
|
+
numWorkers: number;
|
|
340
|
+
/**
|
|
341
|
+
* Whether a systemic OCR failure (every OCR task failed and at least one was
|
|
342
|
+
* a text-sparse page) aborts the whole parse (default: true). Set false to
|
|
343
|
+
* keep already-recovered native text and return partial results instead of
|
|
344
|
+
* rejecting — for callers that prefer a degraded document over a hard failure.
|
|
345
|
+
*/
|
|
346
|
+
ocrFailureFatal: boolean;
|
|
347
|
+
/**
|
|
348
|
+
* OCR request-hedging schedule (ms). Empty (default) = no hedging. Multiple
|
|
349
|
+
* delays (e.g. `[0, 5000, 10000, 15000, 20000]`) fire duplicate requests per
|
|
350
|
+
* OCR attempt and take the first success — lower tail latency on a slow/stuck
|
|
351
|
+
* OCR pod, at the cost of extra OCR-server load. HTTP OCR engine only.
|
|
352
|
+
*/
|
|
353
|
+
ocrHedgeDelaysMs: number[];
|
|
354
|
+
/**
|
|
355
|
+
* Emit per-word sub-boxes on each text item ({@link TextItem.words}).
|
|
356
|
+
* Default false. Word boxes roughly double the text-item payload (size + napi
|
|
357
|
+
* marshalling), so enable only when doing word-level bbox attribution.
|
|
358
|
+
*/
|
|
359
|
+
emitWordBoxes: boolean;
|
|
360
|
+
/** Include rich PDF text metadata on returned text items. Default false. */
|
|
361
|
+
extractTextMetadata?: boolean;
|
|
362
|
+
/**
|
|
363
|
+
* Restrict output to a page sub-region. Each field is the fraction of the
|
|
364
|
+
* page cropped away from that side (top-left origin), so `{ left: 0.5 }`
|
|
365
|
+
* discards the left half. A text item survives only when it lies entirely
|
|
366
|
+
* inside the remaining rectangle. Undefined (default) keeps the whole page.
|
|
367
|
+
* Applied after OCR merge, so OCR text outside the region is dropped too.
|
|
368
|
+
*/
|
|
369
|
+
cropBox?: CropBox;
|
|
370
|
+
/**
|
|
371
|
+
* Drop diagonal text — items whose rotation is more than 2° off the nearest
|
|
372
|
+
* right angle (0/90/180/270). Default false. Use to exclude rotated
|
|
373
|
+
* watermarks/stamps from the output.
|
|
374
|
+
*/
|
|
375
|
+
skipDiagonalText: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Compute per-page complexity signals during {@link LiteParse.parse} and
|
|
378
|
+
* attach them to each page as {@link ParsedPage.complexity} (the same signals
|
|
379
|
+
* {@link LiteParse.isComplex} returns). Default false; enabling it runs an
|
|
380
|
+
* extra vector-text detection pass.
|
|
381
|
+
*/
|
|
382
|
+
includeComplexity: boolean;
|
|
383
|
+
/** Expose page-scoped vector shapes and merged H/V line segments. Default false. */
|
|
384
|
+
extractVectorGraphics: boolean;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* A page sub-region expressed as the fraction cropped from each side
|
|
388
|
+
* (top-left origin, each value in `[0, 1]`).
|
|
389
|
+
*/
|
|
390
|
+
interface CropBox {
|
|
391
|
+
top: number;
|
|
392
|
+
right: number;
|
|
393
|
+
bottom: number;
|
|
394
|
+
left: number;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* One word's bounding box within a {@link TextItem}, in the same viewport space
|
|
398
|
+
* (top-left origin, 72 DPI). `text` excludes inter-word spaces.
|
|
399
|
+
*/
|
|
400
|
+
interface WordBox {
|
|
401
|
+
text: string;
|
|
402
|
+
x: number;
|
|
403
|
+
y: number;
|
|
404
|
+
width: number;
|
|
405
|
+
height: number;
|
|
406
|
+
}
|
|
407
|
+
interface TextItem {
|
|
408
|
+
text: string;
|
|
409
|
+
x: number;
|
|
410
|
+
y: number;
|
|
411
|
+
width: number;
|
|
412
|
+
height: number;
|
|
413
|
+
fontName?: string;
|
|
414
|
+
fontSize?: number;
|
|
415
|
+
/** Font size after applying the text matrix's vertical scale. */
|
|
416
|
+
fontHeight?: number;
|
|
417
|
+
fontAscent?: number;
|
|
418
|
+
fontDescent?: number;
|
|
419
|
+
fontWeight?: number;
|
|
420
|
+
/** Sum of source glyph widths in points. */
|
|
421
|
+
textWidth?: number;
|
|
422
|
+
fontIsBuggy?: boolean;
|
|
423
|
+
/** Marked-content ID from the PDF structure tree. */
|
|
424
|
+
mcid?: number;
|
|
425
|
+
/** Fill color as an eight-character ARGB hex string. */
|
|
426
|
+
fillColor?: string;
|
|
427
|
+
/** Stroke color as an eight-character ARGB hex string. */
|
|
428
|
+
strokeColor?: string;
|
|
429
|
+
/** Raw PDF content-stream character codes for the source glyphs. */
|
|
430
|
+
charCodes?: number[];
|
|
431
|
+
/** True when the trailing source space was synthesized by PDFium. */
|
|
432
|
+
trailingSpaceGenerated?: boolean;
|
|
433
|
+
/** OCR confidence score (0.0-1.0). Undefined for native PDF text. */
|
|
434
|
+
confidence?: number;
|
|
435
|
+
/** Rotation in degrees (viewport space). Defaults to 0 when omitted. */
|
|
436
|
+
rotation?: number;
|
|
437
|
+
/**
|
|
438
|
+
* Per-word sub-boxes within this item. A text item groups several words
|
|
439
|
+
* together (breaking only at line/column boundaries), so this carries the
|
|
440
|
+
* finer word-level geometry for bbox attribution. Empty/undefined for items
|
|
441
|
+
* with no word split (e.g. OCR-sourced or single-token items).
|
|
442
|
+
*/
|
|
443
|
+
words?: WordBox[];
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* A vector-graphic primitive supplied to {@link LiteParse.parsePages}. `kind`
|
|
447
|
+
* selects the variant: `"stroke"` (uses `x1/y1/x2/y2`) or `"rect"` (uses
|
|
448
|
+
* `x/y/width/height`, top-left origin). Coordinates are viewport space (72 DPI),
|
|
449
|
+
* matching the text items. `hasFill`/`hasStroke` carry the paint intent even
|
|
450
|
+
* when the color is unknown, so ruled-table edge detection still treats a
|
|
451
|
+
* colorless stroked rect as stroked.
|
|
452
|
+
*/
|
|
453
|
+
interface Graphic {
|
|
454
|
+
kind: "stroke" | "rect";
|
|
455
|
+
x1?: number;
|
|
456
|
+
y1?: number;
|
|
457
|
+
x2?: number;
|
|
458
|
+
y2?: number;
|
|
459
|
+
x?: number;
|
|
460
|
+
y?: number;
|
|
461
|
+
width?: number;
|
|
462
|
+
height?: number;
|
|
463
|
+
hasFill?: boolean;
|
|
464
|
+
hasStroke?: boolean;
|
|
465
|
+
fillColor?: string;
|
|
466
|
+
strokeColor?: string;
|
|
467
|
+
lineWidth?: number;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* A page of pre-extracted text supplied to {@link LiteParse.parsePages}.
|
|
471
|
+
* Coordinates are viewport space (top-left origin, 72 DPI). `graphics` is
|
|
472
|
+
* optional; when supplied it enables ruled-table and horizontal-rule detection.
|
|
473
|
+
*/
|
|
474
|
+
interface PageInput {
|
|
475
|
+
pageNumber: number;
|
|
476
|
+
pageWidth: number;
|
|
477
|
+
pageHeight: number;
|
|
478
|
+
textItems: TextItem[];
|
|
479
|
+
graphics?: Graphic[];
|
|
480
|
+
}
|
|
481
|
+
interface Rect {
|
|
482
|
+
x: number;
|
|
483
|
+
y: number;
|
|
484
|
+
width: number;
|
|
485
|
+
height: number;
|
|
486
|
+
}
|
|
487
|
+
interface ParsedPage {
|
|
488
|
+
pageNum: number;
|
|
489
|
+
width: number;
|
|
490
|
+
height: number;
|
|
491
|
+
/**
|
|
492
|
+
* Union bbox of the page's top-level content objects in viewport coords
|
|
493
|
+
* (visible content extent). Absent for empty pages.
|
|
494
|
+
*/
|
|
495
|
+
/** Present only when `extractContentBounds` is enabled. */
|
|
496
|
+
contentBounds?: Rect;
|
|
497
|
+
text: string;
|
|
498
|
+
markdown: string;
|
|
499
|
+
textItems: TextItem[];
|
|
500
|
+
/**
|
|
501
|
+
* Per-page complexity signals (the same {@link LiteParse.isComplex} returns).
|
|
502
|
+
* Present only when parsing with `includeComplexity: true`; `undefined`
|
|
503
|
+
* otherwise.
|
|
504
|
+
*/
|
|
505
|
+
complexity?: PageComplexityStats;
|
|
506
|
+
/** Present only when parsing with `extractVectorGraphics: true`. */
|
|
507
|
+
vectorGraphics?: VectorGraphics;
|
|
508
|
+
/** Present only when `extractAnnotations` is enabled. */
|
|
509
|
+
annotations?: DocumentAnnotation[];
|
|
510
|
+
/** Present only when `extractFormFields` is enabled. */
|
|
511
|
+
formFields?: FormField[];
|
|
512
|
+
/** Present only when `extractStructureTree` is enabled. */
|
|
513
|
+
structureTree?: StructureTree;
|
|
514
|
+
/**
|
|
515
|
+
* Classified layout blocks in reading order — the same blocks, in the same
|
|
516
|
+
* order, the page's Markdown is built from. Present only when
|
|
517
|
+
* `extractBlocks` is enabled.
|
|
518
|
+
*/
|
|
519
|
+
blocks?: LayoutBlock[];
|
|
520
|
+
}
|
|
521
|
+
/** One table cell: its text and the region of the page it was read from. */
|
|
522
|
+
interface LayoutCell {
|
|
523
|
+
text: string;
|
|
524
|
+
/**
|
|
525
|
+
* Absent for cells with no ink behind them — padding inserted to square off
|
|
526
|
+
* a ragged grid, or halves of a merged run split at an estimated position.
|
|
527
|
+
*/
|
|
528
|
+
bbox?: Rect;
|
|
529
|
+
}
|
|
530
|
+
/** A classified block of page content, discriminated by `kind`. */
|
|
531
|
+
interface LayoutBlock {
|
|
532
|
+
kind: "heading" | "paragraph" | "list_item" | "code" | "table" | "grid_fallback" | "rule" | "figure";
|
|
533
|
+
/** Rendered text for `heading`, `paragraph`, and `list_item`. */
|
|
534
|
+
text?: string;
|
|
535
|
+
/** Heading level (1-6), or list nesting depth for `list_item`. */
|
|
536
|
+
level?: number;
|
|
537
|
+
bold?: boolean;
|
|
538
|
+
italic?: boolean;
|
|
539
|
+
/** `list_item` only. `marker` is the marker as it appeared on the page. */
|
|
540
|
+
ordered?: boolean;
|
|
541
|
+
marker?: string;
|
|
542
|
+
/** Verbatim source lines for `code` and `grid_fallback`. */
|
|
543
|
+
lines?: string[];
|
|
544
|
+
/** Best-effort language hint for `code`. */
|
|
545
|
+
lang?: string;
|
|
546
|
+
/** `table` only. */
|
|
547
|
+
header?: LayoutCell[];
|
|
548
|
+
rows?: LayoutCell[][];
|
|
549
|
+
/** `figure` only, matching the `img_{id}.{format}` Markdown target. */
|
|
550
|
+
id?: string;
|
|
551
|
+
format?: string;
|
|
552
|
+
/**
|
|
553
|
+
* Region this block occupies, in the same top-left 72-DPI viewport space as
|
|
554
|
+
* `textItems`. The union of every source line that fed the block.
|
|
555
|
+
*/
|
|
556
|
+
bbox?: Rect;
|
|
557
|
+
}
|
|
558
|
+
type StructureAttributeValue = boolean | number | string;
|
|
559
|
+
interface StructureTree {
|
|
560
|
+
roots: StructureTreeElement[];
|
|
561
|
+
}
|
|
562
|
+
interface StructureTreeElement {
|
|
563
|
+
type: string;
|
|
564
|
+
id?: string;
|
|
565
|
+
actualText?: string;
|
|
566
|
+
altText?: string;
|
|
567
|
+
title?: string;
|
|
568
|
+
attributes: Record<string, StructureAttributeValue>;
|
|
569
|
+
markedContentIds: number[];
|
|
570
|
+
children: StructureTreeElement[];
|
|
571
|
+
annotations: DocumentAnnotation[];
|
|
572
|
+
}
|
|
573
|
+
interface VectorGraphics {
|
|
574
|
+
shapes: VectorShape[];
|
|
575
|
+
lines: VectorLine[];
|
|
576
|
+
}
|
|
577
|
+
interface VectorShape {
|
|
578
|
+
bbox: {
|
|
579
|
+
x: number;
|
|
580
|
+
y: number;
|
|
581
|
+
width: number;
|
|
582
|
+
height: number;
|
|
583
|
+
};
|
|
584
|
+
stroke: boolean;
|
|
585
|
+
strokeColor?: string;
|
|
586
|
+
fill: boolean;
|
|
587
|
+
fillColor?: string;
|
|
588
|
+
hasCurve: boolean;
|
|
589
|
+
}
|
|
590
|
+
interface VectorLine {
|
|
591
|
+
x1: number;
|
|
592
|
+
y1: number;
|
|
593
|
+
x2: number;
|
|
594
|
+
y2: number;
|
|
595
|
+
stroke: boolean;
|
|
596
|
+
strokeWidth?: number;
|
|
597
|
+
strokeColor?: string;
|
|
598
|
+
fill: boolean;
|
|
599
|
+
fillColor?: string;
|
|
600
|
+
}
|
|
601
|
+
interface AnnotationRect {
|
|
602
|
+
x: number;
|
|
603
|
+
y: number;
|
|
604
|
+
width: number;
|
|
605
|
+
height: number;
|
|
606
|
+
}
|
|
607
|
+
interface DocumentAnnotation {
|
|
608
|
+
subtype: string;
|
|
609
|
+
contents?: string;
|
|
610
|
+
created?: string;
|
|
611
|
+
modified?: string;
|
|
612
|
+
title?: string;
|
|
613
|
+
rect?: AnnotationRect;
|
|
614
|
+
quadpointRects: AnnotationRect[];
|
|
615
|
+
uri?: string;
|
|
616
|
+
}
|
|
617
|
+
interface FormField {
|
|
618
|
+
id: string;
|
|
619
|
+
type: string;
|
|
620
|
+
page: number;
|
|
621
|
+
annotationIndex: number;
|
|
622
|
+
widgetIndex: number;
|
|
623
|
+
objectNumber?: number;
|
|
624
|
+
name?: string;
|
|
625
|
+
alternateName?: string;
|
|
626
|
+
value?: string;
|
|
627
|
+
exportValue?: string;
|
|
628
|
+
fieldFlags: number;
|
|
629
|
+
controlCount?: number;
|
|
630
|
+
controlIndex?: number;
|
|
631
|
+
checked?: boolean;
|
|
632
|
+
rect?: AnnotationRect;
|
|
633
|
+
options: string[];
|
|
634
|
+
selectedOptions: string[];
|
|
635
|
+
}
|
|
636
|
+
interface ExtractedImage {
|
|
637
|
+
/** Reference id used in the markdown output (e.g. `` → `"p1_1"`). */
|
|
638
|
+
id: string;
|
|
639
|
+
/** File name used when `imageOutputDir` is configured. */
|
|
640
|
+
name: string;
|
|
641
|
+
/** Written file path, absent for in-memory-only extraction. */
|
|
642
|
+
path?: string;
|
|
643
|
+
page: number;
|
|
644
|
+
/** Placement on the page in viewport coordinates (top-left origin, 72 DPI). */
|
|
645
|
+
bbox: {
|
|
646
|
+
x: number;
|
|
647
|
+
y: number;
|
|
648
|
+
width: number;
|
|
649
|
+
height: number;
|
|
650
|
+
};
|
|
651
|
+
/** Intrinsic pixel dimensions of the image resource. */
|
|
652
|
+
width: number;
|
|
653
|
+
height: number;
|
|
654
|
+
/** Clockwise page-object rotation in degrees. */
|
|
655
|
+
rotation: number;
|
|
656
|
+
format: string;
|
|
657
|
+
/** First occurrence with identical encoded source data, when duplicated. */
|
|
658
|
+
duplicateOf?: string;
|
|
659
|
+
bytes: Buffer;
|
|
660
|
+
}
|
|
661
|
+
interface ParseResult {
|
|
662
|
+
/** Total source-document pages before `targetPages` or `maxPages` filtering. */
|
|
663
|
+
totalPages: number;
|
|
664
|
+
pages: ParsedPage[];
|
|
665
|
+
/** Page-level PDFium extraction failures when tolerance is enabled. */
|
|
666
|
+
pageErrors: Array<{
|
|
667
|
+
pageNum: number;
|
|
668
|
+
message: string;
|
|
669
|
+
}>;
|
|
670
|
+
text: string;
|
|
671
|
+
/** Populated only when `extractImages` is true. */
|
|
672
|
+
images: ExtractedImage[];
|
|
673
|
+
/** PNG screenshots of parsed pages when `extractScreenshots` is enabled. */
|
|
674
|
+
screenshots: ScreenshotResult[];
|
|
675
|
+
/** Embedded image objects that PDFium could not render or encode. */
|
|
676
|
+
imageErrorCount: number;
|
|
677
|
+
/** PDFium form type, present only when `extractFormFields` is enabled. */
|
|
678
|
+
formType?: number;
|
|
679
|
+
/** The document's `/Info` `Creator` entry, when present. */
|
|
680
|
+
creator?: string;
|
|
681
|
+
/** The document's `/Info` `Producer` entry, when present. */
|
|
682
|
+
producer?: string;
|
|
683
|
+
/**
|
|
684
|
+
* Document-level provenance metadata from PDFium and the source PDF.
|
|
685
|
+
* Present only when `extractDocumentMetadata` is enabled and the input was
|
|
686
|
+
* a real PDF (not converted from DOCX/XLSX/an image).
|
|
687
|
+
*/
|
|
688
|
+
docMeta?: DocumentMetadata;
|
|
689
|
+
/** Raw XFA packets; present only when `extractXfaPackets` is enabled. */
|
|
690
|
+
xfaPackets?: XfaPacket[];
|
|
691
|
+
}
|
|
692
|
+
interface ParseBatchOptions {
|
|
693
|
+
/** Pages materialized in one batch. Default: 25. */
|
|
694
|
+
batchSize?: number;
|
|
695
|
+
}
|
|
696
|
+
interface ParseBatch {
|
|
697
|
+
/** First source page in this batch (1-indexed). */
|
|
698
|
+
startPage: number;
|
|
699
|
+
/** Last source page in this batch (1-indexed, inclusive). */
|
|
700
|
+
endPage: number;
|
|
701
|
+
/** Total source-document pages, before the parser's `maxPages` cap. */
|
|
702
|
+
totalPages: number;
|
|
703
|
+
result: ParseResult;
|
|
704
|
+
}
|
|
705
|
+
/** Provenance and tamper-analysis facts extracted from the source PDF. */
|
|
706
|
+
interface DocumentMetadata {
|
|
707
|
+
creationDate?: string;
|
|
708
|
+
modDate?: string;
|
|
709
|
+
/** Encoded PDF version (`14` means PDF 1.4). */
|
|
710
|
+
fileVersion?: number;
|
|
711
|
+
isEncrypted?: boolean;
|
|
712
|
+
securityHandlerRevision?: number;
|
|
713
|
+
permissions?: number;
|
|
714
|
+
eofSectionCount?: number;
|
|
715
|
+
startxrefCount?: number;
|
|
716
|
+
trailerIdPairDiffers?: boolean;
|
|
717
|
+
rawFileSize?: number;
|
|
718
|
+
/**
|
|
719
|
+
* The document catalog's `/Metadata` XMP packet, capped at 64 KiB. Absent
|
|
720
|
+
* when the document has none, when it is too large to resolve cheaply, or
|
|
721
|
+
* in WASM builds.
|
|
722
|
+
*/
|
|
723
|
+
xmp?: string;
|
|
724
|
+
/** True when the catalog's XMP stream exceeded the 64 KiB cap. */
|
|
725
|
+
xmpTruncated?: boolean;
|
|
726
|
+
signatureCount?: number;
|
|
727
|
+
/** False when bytes were appended after a readable signature byte range. */
|
|
728
|
+
signatureByteRangeReachesEof?: boolean;
|
|
729
|
+
}
|
|
730
|
+
/** One raw packet from an XFA form document's `/XFA` array. */
|
|
731
|
+
interface XfaPacket {
|
|
732
|
+
index: number;
|
|
733
|
+
name?: string;
|
|
734
|
+
contentLength: number;
|
|
735
|
+
/** Packet content (usually XML), lossily decoded as UTF-8. */
|
|
736
|
+
content?: string;
|
|
737
|
+
}
|
|
738
|
+
interface ScreenshotResult {
|
|
739
|
+
pageNum: number;
|
|
740
|
+
width: number;
|
|
741
|
+
height: number;
|
|
742
|
+
imageBuffer: Buffer;
|
|
743
|
+
/** True when every pixel has the same color (blank page after render). */
|
|
744
|
+
isSolidFill: boolean;
|
|
745
|
+
/** Solid rectangles/lines detected in the raster (viewport coords). Populated only with `detectScreenshotRects`. */
|
|
746
|
+
rects: ScreenshotRect[];
|
|
747
|
+
}
|
|
748
|
+
/** One solid rectangle (or line) detected in a rendered page bitmap. */
|
|
749
|
+
interface ScreenshotRect {
|
|
750
|
+
x: number;
|
|
751
|
+
y: number;
|
|
752
|
+
width: number;
|
|
753
|
+
height: number;
|
|
754
|
+
/** Fill color as ARGB hex string (e.g. "ff1a2b3c"). */
|
|
755
|
+
color: string;
|
|
756
|
+
/** True when the region is a solid line rather than a filled area. */
|
|
757
|
+
isLine: boolean;
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* Per-page complexity signals from {@link LiteParse.isComplex}, used to decide
|
|
761
|
+
* whether a document needs OCR or other advanced parsing.
|
|
762
|
+
*/
|
|
763
|
+
interface PageComplexityStats {
|
|
764
|
+
pageNumber: number;
|
|
765
|
+
textLength: number;
|
|
766
|
+
/** Fraction of the page area covered by native text (0–1). */
|
|
767
|
+
textCoverage: number;
|
|
768
|
+
hasSubstantialImages: boolean;
|
|
769
|
+
/**
|
|
770
|
+
* Number of counted raster images — inline figures only; full-page
|
|
771
|
+
* backgrounds are excluded (see {@link fullPageImage}).
|
|
772
|
+
*/
|
|
773
|
+
imageBlockCount: number;
|
|
774
|
+
/**
|
|
775
|
+
* Summed image-bbox area over page area, clamped to 1. Counts inline figures
|
|
776
|
+
* only: a full-page scan raster contributes 0 here — check
|
|
777
|
+
* {@link fullPageImage} for that.
|
|
778
|
+
*/
|
|
779
|
+
imageCoverage: number;
|
|
780
|
+
/**
|
|
781
|
+
* Largest single *counted* image's area over page area, clamped to 1. Same
|
|
782
|
+
* exclusion as {@link imageCoverage}: a full-page raster contributes 0.
|
|
783
|
+
*/
|
|
784
|
+
largestImageCoverage: number;
|
|
785
|
+
/**
|
|
786
|
+
* A single raster covers ≥90% of the page. Full-page backgrounds are excluded
|
|
787
|
+
* from the image coverage fields, so this is the only signal that tells a scan
|
|
788
|
+
* apart from a blank page — both otherwise report no text and no images.
|
|
789
|
+
*/
|
|
790
|
+
fullPageImage: boolean;
|
|
791
|
+
/**
|
|
792
|
+
* Filled vector-outline area not covered by native text, in pt². `undefined`
|
|
793
|
+
* when a cheaper signal already decided the page, so this walk was skipped.
|
|
794
|
+
*/
|
|
795
|
+
uncoveredVectorArea?: number;
|
|
796
|
+
isGarbled: boolean;
|
|
797
|
+
pageArea: number;
|
|
798
|
+
/** Verdict: whether this page needs more than the cheap text-only path. */
|
|
799
|
+
needsOcr: boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Every reason the page was flagged (e.g. `"scanned"`, `"sparse-text"`,
|
|
802
|
+
* `"garbled"`). Empty exactly when `needsOcr` is false. This is the value to
|
|
803
|
+
* route on; new reasons may be added over time.
|
|
804
|
+
*/
|
|
805
|
+
reasons: string[];
|
|
806
|
+
/**
|
|
807
|
+
* Layout-difficulty signals (columns, tables, dense graphics). Orthogonal to
|
|
808
|
+
* `needsOcr`: none of these imply OCR — they signal that the text-only path
|
|
809
|
+
* may mangle reading order or structure. Present in `isComplex()` results
|
|
810
|
+
* and `includeComplexity` parses.
|
|
811
|
+
*/
|
|
812
|
+
layout?: LayoutComplexityStats;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Layout-difficulty signals for one page, computed from the real
|
|
816
|
+
* grid-projection pass.
|
|
817
|
+
*/
|
|
818
|
+
interface LayoutComplexityStats {
|
|
819
|
+
/** Side-by-side text columns found by the layout pass (1 = single column). */
|
|
820
|
+
columnCount: number;
|
|
821
|
+
/** Ruled-table grids detected on the page. */
|
|
822
|
+
ruledTableCount: number;
|
|
823
|
+
/** Combined ruled-table area over page area, clamped to 1. */
|
|
824
|
+
ruledTableCoverage: number;
|
|
825
|
+
/**
|
|
826
|
+
* Borderless table runs found by track-aligned text detection (description
|
|
827
|
+
* lists excluded). Ruled tables can appear here too — don't sum with
|
|
828
|
+
* `ruledTableCount`; the two discriminate ruled from borderless.
|
|
829
|
+
*/
|
|
830
|
+
textTableRunCount: number;
|
|
831
|
+
/** Figure regions clustered from vector graphics. */
|
|
832
|
+
figureCount: number;
|
|
833
|
+
/** Combined figure area over page area, clamped to 1. */
|
|
834
|
+
figureCoverage: number;
|
|
835
|
+
/** Verdict: whether any layout reason fired. */
|
|
836
|
+
isComplex: boolean;
|
|
837
|
+
/**
|
|
838
|
+
* Every layout reason (e.g. `"multi-column"`, `"table-likely"`,
|
|
839
|
+
* `"dense-graphics"`). Empty exactly when `isComplex` is false; new reasons
|
|
840
|
+
* may be added over time.
|
|
841
|
+
*/
|
|
842
|
+
reasons: string[];
|
|
843
|
+
}
|
|
844
|
+
declare class LiteParse {
|
|
845
|
+
private _native;
|
|
846
|
+
private _config;
|
|
847
|
+
private _pool;
|
|
848
|
+
constructor(userConfig?: Partial<LiteParseConfig> & PoolOptions);
|
|
849
|
+
parse(input: LiteParseInput): Promise<ParseResult>;
|
|
850
|
+
/**
|
|
851
|
+
* Resolves once every pool worker is initialized. No-op without `poolSize`.
|
|
852
|
+
*
|
|
853
|
+
* Optional: the first parse on each worker waits for its init anyway. Call
|
|
854
|
+
* this before latency-sensitive traffic to avoid paying worker startup on
|
|
855
|
+
* the first request.
|
|
856
|
+
*/
|
|
857
|
+
warmUp(): Promise<void>;
|
|
858
|
+
/**
|
|
859
|
+
* Shut down pool workers, if pool mode is enabled. Idempotent.
|
|
860
|
+
*
|
|
861
|
+
* Without `poolSize` this is a no-op. An idle pool never keeps the event
|
|
862
|
+
* loop alive and workers exit when the parent does, so forgetting to call
|
|
863
|
+
* this leaks nothing past process exit.
|
|
864
|
+
*/
|
|
865
|
+
close(): void;
|
|
866
|
+
/**
|
|
867
|
+
* Parse a document in bounded-memory page batches of `batchSize` pages.
|
|
868
|
+
*
|
|
869
|
+
* Each yielded result is independent and becomes collectible once the caller
|
|
870
|
+
* advances the iterator, so a consumer that does not retain batches never
|
|
871
|
+
* holds more than one batch of pages in memory. A non-PDF source is
|
|
872
|
+
* converted once when the iterator starts, not once per batch; its temporary
|
|
873
|
+
* file is released when iteration ends — including an early `break` or
|
|
874
|
+
* `throw`, which run the generator's cleanup.
|
|
875
|
+
*
|
|
876
|
+
* Cross-page passes see only the pages in their own batch, so repeated
|
|
877
|
+
* header/footer removal and image deduplication are batch-local and the
|
|
878
|
+
* output can differ from `parse()`. Prefer `parse()` unless the size of the
|
|
879
|
+
* materialized result is the problem.
|
|
880
|
+
*
|
|
881
|
+
* As with any async generator, work starts on the first `next()` call, so
|
|
882
|
+
* errors (an unreadable file, or a parser configured with `targetPages` —
|
|
883
|
+
* ambiguous with generated batch ranges) surface on the first iteration
|
|
884
|
+
* rather than when `parseBatches()` itself is called.
|
|
885
|
+
*/
|
|
886
|
+
parseBatches(input: LiteParseInput, options?: ParseBatchOptions): AsyncGenerator<ParseBatch>;
|
|
887
|
+
/**
|
|
888
|
+
* Parse from pre-extracted pages, skipping PDFium text extraction. Runs only
|
|
889
|
+
* grid projection + the configured output formatter, so the caller's own
|
|
890
|
+
* text-extraction / font-recovery owns the text content. Synchronous: no
|
|
891
|
+
* PDFium load and no OCR on this path.
|
|
892
|
+
*/
|
|
893
|
+
parsePages(pages: PageInput[]): ParseResult;
|
|
894
|
+
/**
|
|
895
|
+
* Determine per-page complexity without running a full parse. Returns one
|
|
896
|
+
* entry per page with signals and a `needsOcr` verdict — a cheap pre-OCR
|
|
897
|
+
* check to decide whether a document needs advanced parsing.
|
|
898
|
+
*/
|
|
899
|
+
isComplex(input: LiteParseInput): Promise<PageComplexityStats[]>;
|
|
900
|
+
screenshot(input: LiteParseInput, pageNumbers?: number[]): Promise<ScreenshotResult[]>;
|
|
901
|
+
getConfig(): LiteParseConfig;
|
|
902
|
+
}
|
|
903
|
+
/** @internal Exported for pool-worker.ts only; not public API. */
|
|
904
|
+
declare function toParseResult(result: NativeParseResult): ParseResult;
|
|
905
|
+
interface SearchItemsOptions {
|
|
906
|
+
phrase: string;
|
|
907
|
+
caseSensitive?: boolean;
|
|
908
|
+
}
|
|
909
|
+
declare function searchItems(items: TextItem[], options: SearchItemsOptions): TextItem[];
|
|
910
|
+
|
|
911
|
+
export { type AnnotationRect, type CropBox, type DocumentAnnotation, type DocumentMetadata, type ExtractedImage, type FormField, type Graphic, type ImageMode, type LayoutBlock, type LayoutCell, type LayoutComplexityStats, LiteParse, type LiteParseConfig, type LiteParseInput, type OutputFormat, type PageComplexityStats, type PageInput, type ParseBatch, type ParseBatchOptions, type ParseResult, ParseTimeoutError, type ParsedPage, type PoolOptions, type Rect, type ScreenshotRect, type ScreenshotResult, type SearchItemsOptions, type StructureAttributeValue, type StructureTree, type StructureTreeElement, type TextItem, type VectorGraphics, type VectorLine, type VectorShape, type WordBox, type XfaPacket, LiteParse as default, searchItems, toParseResult };
|