@d0paminedriven/pdfdown-ocr 0.9.9 → 0.11.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/index.d.ts CHANGED
@@ -1,212 +1,1238 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+
4
+ // ── Utility types (shared by every generated declaration file) ──
5
+
6
+ /**
7
+ * Superior form of Omit
8
+ */
9
+ export type Rm<T, P extends keyof T = keyof T> = {
10
+ [S in keyof T as Exclude<S, P>]: T[S];
11
+ };
12
+
13
+ /**
14
+ * helper workup for use in XOR type below
15
+ * makes properties from U optional and undefined in T, and vice versa
16
+ */
17
+ export type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never };
18
+
19
+ export type Include<T, U extends T> = Exclude<T, Exclude<T, U>>;
20
+
21
+ /**
22
+ * enforces mutual exclusivity of T | U
23
+ */
24
+ // prettier-ignore
25
+ export type XOR<T, U> =
26
+ [T, U] extends [object, object]
27
+ ? (Without<T, U> & U) | (Without<U, T> & T)
28
+ : T | U;
29
+
30
+ /**
31
+ * CTR (Conditional to Required)
32
+ *
33
+ * - By default: makes all **optional** properties required.
34
+ * - With K: makes only the specified optional keys required.
35
+ */
36
+ export type CTR<T, K extends keyof OnlyOptional<T> = keyof OnlyOptional<T>> = Rm<T, K> & {
37
+ [Q in K]-?: T[Q];
38
+ };
39
+
40
+ /**
41
+ * RTC (Required to Conditional)
42
+ *
43
+ * - By default: makes all **required** properties optional.
44
+ * - With K: makes only the specified required keys optional.
45
+ */
46
+ export type RTC<T, K extends keyof OnlyRequired<T> = keyof OnlyRequired<T>> = Rm<T, K> & {
47
+ [Q in K]?: T[Q];
48
+ };
49
+ export type IsExact<T, U> = [T] extends [U] ? ([U] extends [T] ? true : false) : false;
50
+
51
+ /**
52
+ * Checks that X and Y are exactly equal.
53
+ *
54
+ * For instance, `Equal<'a', 'a'>` is true. But
55
+ * `Equal<'a', 'b'>` is false.
56
+ *
57
+ * This also checks for exact intersection equality. So
58
+ * `Equal<{ a: string; b: string }, { a: string; b: string }>`
59
+ * is true. But `Equal<{ a: string; b: string }, { a: string; } & { b: string }>`
60
+ * is false.
61
+ */
62
+ export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
63
+
64
+ export type UTR<
65
+ TUnion extends Record<TKey, string>,
66
+ TKey extends string = "kind",
67
+ TExclude extends `strip-${TKey}` | boolean = false
68
+ > = {
69
+ [K in TUnion[TKey]]: TExclude extends false
70
+ ? Extract<TUnion, Record<TKey, K>>
71
+ : Rm<Extract<TUnion, Record<TKey, K>>, TKey>;
72
+ };
73
+
74
+ export type IsOptional<T, K extends keyof T> = undefined extends T[K]
75
+ ? object extends Pick<T, K>
76
+ ? true
77
+ : false
78
+ : false;
79
+
80
+ export type OnlyOptional<T> = {
81
+ [K in keyof T as IsOptional<T, K> extends true ? K : never]: T[K];
82
+ };
83
+
84
+ export type OnlyRequired<T> = {
85
+ [K in keyof T as IsOptional<T, K> extends false ? K : never]: T[K];
86
+ };
87
+
88
+ // ── Derived aliases over the generated declarations below (TypeScript hoists type aliases) ──
89
+
90
+ export type FormFieldType = PageFormField["type"];
91
+ export type FormFieldByType = UTR<PageFormField, "type", true>;
92
+
93
+ /**
94
+ * Payload of one or more variants, selected by discriminant. Pass a single key
95
+ * for that variant's fields, or a union of keys for the union of their payloads.
96
+ *
97
+ * @example
98
+ * type Sig = FormFieldPayload<"Signature">; // { signed: boolean; page: number; ... }
99
+ * type Buttons = FormFieldPayload<"Checkbox" | "Radio">; // either payload
100
+ */
101
+ export type FormFieldPayload<T extends keyof FormFieldByType = keyof FormFieldByType> = {
102
+ [P in T]: FormFieldByType[P];
103
+ }[T];
104
+
105
+ /**
106
+ * Which binding artifact the generated loader actually loaded: `'native'` for
107
+ * a native addon, otherwise the `platformArchABI` of the WASI flavor. Every
108
+ * flavor napi-rs can build is listed, because `NAPI_RS_NATIVE_LIBRARY_PATH`
109
+ * can point the loader at a WASI artifact this package does not build itself.
110
+ */
111
+ export declare const __napiBindingTarget: "native" | "wasm32-wasi" | "wasm32-wasip1";
112
+
3
113
  export declare class PdfDown {
4
- constructor(buffer: Buffer)
5
- textPerPage(): Array<PageText>
6
- imagesPerPage(): Array<PageImage>
7
- annotationsPerPage(): Array<PageAnnotation>
8
- metadata(): PdfMeta
9
- textPerPageAsync(): Promise<Array<PageText>>
10
- imagesPerPageAsync(): Promise<Array<PageImage>>
11
- annotationsPerPageAsync(): Promise<Array<PageAnnotation>>
12
- metadataAsync(): Promise<PdfMeta>
13
- document(): PdfDocument
14
- documentAsync(): Promise<PdfDocument>
15
- structuredText(): Array<StructuredPageText>
16
- structuredTextAsync(): Promise<Array<StructuredPageText>>
17
- textWithOcrPerPage(opts?: OcrOptions | undefined | null): Array<OcrPageText>
18
- textWithOcrPerPageAsync(opts?: OcrOptions | undefined | null): Promise<Array<OcrPageText>>
19
- documentOcr(opts?: OcrOptions | undefined | null): PdfDocumentOcr
20
- documentOcrAsync(opts?: OcrOptions | undefined | null): Promise<PdfDocumentOcr>
21
- renderPagesAsync(opts?: RenderOptions | undefined | null): Promise<Array<RenderedPage>>
22
- }
23
-
24
- export type BoxType = 'CropBox'|
25
- 'MediaBox'|
26
- 'Unknown';
27
-
28
- export declare function capabilities(): Capabilities
114
+ constructor(buffer: Buffer);
115
+ /** Open a PDF or a workbook off the JavaScript thread; resolves to a `PdfDown`. */
116
+ static openAsync(buffer: Buffer): Promise<PdfDown>;
117
+ /** The format this document was opened as. */
118
+ get format(): DocumentFormat;
119
+ /** The cells of a workbook's selected sheets, typed, with their display text and formulas. */
120
+ spreadsheetCells(opts?: SpreadsheetOptions | undefined | null): Array<SheetCells>;
121
+ spreadsheetCellsAsync(opts?: SpreadsheetOptions | undefined | null): Promise<Array<SheetCells>>;
122
+ textPerPage(): Array<PageText>;
123
+ imagesPerPage(): Array<PageImage>;
124
+ annotationsPerPage(): Array<PageAnnotation>;
125
+ metadata(): PdfMeta;
126
+ /**
127
+ * Positioned words and lines per page: a PDF's content stream (native text only), or one
128
+ * logical page per selected sheet of a workbook, where `opts` picks the sheets and whether
129
+ * hidden rows and columns keep their extents. A PDF ignores `opts`.
130
+ */
131
+ layout(opts?: SpreadsheetOptions | undefined | null): Array<PageLayout>;
132
+ layoutAsync(opts?: SpreadsheetOptions | undefined | null): Promise<Array<PageLayout>>;
133
+ attachments(): Array<Attachment>;
134
+ attachmentsAsync(): Promise<Array<Attachment>>;
135
+ /**
136
+ * Structured invoice data. A PDF reads its embedded Factur-X / ZUGFeRD / XRechnung / UBL
137
+ * XML; a workbook returns `source: "None"` with a warning until the layout-based engine
138
+ * reads spreadsheet pages.
139
+ */
140
+ invoice(opts?: InvoiceOptions | undefined | null): InvoiceResult;
141
+ invoiceAsync(opts?: InvoiceOptions | undefined | null): Promise<InvoiceResult>;
142
+ textPerPageAsync(): Promise<Array<PageText>>;
143
+ imagesPerPageAsync(): Promise<Array<PageImage>>;
144
+ annotationsPerPageAsync(): Promise<Array<PageAnnotation>>;
145
+ metadataAsync(): Promise<PdfMeta>;
146
+ document(): PdfDocument;
147
+ documentAsync(): Promise<PdfDocument>;
148
+ structuredText(): Array<StructuredPageText>;
149
+ structuredTextAsync(): Promise<Array<StructuredPageText>>;
150
+ formFieldsPerPage(): Array<PageFormField>;
151
+ formFieldsPerPageAsync(): Promise<Array<PageFormField>>;
152
+ textWithOcrPerPage(opts?: OcrOptions | undefined | null): Array<OcrPageText>;
153
+ textWithOcrPerPageAsync(opts?: OcrOptions | undefined | null): Promise<Array<OcrPageText>>;
154
+ /** Positioned words and lines per page with the OCR cascade. */
155
+ layoutWithOcr(opts?: OcrOptions | undefined | null): Array<PageLayout>;
156
+ layoutWithOcrAsync(opts?: OcrOptions | undefined | null): Promise<Array<PageLayout>>;
157
+ documentOcr(opts?: OcrOptions | undefined | null): PdfDocumentOcr;
158
+ documentOcrAsync(opts?: OcrOptions | undefined | null): Promise<PdfDocumentOcr>;
159
+ renderPagesAsync(opts?: RenderOptions | undefined | null): Promise<Array<RenderedPage>>;
160
+ }
161
+
162
+ /** `value` is `lines` joined with `
163
+ `. */
164
+ export interface AddressField {
165
+ value: string;
166
+ text: string;
167
+ confidence: number;
168
+ span?: FieldSpan;
169
+ lines: Array<string>;
170
+ }
171
+
172
+ /**
173
+ * An aircraft or engine the invoice relates to. Maintenance, parts and
174
+ * program invoices identify the asset by airframe (model, manufacturer serial
175
+ * number, registration) and/or by engine (model, engine serial number); one
176
+ * invoice can cover several assets, so `InvoiceFields.aircraft` is a list.
177
+ */
178
+ export interface AircraftReference {
179
+ /** Airframe model, e.g. "Challenger 350", "Global 6000", "Phenom 300". */
180
+ model?: StringField;
181
+ /** Manufacturer serial number (MSN). */
182
+ serialNumber?: StringField;
183
+ /** Registration / tail number, e.g. "N123AB", "C-GXYZ". */
184
+ registration?: StringField;
185
+ /** Engine model, e.g. "BR710", "AE 3007", "PW308C". */
186
+ engineModel?: StringField;
187
+ /** Engine serial number (ESN). */
188
+ engineSerialNumber?: StringField;
189
+ span?: FieldSpan;
190
+ }
191
+
192
+ /**
193
+ * A file embedded in the PDF: a `/Names /EmbeddedFiles` entry, a catalog
194
+ * `/AF` associated file, or a page-level `/FileAttachment` annotation.
195
+ */
196
+ export interface Attachment {
197
+ name: string;
198
+ /** From the embedded file stream's `/Subtype`, e.g. `text/xml`. */
199
+ mimeType?: string;
200
+ /** Decoded payload size in bytes. */
201
+ size: number;
202
+ /** `/AFRelationship`: `Source`, `Data`, `Alternative`, `Supplement`, ... */
203
+ relationship?: string;
204
+ description?: string;
205
+ /** 1-based page for a `/FileAttachment` annotation; absent for document-level files. */
206
+ page?: number;
207
+ data: Buffer;
208
+ }
209
+
210
+ /** Every embedded file: `/Names /EmbeddedFiles`, catalog `/AF`, and page `/FileAttachment` annotations. */
211
+ export declare function attachments(buffer: Buffer): Array<Attachment>;
212
+
213
+ export declare function attachmentsAsync(buffer: Buffer): Promise<Array<Attachment>>;
214
+
215
+ export type BoxType = "CropBox" | "MediaBox" | "Unknown";
216
+
217
+ export declare function capabilities(): Capabilities;
29
218
 
30
219
  export interface Capabilities {
31
- ocr: boolean
32
- render: boolean
220
+ ocr: boolean;
221
+ render: boolean;
222
+ }
223
+
224
+ /** A rectangle in the sheet frame: points, y up, with A1's top-left corner at `(0, height)`. */
225
+ export interface CellBox {
226
+ x0: number;
227
+ y0: number;
228
+ x1: number;
229
+ y1: number;
230
+ }
231
+
232
+ export interface ChoiceOption {
233
+ exportValue: string;
234
+ displayValue: string;
235
+ }
236
+
237
+ /**
238
+ * Which tier named the currency: evidence on the page (an ISO code or an unambiguous glyph),
239
+ * content priors such as the vendor's country, the caller's option, or nothing.
240
+ */
241
+ export type CurrencySource = "Page" | "Content" | "Option" | "Unknown";
242
+
243
+ /** `value` is an ISO 8601 calendar date, `YYYY-MM-DD`. */
244
+ export interface DateField {
245
+ value: string;
246
+ text: string;
247
+ confidence: number;
248
+ span?: FieldSpan;
249
+ }
250
+
251
+ export type DateOrder = "Auto" | "MDY" | "DMY" | "YMD";
252
+
253
+ /** `Pdf`, `Xlsx`, or `Unknown` with what the buffer was instead. */
254
+ export declare function detectFormat(buffer: Buffer): FormatDetection;
255
+
256
+ /** `detectFormat` off the JavaScript thread: a zip's package directory is read to name it. */
257
+ export declare function detectFormatAsync(buffer: Buffer): Promise<FormatDetection>;
258
+
259
+ /** What `detectFormat` and `PdfDown` recognise. */
260
+ export type DocumentFormat = "Pdf" | "Xlsx" | "Unknown";
261
+
262
+ export type EInvoiceStandard = "FacturX" | "ZUGFeRD" | "XRechnung" | "UBL" | "Unknown";
263
+
264
+ export interface EmbeddedInvoiceXml {
265
+ filename: string;
266
+ standard: EInvoiceStandard;
267
+ /**
268
+ * The guideline / customization identifier, e.g.
269
+ * `urn:cen.eu:en16931:2017#compliant#urn:factur-x.eu:1p0:basic`.
270
+ */
271
+ profile?: string;
272
+ xml: string;
273
+ }
274
+
275
+ export declare function extractAnnotationsPerPage(buffer: Buffer): Array<PageAnnotation>;
276
+
277
+ export declare function extractAnnotationsPerPageAsync(buffer: Buffer): Promise<Array<PageAnnotation>>;
278
+
279
+ export declare function extractFormFieldsPerPage(buffer: Buffer): Array<PageFormField>;
280
+
281
+ export declare function extractFormFieldsPerPageAsync(buffer: Buffer): Promise<Array<PageFormField>>;
282
+
283
+ export declare function extractImagesPerPage(buffer: Buffer): Array<PageImage>;
284
+
285
+ export declare function extractImagesPerPageAsync(buffer: Buffer): Promise<Array<PageImage>>;
286
+
287
+ /**
288
+ * Structured invoice data. This version reads embedded Factur-X / ZUGFeRD /
289
+ * XRechnung / UBL XML; documents without it return `source: "None"`.
290
+ */
291
+ export declare function extractInvoice(buffer: Buffer, opts?: InvoiceOptions | undefined | null): InvoiceResult;
292
+
293
+ export declare function extractInvoiceAsync(
294
+ buffer: Buffer,
295
+ opts?: InvoiceOptions | undefined | null
296
+ ): Promise<InvoiceResult>;
297
+
298
+ /**
299
+ * Positioned words and lines per page with the OCR cascade: native glyph
300
+ * placement, then OCR of embedded images mapped through their placements,
301
+ * then (with PDFium) OCR of the rasterised page.
302
+ */
303
+ export declare function extractLayoutWithOcrPerPage(
304
+ buffer: Buffer,
305
+ opts?: OcrOptions | undefined | null
306
+ ): Array<PageLayout>;
307
+
308
+ export declare function extractLayoutWithOcrPerPageAsync(
309
+ buffer: Buffer,
310
+ opts?: OcrOptions | undefined | null
311
+ ): Promise<Array<PageLayout>>;
312
+
313
+ export declare function extractStructuredTextPerPage(buffer: Buffer): Array<StructuredPageText>;
314
+
315
+ export declare function extractStructuredTextPerPageAsync(buffer: Buffer): Promise<Array<StructuredPageText>>;
316
+
317
+ export declare function extractTextPerPage(buffer: Buffer): Array<PageText>;
318
+
319
+ export declare function extractTextPerPageAsync(buffer: Buffer): Promise<Array<PageText>>;
320
+
321
+ export declare function extractTextWithOcrPerPage(
322
+ buffer: Buffer,
323
+ opts?: OcrOptions | undefined | null
324
+ ): Array<OcrPageText>;
325
+
326
+ export declare function extractTextWithOcrPerPageAsync(
327
+ buffer: Buffer,
328
+ opts?: OcrOptions | undefined | null
329
+ ): Promise<Array<OcrPageText>>;
330
+
331
+ /** Where a field was read from, in PDF user space on a 1-based page. */
332
+ export interface FieldSpan {
333
+ page: number;
334
+ x0: number;
335
+ y0: number;
336
+ x1: number;
337
+ y1: number;
33
338
  }
34
339
 
35
- export declare function extractAnnotationsPerPage(buffer: Buffer): Array<PageAnnotation>
340
+ /** The outcome of `detectFormat`: the format, and for `Unknown` what the input was instead. */
341
+ export interface FormatDetection {
342
+ format: DocumentFormat;
343
+ detail?: string;
344
+ }
36
345
 
37
- export declare function extractAnnotationsPerPageAsync(buffer: Buffer): Promise<Array<PageAnnotation>>
346
+ /**
347
+ * Document-level AcroForm facts. Present on `PdfMeta` / `PdfDocument` when `/AcroForm` exists
348
+ * or orphan widgets were found.
349
+ */
350
+ export interface FormInfo {
351
+ /** `/AcroForm` present (false when only orphan widgets were found). */
352
+ hasAcroForm: boolean;
353
+ /** `/AcroForm /XFA` present (XFA is not parsed). */
354
+ hasXfa: boolean;
355
+ needAppearances: boolean;
356
+ sigFlags: number;
357
+ /** Logical fields, placed + unplaced; may differ from `totalFormFields`. */
358
+ fieldCount: number;
359
+ /** Placements; always equals `totalFormFields` and `formFields.length`. */
360
+ widgetCount: number;
361
+ unplacedFields: Array<UnplacedFormField>;
362
+ /** The `/Kids` depth cap was hit somewhere: the result is partial. */
363
+ truncated: boolean;
364
+ /** Dangling references, non-array `/Annots`, non-dictionary `/Kids` entries, depth cap. */
365
+ warnings: Array<string>;
366
+ }
38
367
 
39
- export declare function extractImagesPerPage(buffer: Buffer): Array<PageImage>
368
+ export type InvoiceDocumentType = "Invoice" | "CreditNote" | "Unknown";
40
369
 
41
- export declare function extractImagesPerPageAsync(buffer: Buffer): Promise<Array<PageImage>>
370
+ /**
371
+ * Field names mirror the de-facto vocabulary of common invoice extractors so
372
+ * consumers can swap sources with a thin mapper. Naming only: nothing here
373
+ * talks to any service.
374
+ */
375
+ export interface InvoiceFields {
376
+ vendorName?: StringField;
377
+ vendorAddress?: AddressField;
378
+ vendorTaxId?: StringField;
379
+ vendorEmail?: StringField;
380
+ vendorPhone?: StringField;
381
+ vendorWebsite?: StringField;
382
+ customerName?: StringField;
383
+ customerId?: StringField;
384
+ customerAddress?: AddressField;
385
+ customerTaxId?: StringField;
386
+ billingAddress?: AddressField;
387
+ shippingAddress?: AddressField;
388
+ remittanceAddress?: AddressField;
389
+ invoiceId?: StringField;
390
+ invoiceDate?: DateField;
391
+ dueDate?: DateField;
392
+ purchaseOrder?: StringField;
393
+ paymentTerm?: StringField;
394
+ serviceStartDate?: DateField;
395
+ serviceEndDate?: DateField;
396
+ currencyCode?: string;
397
+ subTotal?: MoneyField;
398
+ totalDiscount?: MoneyField;
399
+ totalTax?: MoneyField;
400
+ shippingCost?: MoneyField;
401
+ invoiceTotal?: MoneyField;
402
+ amountDue?: MoneyField;
403
+ previousUnpaidBalance?: MoneyField;
404
+ /** MRO work order / shop order the invoice bills against. */
405
+ workOrder?: StringField;
406
+ /** Aircraft and engines the invoice relates to; empty when none is identified. */
407
+ aircraft: Array<AircraftReference>;
408
+ taxDetails: Array<TaxDetail>;
409
+ paymentDetails: Array<PaymentDetail>;
410
+ items: Array<InvoiceItem>;
411
+ }
42
412
 
43
- export declare function extractStructuredTextPerPage(buffer: Buffer): Array<StructuredPageText>
413
+ /**
414
+ * The layout track over pages from anywhere: a PDF's own layout, `layoutWithOcr`, a workbook's
415
+ * logical pages, or pages the caller built.
416
+ */
417
+ export declare function invoiceFromLayout(
418
+ pages: Array<PageLayout>,
419
+ opts?: InvoiceOptions | undefined | null
420
+ ): InvoiceResult;
44
421
 
45
- export declare function extractStructuredTextPerPageAsync(buffer: Buffer): Promise<Array<StructuredPageText>>
422
+ export declare function invoiceFromLayoutAsync(
423
+ pages: Array<PageLayout>,
424
+ opts?: InvoiceOptions | undefined | null
425
+ ): Promise<InvoiceResult>;
46
426
 
47
- export declare function extractTextPerPage(buffer: Buffer): Array<PageText>
427
+ export interface InvoiceItem {
428
+ description?: StringField;
429
+ productCode?: StringField;
430
+ quantity?: NumberField;
431
+ unit?: StringField;
432
+ unitPrice?: MoneyField;
433
+ taxRate?: NumberField;
434
+ tax?: MoneyField;
435
+ discount?: MoneyField;
436
+ date?: DateField;
437
+ amount?: MoneyField;
438
+ /** Absent when the item came from embedded XML (no page geometry). */
439
+ span?: FieldSpan;
440
+ }
48
441
 
49
- export declare function extractTextPerPageAsync(buffer: Buffer): Promise<Array<PageText>>
442
+ /**
443
+ * Options accepted by every invoice entry point. `preferEmbeddedXml` picks the embedded
444
+ * XML over the pages when both exist; `languages`, `currency`, `dateOrder` and
445
+ * `decimalSeparator` steer the page reader where the page leaves a choice;
446
+ * `includeCandidates` lists, in `warnings`, the candidates each field was chosen from;
447
+ * `includeLayout` is reserved.
448
+ */
449
+ export interface InvoiceOptions {
450
+ /** Label lexicons to enable; default `["en"]`. */
451
+ languages?: Array<string>;
452
+ /** ISO 4217 hint when the page shows only symbols. */
453
+ currency?: string;
454
+ dateOrder?: DateOrder;
455
+ decimalSeparator?: "Auto" | "." | ",";
456
+ /** Default `true`. Embedded Factur-X / ZUGFeRD / XRechnung / UBL XML is used when present. */
457
+ preferEmbeddedXml?: boolean;
458
+ /** Reserved; accepted and ignored. */
459
+ includeLayout?: boolean;
460
+ /**
461
+ * Default `false`. Lists, in `warnings`, the candidates each field was chosen from, with
462
+ * their scores.
463
+ */
464
+ includeCandidates?: boolean;
465
+ }
466
+
467
+ export interface InvoiceResult {
468
+ source: InvoiceSource;
469
+ documentType: InvoiceDocumentType;
470
+ /** Document-level confidence, 0..1. */
471
+ confidence: number;
472
+ fields: InvoiceFields;
473
+ warnings: Array<string>;
474
+ embeddedXml?: EmbeddedInvoiceXml;
475
+ /** Which tier named `fields.currencyCode`; absent when no layout pass ran. */
476
+ currencySource?: CurrencySource;
477
+ /** The evidence behind `documentType: CreditNote`; empty otherwise. */
478
+ creditSignals: Array<string>;
479
+ }
50
480
 
51
- export declare function extractTextWithOcrPerPage(buffer: Buffer, opts?: OcrOptions | undefined | null): Array<OcrPageText>
481
+ /**
482
+ * Which extraction path produced the result: embedded XML, the page text (native, OCR,
483
+ * rendered or mixed), a workbook's cells, or `None` when the document had no readable
484
+ * pages and no embedded XML.
485
+ */
486
+ export type InvoiceSource = "EmbeddedXml" | "Native" | "Ocr" | "Rendered" | "Mixed" | "Spreadsheet" | "None";
487
+
488
+ /**
489
+ * The logical pages of a workbook buffer's selected sheets, as `PageLayout` with
490
+ * `source: "Spreadsheet"`.
491
+ */
492
+ export declare function layoutFromXlsx(buffer: Buffer, opts?: SpreadsheetOptions | undefined | null): Array<PageLayout>;
493
+
494
+ export declare function layoutFromXlsxAsync(
495
+ buffer: Buffer,
496
+ opts?: SpreadsheetOptions | undefined | null
497
+ ): Promise<Array<PageLayout>>;
498
+
499
+ /**
500
+ * Positioned words and lines per page from the content stream (native text only).
501
+ * Coordinates are PDF user space in points, y up.
502
+ */
503
+ export declare function layoutPerPage(buffer: Buffer): Array<PageLayout>;
504
+
505
+ export declare function layoutPerPageAsync(buffer: Buffer): Promise<Array<PageLayout>>;
506
+
507
+ /**
508
+ * Money as a JS number plus the exact printed text; `text` is authoritative
509
+ * when cents matter.
510
+ */
511
+ export interface MoneyField {
512
+ value: number;
513
+ text: string;
514
+ confidence: number;
515
+ span?: FieldSpan;
516
+ currencyCode?: string;
517
+ currencySymbol?: string;
518
+ }
519
+
520
+ export interface NumberField {
521
+ value: number;
522
+ text: string;
523
+ confidence: number;
524
+ span?: FieldSpan;
525
+ }
52
526
 
53
- export declare function extractTextWithOcrPerPageAsync(buffer: Buffer, opts?: OcrOptions | undefined | null): Promise<Array<OcrPageText>>
527
+ /**
528
+ * Whether a Number cell's value is a whole number JavaScript can hold exactly, or a fraction.
529
+ * A percentage is a fraction (50% is 0.5); the subtype is about the value, not the format.
530
+ */
531
+ export type NumberSubtype = "Integer" | "Float";
54
532
 
55
533
  export interface OcrOptions {
56
- lang?: string
57
- minTextLength?: number
58
- maxThreads?: number
59
- render?: RenderMode
60
- renderDpi?: number
61
- pdfiumPath?: string
534
+ lang?: string;
535
+ minTextLength?: number;
536
+ maxThreads?: number;
537
+ render?: RenderMode;
538
+ renderDpi?: number;
539
+ pdfiumPath?: string;
62
540
  }
63
541
 
64
542
  export interface OcrPageText {
65
- page: number
66
- text: string
67
- source: TextSource
543
+ page: number;
544
+ text: string;
545
+ source: TextSource;
68
546
  }
69
547
 
70
548
  export interface OcrStructuredPageText {
71
- page: number
72
- header: string
73
- body: string
74
- footer: string
75
- source: TextSource
549
+ page: number;
550
+ header: string;
551
+ body: string;
552
+ footer: string;
553
+ source: TextSource;
76
554
  }
77
555
 
78
556
  export interface PageAnnotation {
79
- page: number
80
- subtype: string
81
- rect: Array<number>
82
- uri?: string
83
- dest?: string
84
- content?: string
557
+ page: number;
558
+ subtype: string;
559
+ rect: Array<number>;
560
+ uri?: string;
561
+ dest?: string;
562
+ content?: string;
85
563
  }
86
564
 
87
565
  export interface PageBox {
88
566
  /** Number of pages that share these dimensions. */
89
- pageCount: number
90
- left: number
91
- bottom: number
92
- right: number
93
- top: number
94
- width: number
95
- height: number
96
- boxType: BoxType
567
+ pageCount: number;
568
+ left: number;
569
+ bottom: number;
570
+ right: number;
571
+ top: number;
572
+ width: number;
573
+ height: number;
574
+ boxType: BoxType;
97
575
  /**
98
576
  * Present only on non-dominant boxes — lists the specific pages with these
99
577
  * dimensions. `None` on the first (most frequent) entry means "all pages
100
578
  * not listed in any other entry's `pages` array."
101
579
  */
102
- pages?: Array<number>
580
+ pages?: Array<number>;
103
581
  }
104
582
 
583
+ export type PageFormField =
584
+ | {
585
+ type: "Text";
586
+ page: number;
587
+ rect: Array<number>;
588
+ objectId: string;
589
+ fieldObjectId: string;
590
+ name: string;
591
+ partialName: string;
592
+ widgetIndex: number;
593
+ widgetCount: number;
594
+ value?: string;
595
+ defaultValue?: string;
596
+ tooltip?: string;
597
+ mappingName?: string;
598
+ readOnly: boolean;
599
+ required: boolean;
600
+ noExport: boolean;
601
+ hasActions: boolean;
602
+ multiline: boolean;
603
+ password: boolean;
604
+ comb: boolean;
605
+ richText: boolean;
606
+ maxLen?: number;
607
+ }
608
+ | {
609
+ type: "Checkbox";
610
+ page: number;
611
+ rect: Array<number>;
612
+ objectId: string;
613
+ fieldObjectId: string;
614
+ name: string;
615
+ partialName: string;
616
+ widgetIndex: number;
617
+ widgetCount: number;
618
+ value?: string;
619
+ defaultValue?: string;
620
+ tooltip?: string;
621
+ mappingName?: string;
622
+ readOnly: boolean;
623
+ required: boolean;
624
+ noExport: boolean;
625
+ hasActions: boolean;
626
+ onState?: string;
627
+ exportValue?: string;
628
+ checked: boolean;
629
+ }
630
+ | {
631
+ type: "Radio";
632
+ page: number;
633
+ rect: Array<number>;
634
+ objectId: string;
635
+ fieldObjectId: string;
636
+ name: string;
637
+ partialName: string;
638
+ widgetIndex: number;
639
+ widgetCount: number;
640
+ value?: string;
641
+ defaultValue?: string;
642
+ tooltip?: string;
643
+ mappingName?: string;
644
+ readOnly: boolean;
645
+ required: boolean;
646
+ noExport: boolean;
647
+ hasActions: boolean;
648
+ onState?: string;
649
+ exportValue?: string;
650
+ selected: boolean;
651
+ }
652
+ | {
653
+ type: "ComboBox";
654
+ page: number;
655
+ rect: Array<number>;
656
+ objectId: string;
657
+ fieldObjectId: string;
658
+ name: string;
659
+ partialName: string;
660
+ widgetIndex: number;
661
+ widgetCount: number;
662
+ value?: string;
663
+ defaultValue?: string;
664
+ tooltip?: string;
665
+ mappingName?: string;
666
+ readOnly: boolean;
667
+ required: boolean;
668
+ noExport: boolean;
669
+ hasActions: boolean;
670
+ options: Array<ChoiceOption>;
671
+ editable: boolean;
672
+ }
673
+ | {
674
+ type: "ListBox";
675
+ page: number;
676
+ rect: Array<number>;
677
+ objectId: string;
678
+ fieldObjectId: string;
679
+ name: string;
680
+ partialName: string;
681
+ widgetIndex: number;
682
+ widgetCount: number;
683
+ value?: string;
684
+ defaultValue?: string;
685
+ tooltip?: string;
686
+ mappingName?: string;
687
+ readOnly: boolean;
688
+ required: boolean;
689
+ noExport: boolean;
690
+ hasActions: boolean;
691
+ options: Array<ChoiceOption>;
692
+ multiSelect: boolean;
693
+ values?: Array<string>;
694
+ }
695
+ | {
696
+ type: "PushButton";
697
+ page: number;
698
+ rect: Array<number>;
699
+ objectId: string;
700
+ fieldObjectId: string;
701
+ name: string;
702
+ partialName: string;
703
+ widgetIndex: number;
704
+ widgetCount: number;
705
+ value?: string;
706
+ defaultValue?: string;
707
+ tooltip?: string;
708
+ mappingName?: string;
709
+ readOnly: boolean;
710
+ required: boolean;
711
+ noExport: boolean;
712
+ hasActions: boolean;
713
+ }
714
+ | {
715
+ type: "Signature";
716
+ page: number;
717
+ rect: Array<number>;
718
+ objectId: string;
719
+ fieldObjectId: string;
720
+ name: string;
721
+ partialName: string;
722
+ widgetIndex: number;
723
+ widgetCount: number;
724
+ value?: string;
725
+ defaultValue?: string;
726
+ tooltip?: string;
727
+ mappingName?: string;
728
+ readOnly: boolean;
729
+ required: boolean;
730
+ noExport: boolean;
731
+ hasActions: boolean;
732
+ signed: boolean;
733
+ }
734
+ | {
735
+ type: "Unknown";
736
+ page: number;
737
+ rect: Array<number>;
738
+ objectId: string;
739
+ fieldObjectId: string;
740
+ name: string;
741
+ partialName: string;
742
+ widgetIndex: number;
743
+ widgetCount: number;
744
+ value?: string;
745
+ defaultValue?: string;
746
+ tooltip?: string;
747
+ mappingName?: string;
748
+ readOnly: boolean;
749
+ required: boolean;
750
+ noExport: boolean;
751
+ hasActions: boolean;
752
+ };
753
+
105
754
  export interface PageImage {
106
- page: number
107
- imageIndex: number
108
- width: number
109
- height: number
110
- data: Buffer
111
- colorSpace: string
112
- bitsPerComponent: number
113
- filter: string
114
- xobjectName: string
115
- objectId: string
755
+ page: number;
756
+ imageIndex: number;
757
+ width: number;
758
+ height: number;
759
+ data: Buffer;
760
+ colorSpace: string;
761
+ bitsPerComponent: number;
762
+ filter: string;
763
+ xobjectName: string;
764
+ objectId: string;
765
+ }
766
+
767
+ export interface PageLayout {
768
+ page: number;
769
+ /**
770
+ * CropBox (fallback MediaBox) size in points. Coordinates in `words`,
771
+ * `lines` and `images` are raw user space, not shifted to this box's origin.
772
+ */
773
+ width: number;
774
+ height: number;
775
+ /** `/Rotate`, reported and not applied. */
776
+ rotate: number;
777
+ /**
778
+ * Clockwise degrees (0, 90, 180, 270) the OCR tiers turned the page so its
779
+ * text reads upright: the turn carrying the most confident OCR text across
780
+ * the page's images (the tiles of a tiled scan vote together). Every word,
781
+ * line and image placement is expressed in that turned frame, and `width`
782
+ * and `height` swap for a quarter turn. An image with more than a few words
783
+ * that reads upright at a different turn is named in a warning: its words
784
+ * read sideways in the page frame. The render tier reads the page as
785
+ * displayed, so its turn includes `/Rotate`. Always 0 for `Native` pages.
786
+ * For any page, displayed coordinates are this frame turned clockwise by
787
+ * `rotate - contentRotation` (mod 360).
788
+ */
789
+ contentRotation: number;
790
+ /**
791
+ * Deepest cascade tier that ran: `Native`, or `Ocr` / `Rendered` on a page
792
+ * whose native words (if any) were kept alongside the OCR words.
793
+ */
794
+ source: TextSource;
795
+ /** Spreadsheet pages only: the sheet this logical page projects. */
796
+ sheet?: string;
797
+ words: Array<TextWord>;
798
+ lines: Array<TextLine>;
799
+ images: Array<PlacedImage>;
800
+ warnings: Array<string>;
116
801
  }
117
802
 
118
803
  export interface PageText {
119
- page: number
120
- text: string
804
+ page: number;
805
+ text: string;
806
+ }
807
+
808
+ export interface PaymentDetail {
809
+ iban?: StringField;
810
+ swift?: StringField;
811
+ bankName?: StringField;
812
+ accountNumber?: StringField;
813
+ routingNumber?: StringField;
121
814
  }
122
815
 
123
- export declare function pdfDocument(buffer: Buffer): PdfDocument
816
+ export declare function pdfDocument(buffer: Buffer): PdfDocument;
124
817
 
125
818
  export interface PdfDocument {
126
- version: string
127
- isLinearized: boolean
128
- pageCount: number
129
- creator?: string
130
- producer?: string
131
- creationDate?: string
132
- modificationDate?: string
133
- pageBoxes: Array<PageBox>
134
- totalImages: number
135
- totalAnnotations: number
136
- imagePages: Array<number>
137
- annotationPages: Array<number>
138
- text: Array<PageText>
139
- structuredText: Array<StructuredPageText>
140
- images: Array<PageImage>
141
- annotations: Array<PageAnnotation>
142
- }
143
-
144
- export declare function pdfDocumentAsync(buffer: Buffer): Promise<PdfDocument>
145
-
146
- export declare function pdfDocumentOcr(buffer: Buffer, opts?: OcrOptions | undefined | null): PdfDocumentOcr
819
+ version: string;
820
+ isLinearized: boolean;
821
+ pageCount: number;
822
+ creator?: string;
823
+ producer?: string;
824
+ creationDate?: string;
825
+ modificationDate?: string;
826
+ pageBoxes: Array<PageBox>;
827
+ totalImages: number;
828
+ totalAnnotations: number;
829
+ imagePages: Array<number>;
830
+ annotationPages: Array<number>;
831
+ text: Array<PageText>;
832
+ structuredText: Array<StructuredPageText>;
833
+ images: Array<PageImage>;
834
+ annotations: Array<PageAnnotation>;
835
+ form?: FormInfo;
836
+ formFields: Array<PageFormField>;
837
+ totalFormFields: number;
838
+ formFieldPages: Array<number>;
839
+ }
840
+
841
+ export declare function pdfDocumentAsync(buffer: Buffer): Promise<PdfDocument>;
842
+
843
+ export declare function pdfDocumentOcr(buffer: Buffer, opts?: OcrOptions | undefined | null): PdfDocumentOcr;
147
844
 
148
845
  export interface PdfDocumentOcr {
149
- version: string
150
- isLinearized: boolean
151
- pageCount: number
152
- creator?: string
153
- producer?: string
154
- creationDate?: string
155
- modificationDate?: string
156
- pageBoxes: Array<PageBox>
157
- totalImages: number
158
- totalAnnotations: number
159
- imagePages: Array<number>
160
- annotationPages: Array<number>
161
- text: Array<OcrPageText>
162
- structuredText: Array<OcrStructuredPageText>
163
- images: Array<PageImage>
164
- annotations: Array<PageAnnotation>
165
- }
166
-
167
- export declare function pdfDocumentOcrAsync(buffer: Buffer, opts?: OcrOptions | undefined | null): Promise<PdfDocumentOcr>
846
+ version: string;
847
+ isLinearized: boolean;
848
+ pageCount: number;
849
+ creator?: string;
850
+ producer?: string;
851
+ creationDate?: string;
852
+ modificationDate?: string;
853
+ pageBoxes: Array<PageBox>;
854
+ totalImages: number;
855
+ totalAnnotations: number;
856
+ imagePages: Array<number>;
857
+ annotationPages: Array<number>;
858
+ text: Array<OcrPageText>;
859
+ structuredText: Array<OcrStructuredPageText>;
860
+ images: Array<PageImage>;
861
+ annotations: Array<PageAnnotation>;
862
+ form?: FormInfo;
863
+ formFields: Array<PageFormField>;
864
+ totalFormFields: number;
865
+ formFieldPages: Array<number>;
866
+ }
867
+
868
+ export declare function pdfDocumentOcrAsync(
869
+ buffer: Buffer,
870
+ opts?: OcrOptions | undefined | null
871
+ ): Promise<PdfDocumentOcr>;
168
872
 
169
873
  export interface PdfMeta {
170
- pageCount: number
171
- version: string
172
- isLinearized: boolean
173
- creator?: string
174
- producer?: string
175
- creationDate?: string
176
- modificationDate?: string
177
- pageBoxes: Array<PageBox>
874
+ pageCount: number;
875
+ version: string;
876
+ isLinearized: boolean;
877
+ creator?: string;
878
+ producer?: string;
879
+ creationDate?: string;
880
+ modificationDate?: string;
881
+ pageBoxes: Array<PageBox>;
882
+ /** AcroForm facts; present when `/AcroForm` exists or orphan widgets were found. */
883
+ form?: FormInfo;
178
884
  }
179
885
 
180
- export declare function pdfMetadata(buffer: Buffer): PdfMeta
886
+ export declare function pdfMetadata(buffer: Buffer): PdfMeta;
181
887
 
182
- export declare function pdfMetadataAsync(buffer: Buffer): Promise<PdfMeta>
888
+ export declare function pdfMetadataAsync(buffer: Buffer): Promise<PdfMeta>;
889
+
890
+ /**
891
+ * Where an image XObject was painted: the unit square under the CTM at the
892
+ * `Do` operator, as an axis-aligned box in user space.
893
+ */
894
+ export interface PlacedImage {
895
+ xobjectName: string;
896
+ x0: number;
897
+ y0: number;
898
+ x1: number;
899
+ y1: number;
900
+ }
183
901
 
184
902
  export interface RenderedPage {
185
- page: number
186
- width: number
187
- height: number
188
- dpi: number
189
- data: Buffer
903
+ page: number;
904
+ width: number;
905
+ height: number;
906
+ dpi: number;
907
+ data: Buffer;
190
908
  }
191
909
 
192
- export type RenderMode = 'Auto'|
193
- 'Never'|
194
- 'Always';
910
+ export type RenderMode = "Auto" | "Never" | "Always";
195
911
 
196
912
  export interface RenderOptions {
197
- dpi?: number
198
- mode?: RenderMode
913
+ dpi?: number;
914
+ mode?: RenderMode;
199
915
  }
200
916
 
201
- export declare function renderPagesAsync(buffer: Buffer, opts?: RenderOptions | undefined | null): Promise<Array<RenderedPage>>
917
+ export declare function renderPagesAsync(
918
+ buffer: Buffer,
919
+ opts?: RenderOptions | undefined | null
920
+ ): Promise<Array<RenderedPage>>;
921
+
922
+ /**
923
+ * One cell of a worksheet: a discriminated union on `type` whose typed value is `value`
924
+ * (none for `Blank`): a Number carries the full double plus its `subtype` and the
925
+ * `currencySymbol` its format names; a Date carries an ISO date or date-time; a Time the
926
+ * clock of a time-only cell. `text` is the display text, `raw` the stored spelling (the
927
+ * serial for dates and times), `format` the code that produced `text`, `formula` the expression stored on this
928
+ * cell, `sharedFormula` the master cell when this cell follows a shared formula, `cached`
929
+ * whether a result was stored, `merge` the range this cell anchors, `hidden` whether its row
930
+ * or column is hidden, `box` its rectangle in the sheet frame (a merged anchor spans its
931
+ * range).
932
+ */
933
+ export type SheetCell =
934
+ | {
935
+ type: "Text";
936
+ ref: string;
937
+ row: number;
938
+ col: number;
939
+ text: string;
940
+ raw: string;
941
+ format?: string;
942
+ formatSupported: boolean;
943
+ formula?: string;
944
+ sharedFormula?: string;
945
+ cached: boolean;
946
+ merge?: string;
947
+ hidden: boolean;
948
+ box: CellBox;
949
+ value: string;
950
+ }
951
+ | {
952
+ type: "Number";
953
+ ref: string;
954
+ row: number;
955
+ col: number;
956
+ text: string;
957
+ raw: string;
958
+ format?: string;
959
+ formatSupported: boolean;
960
+ formula?: string;
961
+ sharedFormula?: string;
962
+ cached: boolean;
963
+ merge?: string;
964
+ hidden: boolean;
965
+ box: CellBox;
966
+ value: number;
967
+ subtype: NumberSubtype;
968
+ currencySymbol?: string;
969
+ }
970
+ | {
971
+ type: "Boolean";
972
+ ref: string;
973
+ row: number;
974
+ col: number;
975
+ text: string;
976
+ raw: string;
977
+ format?: string;
978
+ formatSupported: boolean;
979
+ formula?: string;
980
+ sharedFormula?: string;
981
+ cached: boolean;
982
+ merge?: string;
983
+ hidden: boolean;
984
+ box: CellBox;
985
+ value: boolean;
986
+ }
987
+ | {
988
+ type: "Error";
989
+ ref: string;
990
+ row: number;
991
+ col: number;
992
+ text: string;
993
+ raw: string;
994
+ format?: string;
995
+ formatSupported: boolean;
996
+ formula?: string;
997
+ sharedFormula?: string;
998
+ cached: boolean;
999
+ merge?: string;
1000
+ hidden: boolean;
1001
+ box: CellBox;
1002
+ value: string;
1003
+ }
1004
+ | {
1005
+ type: "Date";
1006
+ ref: string;
1007
+ row: number;
1008
+ col: number;
1009
+ text: string;
1010
+ raw: string;
1011
+ format?: string;
1012
+ formatSupported: boolean;
1013
+ formula?: string;
1014
+ sharedFormula?: string;
1015
+ cached: boolean;
1016
+ merge?: string;
1017
+ hidden: boolean;
1018
+ box: CellBox;
1019
+ value: string;
1020
+ }
1021
+ | {
1022
+ type: "Time";
1023
+ ref: string;
1024
+ row: number;
1025
+ col: number;
1026
+ text: string;
1027
+ raw: string;
1028
+ format?: string;
1029
+ formatSupported: boolean;
1030
+ formula?: string;
1031
+ sharedFormula?: string;
1032
+ cached: boolean;
1033
+ merge?: string;
1034
+ hidden: boolean;
1035
+ box: CellBox;
1036
+ value: string;
1037
+ }
1038
+ | {
1039
+ type: "Blank";
1040
+ ref: string;
1041
+ row: number;
1042
+ col: number;
1043
+ text: string;
1044
+ raw: string;
1045
+ format?: string;
1046
+ formatSupported: boolean;
1047
+ formula?: string;
1048
+ sharedFormula?: string;
1049
+ cached: boolean;
1050
+ merge?: string;
1051
+ hidden: boolean;
1052
+ box: CellBox;
1053
+ };
1054
+
1055
+ /** One selected worksheet's cells, with the sheet facts a reader needs beside them. */
1056
+ export interface SheetCells {
1057
+ sheet: string;
1058
+ /** Position in the workbook, 0-based. */
1059
+ index: number;
1060
+ hidden: boolean;
1061
+ /** The declared `<dimension>`, which a producer may overstate. */
1062
+ dimension?: string;
1063
+ printArea?: string;
1064
+ /** Merged ranges in A1 form. */
1065
+ merges: Array<string>;
1066
+ /**
1067
+ * The sheet frame's size in points: A1 to the last non-empty cell or merged range, with hidden
1068
+ * rows and columns counted or not per `hiddenCells`.
1069
+ */
1070
+ width: number;
1071
+ height: number;
1072
+ /** Points; what a column or row absent from `columns` / `rows` measures. */
1073
+ defaultColumnWidth: number;
1074
+ defaultRowHeight: number;
1075
+ /** Only the columns and rows that differ from the default or are hidden. */
1076
+ columns: Array<SheetColumn>;
1077
+ rows: Array<SheetRow>;
1078
+ warnings: Array<string>;
1079
+ cells: Array<SheetCell>;
1080
+ }
1081
+
1082
+ /** A column whose width differs from the sheet default, or that is hidden. 0-based. */
1083
+ export interface SheetColumn {
1084
+ index: number;
1085
+ /** Points; zero for a hidden column when hidden cells are excluded. */
1086
+ width: number;
1087
+ hidden: boolean;
1088
+ }
1089
+
1090
+ /**
1091
+ * A row whose height differs from the sheet default (auto-fit growth included), or that is
1092
+ * hidden. 0-based.
1093
+ */
1094
+ export interface SheetRow {
1095
+ index: number;
1096
+ /** Points; zero for a hidden row when hidden cells are excluded. */
1097
+ height: number;
1098
+ hidden: boolean;
1099
+ }
1100
+
1101
+ /** The cells of a workbook buffer's selected sheets. */
1102
+ export declare function spreadsheetCells(
1103
+ buffer: Buffer,
1104
+ opts?: SpreadsheetOptions | undefined | null
1105
+ ): Array<SheetCells>;
1106
+
1107
+ export declare function spreadsheetCellsAsync(
1108
+ buffer: Buffer,
1109
+ opts?: SpreadsheetOptions | undefined | null
1110
+ ): Promise<Array<SheetCells>>;
1111
+
1112
+ /** Workbook options shared by `spreadsheetCells` and `layout`. */
1113
+ export interface SpreadsheetOptions {
1114
+ /** Sheet names to include, in workbook order; default: every visible sheet. */
1115
+ sheets?: Array<string>;
1116
+ /** Include hidden sheets (default false). */
1117
+ hiddenSheets?: boolean;
1118
+ /**
1119
+ * Cells in hidden rows and columns. For `spreadsheetCells` the default is true: they are listed
1120
+ * with `hidden: true`. For `layout` the default is false: zero extent and omitted; true gives
1121
+ * them their real extents back.
1122
+ */
1123
+ hiddenCells?: boolean;
1124
+ }
1125
+
1126
+ export interface StringField {
1127
+ value: string;
1128
+ /** The exact source text the value was derived from. */
1129
+ text: string;
1130
+ confidence: number;
1131
+ span?: FieldSpan;
1132
+ }
202
1133
 
203
1134
  export interface StructuredPageText {
204
- page: number
205
- header: string
206
- body: string
207
- footer: string
1135
+ page: number;
1136
+ header: string;
1137
+ body: string;
1138
+ footer: string;
1139
+ }
1140
+
1141
+ export interface TaxDetail {
1142
+ rate?: NumberField;
1143
+ amount?: MoneyField;
1144
+ base?: MoneyField;
1145
+ category?: StringField;
1146
+ }
1147
+
1148
+ /**
1149
+ * Words sharing a baseline band, left to right. `firstWord` / `wordCount`
1150
+ * address a contiguous slice of `PageLayout.words`.
1151
+ */
1152
+ export interface TextLine {
1153
+ text: string;
1154
+ x0: number;
1155
+ y0: number;
1156
+ x1: number;
1157
+ y1: number;
1158
+ firstWord: number;
1159
+ wordCount: number;
1160
+ }
1161
+
1162
+ /**
1163
+ * The deepest tier of the OCR cascade that ran for a page: `Native` when the
1164
+ * page's own glyphs were the page, `Ocr` when its embedded rasters were OCR'd,
1165
+ * `Rendered` when the page was rasterised and OCR'd (only with the `render`
1166
+ * feature). A hybrid page keeps its native words alongside the OCR words and
1167
+ * still reports the OCR tier, even when that tier added no words; tell the
1168
+ * two apart by `confidence`, which only OCR words carry, and see the "native
1169
+ * words kept" warnings. `Spreadsheet` is the logical page of a workbook sheet,
1170
+ * laid out from column widths and row heights. Present in every build.
1171
+ */
1172
+ export type TextSource = "Native" | "Ocr" | "Rendered" | "Spreadsheet";
1173
+
1174
+ /** One word with its box in PDF user space (points, y up). */
1175
+ export interface TextWord {
1176
+ text: string;
1177
+ x0: number;
1178
+ y0: number;
1179
+ x1: number;
1180
+ y1: number;
1181
+ /** Index into `PageLayout.lines`. */
1182
+ line: number;
1183
+ /** Native only: font size in user space (after the CTM), in points. */
1184
+ fontSize?: number;
1185
+ /** Native only: base font name with any subset prefix stripped. */
1186
+ fontName?: string;
1187
+ /**
1188
+ * Native: from the font descriptor and name; absent when the font gives no weight evidence
1189
+ * (anonymous names such as `CIDFont+F1`) and for OCR words.
1190
+ */
1191
+ bold?: boolean;
1192
+ italic?: boolean;
1193
+ /** Native only: true when the word is set in a barcode font, so its glyphs are bars, not letters. */
1194
+ symbolic?: boolean;
1195
+ /** OCR only: Tesseract word confidence, 0..1. */
1196
+ confidence?: number;
1197
+ /**
1198
+ * Spreadsheet only: the reference of the cell this word was laid out from (`"C3"`); the
1199
+ * anchor for a merged range.
1200
+ */
1201
+ cell?: string;
208
1202
  }
209
1203
 
210
- export type TextSource = 'Native'|
211
- 'Ocr'|
212
- 'Rendered';
1204
+ /**
1205
+ * A logical field with no widget placed on any page. Keeps the full field payload; only
1206
+ * geometry and per-widget state are absent.
1207
+ */
1208
+ export interface UnplacedFormField {
1209
+ /**
1210
+ * `"N G obj"`, or `"<parent fieldObjectId>/kid I"` / `"/Fields I"` when the field
1211
+ * dictionary itself is written inline.
1212
+ */
1213
+ fieldObjectId: string;
1214
+ name: string;
1215
+ partialName: string;
1216
+ type: FormFieldType;
1217
+ value?: string;
1218
+ /** Multi-select list boxes. */
1219
+ values?: Array<string>;
1220
+ defaultValue?: string;
1221
+ tooltip?: string;
1222
+ mappingName?: string;
1223
+ /** Choice fields. */
1224
+ options?: Array<ChoiceOption>;
1225
+ maxLen?: number;
1226
+ readOnly: boolean;
1227
+ required: boolean;
1228
+ noExport: boolean;
1229
+ hasActions: boolean;
1230
+ multiline: boolean;
1231
+ password: boolean;
1232
+ comb: boolean;
1233
+ richText: boolean;
1234
+ editable: boolean;
1235
+ multiSelect: boolean;
1236
+ /** Signature fields: signature data present in /V (not cryptographic validation). */
1237
+ signed: boolean;
1238
+ }