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