@d0paminedriven/pdfdown-ocr 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -113,7 +113,9 @@ export declare class PdfDown {
113
113
  layout(): Array<PageLayout>;
114
114
  layoutAsync(): Promise<Array<PageLayout>>;
115
115
  imagesPerPage(): Array<PageImage>;
116
+ imageCount(): number; // counted without decoding
116
117
  imagesPerPageAsync(): Promise<Array<PageImage>>;
118
+ imageCountAsync(): Promise<number>;
117
119
  annotationsPerPage(): Array<PageAnnotation>;
118
120
  annotationsPerPageAsync(): Promise<Array<PageAnnotation>>;
119
121
  formFieldsPerPage(): Array<PageFormField>;
@@ -177,6 +179,12 @@ export interface PdfDocumentOcr {
177
179
  producer?: string;
178
180
  creationDate?: string;
179
181
  modificationDate?: string;
182
+ title?: string; // what the document says of itself, as the file writes it
183
+ author?: string;
184
+ subject?: string;
185
+ keywords?: string; // one string, usually a list separated by commas or semicolons
186
+ language?: string; // the language the catalog names for the text: en-US
187
+ isEncrypted: boolean; // encrypted on disk, whether or not it opened without a password
180
188
  pageBoxes: Array<PageBox>;
181
189
  totalImages: number;
182
190
  totalAnnotations: number;
@@ -297,7 +305,7 @@ Both methods extract everything from a PDF in a single call. The difference is h
297
305
  2. **Ocr** -- the page's embedded raster images are OCR'd and each Tesseract word box is mapped through the image's `Do` placement onto the page. Words carry `confidence` (0..1) instead of font metadata.
298
306
  3. **Rendered** -- with PDFium, the page is rasterised as displayed at `renderDpi` and OCR'd; word boxes are mapped back onto the page box in the page's own frame, the one native words use, and `contentRotation` includes `/Rotate`.
299
307
 
300
- Copier and fax scans (`CCITTFaxDecode`, Group 3 and Group 4) and bi-level scans kept as `JBIG2Decode` images or stencil masks are decoded in pure Rust, so they are read at tier 2 without PDFium. When the upright pass scores a mean Tesseract confidence under 55 (a landscape sheet scanned in portrait comes back as punctuation at 35-45), the raster is OCR'd again turned 90°, 270° and 180° and the best orientation wins. The page then reports `contentRotation`, the turn carrying the most confident OCR text across its images (the tiles of a tiled scan vote together), and every word, line and image placement is expressed in that turned frame, with `width`/`height` swapped for a quarter turn. A warning names each turned image with more than a few words and who decided the turn (the orientation detector or the confidence retry); such an image that reads upright at a different turn than the page is named too, since its words read sideways in the page frame. The render tier reads the page as displayed, so on a `/Rotate` page its `contentRotation` includes `/Rotate`; for any page, displayed coordinates are the reported frame turned clockwise by `rotate - contentRotation`. The same retry applies to `extractTextWithOcrPerPage`.
308
+ Copier and fax scans (`CCITTFaxDecode`, Group 3 and Group 4) and bi-level scans kept as `JBIG2Decode` images or stencil masks are decoded in pure Rust, so they are read at tier 2 without PDFium. A page that paints two or more of these one-bit images has them painted onto one raster, where the page puts them, and read in one pass: copiers that save a scan as mixed raster content split its text into a stencil mask for each ink color, often dozens to a page, and a word that falls across two masks is then read whole. Masks painted in a light color go on a raster of their own, since white lettering and the dark shape it is cut out of would otherwise merge. When the upright pass scores a mean Tesseract confidence under 55 (a landscape sheet scanned in portrait comes back as punctuation at 35-45), the raster is OCR'd again turned 90°, 270° and 180° and the best orientation wins. The page then reports `contentRotation`, the turn carrying the most confident OCR text across its images (the tiles of a tiled scan vote together), and every word, line and image placement is expressed in that turned frame, with `width`/`height` swapped for a quarter turn. A warning names each turned image with more than a few words and who decided the turn (the orientation detector or the confidence retry); such an image that reads upright at a different turn than the page is named too, since its words read sideways in the page frame. The render tier reads the page as displayed, so on a `/Rotate` page its `contentRotation` includes `/Rotate`; for any page, displayed coordinates are the reported frame turned clockwise by `rotate - contentRotation`. The same retry applies to `extractTextWithOcrPerPage`.
301
309
 
302
310
  ```typescript
303
311
  import { readFileSync } from "node:fs";
@@ -345,7 +353,7 @@ A `pdfiumPath` passed after that first look is ignored, so pass it on your first
345
353
 
346
354
  ## How it works
347
355
 
348
- 1. **Text extraction (the cascade):** Each page is read natively first. A page goes to OCR when its native text is under `minTextLength` non-whitespace characters, or when its native words cover under 2% of the page while images cover more than half of it or the content stream paints 200 or more path operators (a scan with a stamp on it, or text printed as outlines); a few words on an otherwise empty cover sheet stay native. Tier 2 decodes the embedded rasters and feeds them to Tesseract; tier 3, with PDFium, renders the page when the page has no rasters but painted paths, or when tier 2 found nothing or only a weak result on a path-heavy page. On a hybrid page the native words stay and OCR adds only what they do not cover (duplicates dropped at IoU > 0.5); `source` reports the deepest tier that ran (`Native`, `Ocr` or `Rendered`), even when OCR added no words; OCR words carry `confidence`, native words do not, and a warning counts the native words kept. Orientation is decided per raster: an upright pass with a mean Tesseract confidence of 80 or more stands; below that the raster is shown to Tesseract's orientation detector (OSD), and only when OSD cannot decide and the upright pass scored under 55 is the raster read again at 90°, 270° and 180° with the best score winning.
356
+ 1. **Text extraction (the cascade):** Each page is read natively first. A page goes to OCR when its native text is under `minTextLength` non-whitespace characters, or when its native words cover under 2% of the page while images cover more than half of it or the content stream paints 200 or more path operators (a scan with a stamp on it, or text printed as outlines); a few words on an otherwise empty cover sheet stay native. Tier 2 decodes the embedded rasters and feeds them to Tesseract, the page's one-bit images merged onto one raster (two when some are painted light) and every other image by itself; tier 3, with PDFium, renders the page when the page has no rasters but painted paths, or when tier 2 found nothing or only a weak result on a path-heavy page. On a hybrid page the native words stay and OCR adds only what they do not cover (duplicates dropped at IoU > 0.5); `source` reports the deepest tier that ran (`Native`, `Ocr` or `Rendered`), even when OCR added no words; OCR words carry `confidence`, native words do not, and a warning counts the native words kept. Orientation is decided per raster: an upright pass with a mean Tesseract confidence of 80 or more stands; below that the raster is shown to Tesseract's orientation detector (OSD), and only when OSD cannot decide and the upright pass scored under 55 is the raster read again at 90°, 270° and 180° with the best score winning.
349
357
 
350
358
  2. **Structured text:** After text extraction, repeated header/footer lines are detected across pages using frequency analysis (requires 3+ pages). Each page's text is split into `header`, `body`, and `footer` sections. For OCR results, the `source` tag is preserved so you know whether each page's content came from native extraction or OCR.
351
359
 
package/index.d.ts CHANGED
@@ -16,6 +16,11 @@ export declare class PdfDown {
16
16
  textPerPage(): Array<PageText>
17
17
  imagesPerPage(): Array<PageImage>
18
18
  annotationsPerPage(): Array<PageAnnotation>
19
+ /**
20
+ * How many images the pages paint. Nothing is decoded, so this costs far less than
21
+ * counting what `imagesPerPage` returns.
22
+ */
23
+ imageCount(): number
19
24
  metadata(): PdfMeta
20
25
  /** Positioned words and lines per page, from the page's content stream (native text only). */
21
26
  layout(): Array<PageLayout>
@@ -31,6 +36,7 @@ export declare class PdfDown {
31
36
  textPerPageAsync(): Promise<Array<PageText>>
32
37
  imagesPerPageAsync(): Promise<Array<PageImage>>
33
38
  annotationsPerPageAsync(): Promise<Array<PageAnnotation>>
39
+ imageCountAsync(): Promise<number>
34
40
  metadataAsync(): Promise<PdfMeta>
35
41
  document(): PdfDocument
36
42
  documentAsync(): Promise<PdfDocument>
@@ -533,6 +539,19 @@ export interface PdfDocument {
533
539
  producer?: string
534
540
  creationDate?: string
535
541
  modificationDate?: string
542
+ /**
543
+ * What the document says of itself in its Info dictionary, as the file writes it. Absent
544
+ * when the file does not say.
545
+ */
546
+ title?: string
547
+ author?: string
548
+ subject?: string
549
+ /** One string, which is usually a list separated by commas or semicolons. */
550
+ keywords?: string
551
+ /** The language the catalog names for the document's text: `en-US`. */
552
+ language?: string
553
+ /** The file was encrypted on disk, whether or not it opened without a password. */
554
+ isEncrypted: boolean
536
555
  pageBoxes: Array<PageBox>
537
556
  totalImages: number
538
557
  totalAnnotations: number
@@ -560,6 +579,19 @@ export interface PdfDocumentOcr {
560
579
  producer?: string
561
580
  creationDate?: string
562
581
  modificationDate?: string
582
+ /**
583
+ * What the document says of itself in its Info dictionary, as the file writes it. Absent
584
+ * when the file does not say.
585
+ */
586
+ title?: string
587
+ author?: string
588
+ subject?: string
589
+ /** One string, which is usually a list separated by commas or semicolons. */
590
+ keywords?: string
591
+ /** The language the catalog names for the document's text: `en-US`. */
592
+ language?: string
593
+ /** The file was encrypted on disk, whether or not it opened without a password. */
594
+ isEncrypted: boolean
563
595
  pageBoxes: Array<PageBox>
564
596
  totalImages: number
565
597
  totalAnnotations: number
@@ -577,6 +609,14 @@ export interface PdfDocumentOcr {
577
609
 
578
610
  export declare function pdfDocumentOcrAsync(buffer: Buffer, opts?: OcrOptions | undefined | null): Promise<PdfDocumentOcr>
579
611
 
612
+ /**
613
+ * How many images the document's pages paint. Nothing is decoded, so this costs far less
614
+ * than counting what `extractImagesPerPage` returns.
615
+ */
616
+ export declare function pdfImageCount(buffer: Buffer): number
617
+
618
+ export declare function pdfImageCountAsync(buffer: Buffer): Promise<number>
619
+
580
620
  export interface PdfMeta {
581
621
  pageCount: number
582
622
  version: string
@@ -585,6 +625,19 @@ export interface PdfMeta {
585
625
  producer?: string
586
626
  creationDate?: string
587
627
  modificationDate?: string
628
+ /**
629
+ * What the document says of itself in its Info dictionary, as the file writes it. Absent
630
+ * when the file does not say.
631
+ */
632
+ title?: string
633
+ author?: string
634
+ subject?: string
635
+ /** One string, which is usually a list separated by commas or semicolons. */
636
+ keywords?: string
637
+ /** The language the catalog names for the document's text: `en-US`. */
638
+ language?: string
639
+ /** The file was encrypted on disk, whether or not it opened without a password. */
640
+ isEncrypted: boolean
588
641
  pageBoxes: Array<PageBox>
589
642
  /** AcroForm facts; present when `/AcroForm` exists or orphan widgets were found. */
590
643
  form?: FormInfo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d0paminedriven/pdfdown-ocr",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "Rust powered PDF extraction for Node with OCR and optional rendering (requires system tesseract).",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,8 +39,8 @@
39
39
  "node": ">=24"
40
40
  },
41
41
  "optionalDependencies": {
42
- "@d0paminedriven/pdfdown-ocr-darwin-arm64": "0.16.0",
43
- "@d0paminedriven/pdfdown-ocr-linux-x64-gnu": "0.16.0",
44
- "@d0paminedriven/pdfdown-ocr-linux-arm64-gnu": "0.16.0"
42
+ "@d0paminedriven/pdfdown-ocr-darwin-arm64": "0.18.0",
43
+ "@d0paminedriven/pdfdown-ocr-linux-x64-gnu": "0.18.0",
44
+ "@d0paminedriven/pdfdown-ocr-linux-arm64-gnu": "0.18.0"
45
45
  }
46
46
  }
@@ -97,8 +97,8 @@ function requireNative() {
97
97
  try {
98
98
  const binding = require('@d0paminedriven/pdfdown-ocr-android-arm64')
99
99
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-android-arm64/package.json').version
100
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
100
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
101
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
102
102
  }
103
103
  return binding
104
104
  } catch (e) {
@@ -113,8 +113,8 @@ function requireNative() {
113
113
  try {
114
114
  const binding = require('@d0paminedriven/pdfdown-ocr-android-arm-eabi')
115
115
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-android-arm-eabi/package.json').version
116
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
117
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
116
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
117
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
118
118
  }
119
119
  return binding
120
120
  } catch (e) {
@@ -134,8 +134,8 @@ function requireNative() {
134
134
  try {
135
135
  const binding = require('@d0paminedriven/pdfdown-ocr-win32-x64-gnu')
136
136
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-x64-gnu/package.json').version
137
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
138
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
139
139
  }
140
140
  return binding
141
141
  } catch (e) {
@@ -150,8 +150,8 @@ function requireNative() {
150
150
  try {
151
151
  const binding = require('@d0paminedriven/pdfdown-ocr-win32-x64-msvc')
152
152
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-x64-msvc/package.json').version
153
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
154
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
153
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
154
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
155
155
  }
156
156
  return binding
157
157
  } catch (e) {
@@ -167,8 +167,8 @@ function requireNative() {
167
167
  try {
168
168
  const binding = require('@d0paminedriven/pdfdown-ocr-win32-ia32-msvc')
169
169
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-ia32-msvc/package.json').version
170
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
170
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
172
  }
173
173
  return binding
174
174
  } catch (e) {
@@ -183,8 +183,8 @@ function requireNative() {
183
183
  try {
184
184
  const binding = require('@d0paminedriven/pdfdown-ocr-win32-arm64-msvc')
185
185
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-win32-arm64-msvc/package.json').version
186
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
187
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
186
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
187
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
188
188
  }
189
189
  return binding
190
190
  } catch (e) {
@@ -202,8 +202,8 @@ function requireNative() {
202
202
  try {
203
203
  const binding = require('@d0paminedriven/pdfdown-ocr-darwin-universal')
204
204
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-darwin-universal/package.json').version
205
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
205
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
206
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
207
207
  }
208
208
  return binding
209
209
  } catch (e) {
@@ -218,8 +218,8 @@ function requireNative() {
218
218
  try {
219
219
  const binding = require('@d0paminedriven/pdfdown-ocr-darwin-x64')
220
220
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-darwin-x64/package.json').version
221
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
221
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
222
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
223
  }
224
224
  return binding
225
225
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@d0paminedriven/pdfdown-ocr-darwin-arm64')
236
236
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-darwin-arm64/package.json').version
237
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -254,8 +254,8 @@ function requireNative() {
254
254
  try {
255
255
  const binding = require('@d0paminedriven/pdfdown-ocr-freebsd-x64')
256
256
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-freebsd-x64/package.json').version
257
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
257
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
258
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
259
259
  }
260
260
  return binding
261
261
  } catch (e) {
@@ -270,8 +270,8 @@ function requireNative() {
270
270
  try {
271
271
  const binding = require('@d0paminedriven/pdfdown-ocr-freebsd-arm64')
272
272
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-freebsd-arm64/package.json').version
273
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
274
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
273
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
274
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
275
275
  }
276
276
  return binding
277
277
  } catch (e) {
@@ -286,8 +286,8 @@ function requireNative() {
286
286
  try {
287
287
  const binding = require('@d0paminedriven/pdfdown-ocr-freebsd-ppc64')
288
288
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-freebsd-ppc64/package.json').version
289
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
290
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
289
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
290
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
291
291
  }
292
292
  return binding
293
293
  } catch (e) {
@@ -307,8 +307,8 @@ function requireNative() {
307
307
  try {
308
308
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-x64-musl')
309
309
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-x64-musl/package.json').version
310
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
311
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
312
312
  }
313
313
  return binding
314
314
  } catch (e) {
@@ -323,8 +323,8 @@ function requireNative() {
323
323
  try {
324
324
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-x64-gnu')
325
325
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-x64-gnu/package.json').version
326
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
327
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
327
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
328
328
  }
329
329
  return binding
330
330
  } catch (e) {
@@ -341,8 +341,8 @@ function requireNative() {
341
341
  try {
342
342
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm64-musl')
343
343
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm64-musl/package.json').version
344
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
345
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
346
346
  }
347
347
  return binding
348
348
  } catch (e) {
@@ -357,8 +357,8 @@ function requireNative() {
357
357
  try {
358
358
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm64-gnu')
359
359
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm64-gnu/package.json').version
360
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
361
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
361
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
362
362
  }
363
363
  return binding
364
364
  } catch (e) {
@@ -375,8 +375,8 @@ function requireNative() {
375
375
  try {
376
376
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm-musleabihf')
377
377
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm-musleabihf/package.json').version
378
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
379
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
380
380
  }
381
381
  return binding
382
382
  } catch (e) {
@@ -391,8 +391,8 @@ function requireNative() {
391
391
  try {
392
392
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-arm-gnueabihf')
393
393
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-arm-gnueabihf/package.json').version
394
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
395
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
395
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
396
396
  }
397
397
  return binding
398
398
  } catch (e) {
@@ -409,8 +409,8 @@ function requireNative() {
409
409
  try {
410
410
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-loong64-musl')
411
411
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-loong64-musl/package.json').version
412
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
413
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
414
414
  }
415
415
  return binding
416
416
  } catch (e) {
@@ -425,8 +425,8 @@ function requireNative() {
425
425
  try {
426
426
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-loong64-gnu')
427
427
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-loong64-gnu/package.json').version
428
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
429
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
429
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
430
  }
431
431
  return binding
432
432
  } catch (e) {
@@ -443,8 +443,8 @@ function requireNative() {
443
443
  try {
444
444
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-musl')
445
445
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-musl/package.json').version
446
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
447
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
446
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
447
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
448
448
  }
449
449
  return binding
450
450
  } catch (e) {
@@ -459,8 +459,8 @@ function requireNative() {
459
459
  try {
460
460
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-gnu')
461
461
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-riscv64-gnu/package.json').version
462
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
463
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
462
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
463
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
464
464
  }
465
465
  return binding
466
466
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-ppc64-gnu')
478
478
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-ppc64-gnu/package.json').version
479
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@d0paminedriven/pdfdown-ocr-linux-s390x-gnu')
494
494
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-linux-s390x-gnu/package.json').version
495
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -512,8 +512,8 @@ function requireNative() {
512
512
  try {
513
513
  const binding = require('@d0paminedriven/pdfdown-ocr-openharmony-arm64')
514
514
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-openharmony-arm64/package.json').version
515
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
515
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
516
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
517
517
  }
518
518
  return binding
519
519
  } catch (e) {
@@ -528,8 +528,8 @@ function requireNative() {
528
528
  try {
529
529
  const binding = require('@d0paminedriven/pdfdown-ocr-openharmony-x64')
530
530
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-openharmony-x64/package.json').version
531
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
532
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
531
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
532
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
533
533
  }
534
534
  return binding
535
535
  } catch (e) {
@@ -544,8 +544,8 @@ function requireNative() {
544
544
  try {
545
545
  const binding = require('@d0paminedriven/pdfdown-ocr-openharmony-arm')
546
546
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-openharmony-arm/package.json').version
547
- if (bindingPackageVersion !== '0.16.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
548
- throw new Error(`Native binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
547
+ if (bindingPackageVersion !== '0.18.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
548
+ throw new Error(`Native binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
549
549
  }
550
550
  return binding
551
551
  } catch (e) {
@@ -686,8 +686,8 @@ if (!nativeBinding || forceWasi) {
686
686
  if (!candidateFailed) {
687
687
  if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
688
688
  const bindingPackageVersion = require('@d0paminedriven/pdfdown-ocr-wasm32-wasi/package.json').version
689
- if (bindingPackageVersion !== '0.16.0') {
690
- throw new Error(`WASI binding package version mismatch, expected 0.16.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
689
+ if (bindingPackageVersion !== '0.18.0') {
690
+ throw new Error(`WASI binding package version mismatch, expected 0.18.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
691
691
  }
692
692
  }
693
693
  wasiBinding = require('@d0paminedriven/pdfdown-ocr-wasm32-wasi')
@@ -773,7 +773,7 @@ if (
773
773
  }
774
774
  }
775
775
 
776
- const { PdfDown, attachments, attachmentsAsync, BoxType, capabilities, CurrencySource, DateOrder, EInvoiceStandard, extractAnnotationsPerPage, extractAnnotationsPerPageAsync, extractFormFieldsPerPage, extractFormFieldsPerPageAsync, extractImagesPerPage, extractImagesPerPageAsync, extractInvoice, extractInvoiceAsync, extractLayoutWithOcrPerPage, extractLayoutWithOcrPerPageAsync, extractStructuredTextPerPage, extractStructuredTextPerPageAsync, extractTextPerPage, extractTextPerPageAsync, extractTextWithOcrPerPage, extractTextWithOcrPerPageAsync, InvoiceDocumentType, invoiceFromLayout, invoiceFromLayoutAsync, InvoiceSource, layoutPerPage, layoutPerPageAsync, pdfDocument, pdfDocumentAsync, pdfDocumentOcr, pdfDocumentOcrAsync, pdfMetadata, pdfMetadataAsync, RenderMode, renderPagesAsync, TextSource } = nativeBinding
776
+ const { PdfDown, attachments, attachmentsAsync, BoxType, capabilities, CurrencySource, DateOrder, EInvoiceStandard, extractAnnotationsPerPage, extractAnnotationsPerPageAsync, extractFormFieldsPerPage, extractFormFieldsPerPageAsync, extractImagesPerPage, extractImagesPerPageAsync, extractInvoice, extractInvoiceAsync, extractLayoutWithOcrPerPage, extractLayoutWithOcrPerPageAsync, extractStructuredTextPerPage, extractStructuredTextPerPageAsync, extractTextPerPage, extractTextPerPageAsync, extractTextWithOcrPerPage, extractTextWithOcrPerPageAsync, InvoiceDocumentType, invoiceFromLayout, invoiceFromLayoutAsync, InvoiceSource, layoutPerPage, layoutPerPageAsync, pdfDocument, pdfDocumentAsync, pdfDocumentOcr, pdfDocumentOcrAsync, pdfImageCount, pdfImageCountAsync, pdfMetadata, pdfMetadataAsync, RenderMode, renderPagesAsync, TextSource } = nativeBinding
777
777
  export { PdfDown }
778
778
  export { attachments }
779
779
  export { attachmentsAsync }
@@ -808,6 +808,8 @@ export { pdfDocument }
808
808
  export { pdfDocumentAsync }
809
809
  export { pdfDocumentOcr }
810
810
  export { pdfDocumentOcrAsync }
811
+ export { pdfImageCount }
812
+ export { pdfImageCountAsync }
811
813
  export { pdfMetadata }
812
814
  export { pdfMetadataAsync }
813
815
  export { RenderMode }