@procedures/ocr 0.68.9 → 0.68.11

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +35 -2
  3. package/dist/index.d.ts +1 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/index.js.map +1 -1
  7. package/dist/module.d.ts.map +1 -1
  8. package/dist/module.js +20 -2
  9. package/dist/module.js.map +1 -1
  10. package/dist/parse.d.ts +2 -0
  11. package/dist/parse.d.ts.map +1 -1
  12. package/dist/parse.js +2 -0
  13. package/dist/parse.js.map +1 -1
  14. package/dist/pdfinfo.d.ts +14 -0
  15. package/dist/pdfinfo.d.ts.map +1 -0
  16. package/dist/pdfinfo.js +20 -0
  17. package/dist/pdfinfo.js.map +1 -0
  18. package/dist/procedures/ocr/index.d.ts +1 -0
  19. package/dist/procedures/ocr/index.d.ts.map +1 -1
  20. package/dist/procedures/ocr/index.js +1 -0
  21. package/dist/procedures/ocr/index.js.map +1 -1
  22. package/dist/procedures/ocr/pageCount.d.ts +20 -0
  23. package/dist/procedures/ocr/pageCount.d.ts.map +1 -0
  24. package/dist/procedures/ocr/pageCount.js +28 -0
  25. package/dist/procedures/ocr/pageCount.js.map +1 -0
  26. package/dist/programs.d.ts +28 -2
  27. package/dist/programs.d.ts.map +1 -1
  28. package/dist/programs.js +30 -5
  29. package/dist/programs.js.map +1 -1
  30. package/dist/run.d.ts +2 -2
  31. package/dist/run.d.ts.map +1 -1
  32. package/dist/run.js +3 -0
  33. package/dist/run.js.map +1 -1
  34. package/dist/table.d.ts +59 -0
  35. package/dist/table.d.ts.map +1 -0
  36. package/dist/table.js +152 -0
  37. package/dist/table.js.map +1 -0
  38. package/dist/types.d.ts +12 -0
  39. package/dist/types.d.ts.map +1 -1
  40. package/dist/types.js +7 -0
  41. package/dist/types.js.map +1 -1
  42. package/package.json +4 -3
  43. package/src/index.ts +1 -1
  44. package/src/module.ts +34 -2
  45. package/src/parse.ts +2 -0
  46. package/src/pdfinfo.ts +19 -0
  47. package/src/procedures/ocr/index.ts +1 -0
  48. package/src/procedures/ocr/pageCount.ts +32 -0
  49. package/src/programs.ts +44 -5
  50. package/src/run.ts +4 -2
  51. package/src/table.ts +188 -0
  52. package/src/types.ts +25 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @procedures/ocr
2
2
 
3
+ ## 0.68.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 0d9a5e4: The new procedure `ocr.pageCount` gives the number of pages of a PDF file. A caller can then read each page with `ocr.page`, from page 1 to that number.
8
+
9
+ - The count comes from `pdfinfo` of Poppler, through `shell.run` with argv. `ocr.page` uses the same Poppler programs, so each page in the count is a valid page of `ocr.page`.
10
+ - The input is `{ file, timeout? }`, and the output is `{ pages }`. The effects are the effects of `ocr.image`: it reads `fs` and `process`, and it writes `process`.
11
+ - The new exports are `ocrPageCount`, `pdfinfoArgs`, `parsePdfinfoPages` (also on the entry `./parse`), `PDFINFO`, `OcrPageCountInput`, `OcrPageCountOutput` and their schemas.
12
+ - The search finds `pdfinfo` as the other programs of Poppler: `executables.pdfinfo`, then `PDFINFO_EXE`, then `POPPLER_PATH`, the install folders and the `PATH`.
13
+
14
+ PATCH: before 1.0.0, a backward-compatible feature raises PATCH. The other procedures do not change.
15
+ - @procedures/client@0.68.11
16
+ - @procedures/shell@0.68.11
17
+
18
+ ## 0.68.10
19
+
20
+ ### Patch Changes
21
+
22
+ - ee0504e: The new pure function `tableOfText` gives the rows and the columns of a table from the boxes of its words. Each row has one cell for each column, with its text, its confidence and its box. A right-aligned column of numbers stays one column.
23
+ - 4b926ae: When `pdftotext` or `pdftoppm` fails and its output comes from Xpdf, not from Poppler, the call fails with an `OcrToolMissingError` with `other: "Xpdf"`. The error tells you to install Poppler or to set `POPPLER_PATH`. Before, the call failed with the usage text of Xpdf. The new field `others` of a `ProgramSpec` lists the different programs with the same name, and the new export `XPDF` describes Xpdf.
24
+ - Updated dependencies [c2899fe]
25
+ - @procedures/shell@0.68.10
26
+ - @procedures/client@0.68.10
27
+
3
28
  ## 0.68.9
4
29
 
5
30
  ### Patch Changes
package/README.md CHANGED
@@ -6,7 +6,7 @@ The text of a PDF page or of an image, as lines and words. Each line and each wo
6
6
 
7
7
  The package uses the programs of the host. It does not download a program:
8
8
 
9
- - `pdftotext` and `pdftoppm` of Poppler, for the PDF pages.
9
+ - `pdftotext`, `pdftoppm` and `pdfinfo` of Poppler, for the PDF pages.
10
10
  - `tesseract` 4 or later, the first OCR engine.
11
11
 
12
12
  Each program starts as argv through the procedure `shell.run` of `@procedures/shell`. No shell starts.
@@ -31,6 +31,7 @@ Install the programs:
31
31
  |---|---|---|
32
32
  | `ocr.page` | It gives the text of one page of a PDF file. The boxes are in PDF points. | It reads `fs` and `process`. It writes `fs` (a temporary image) and `process`. |
33
33
  | `ocr.image` | It reads the text of an image file with the OCR engine. The boxes are in the pixels of the image. | It reads `fs` and `process`. It writes `process`. |
34
+ | `ocr.pageCount` | It gives the number of pages of a PDF file, from `pdfinfo`. | It reads `fs` and `process`. It writes `process`. |
34
35
 
35
36
  `ocr.page` has three modes:
36
37
 
@@ -47,11 +48,21 @@ const page = await outputValue(await invokePath(["ocr", "page"], { file: "report
47
48
  // { page: 2, source: "text-layer", unit: "pt", width: 612, height: 792, text: "...", confidence: 1, lines: [...] }
48
49
  ```
49
50
 
51
+ To read each page of a file, get the number of pages with `ocr.pageCount` first. The pages of `ocr.page` are the numbers from 1 to that number.
52
+
53
+ ```ts
54
+ const { pages } = await outputValue(await invokePath(["ocr", "pageCount"], { file: "report.pdf" }, { registry }));
55
+ for (let page = 1; page <= pages; page += 1) {
56
+ const text = await outputValue(await invokePath(["ocr", "page"], { file: "report.pdf", page }, { registry }));
57
+ }
58
+ ```
59
+
50
60
  From the `mark` CLI:
51
61
 
52
62
  ```sh
53
63
  mark ocr page report.pdf --page 2
54
64
  mark ocr image photo.png --language eng+deu
65
+ mark ocr pageCount report.pdf
55
66
  ```
56
67
 
57
68
  ## A page on its side
@@ -71,6 +82,24 @@ const scan = await outputValue(await invokePath(["ocr", "page"], { file: "auctio
71
82
 
72
83
  The function `turnText(text, turn)` of the parsers does step 3 for a text from another source.
73
84
 
85
+ ## A table
86
+
87
+ OCR gives words and lines, not cells. The pure function `tableOfText` gives the cells of a table from the boxes of its words:
88
+
89
+ 1. Two words are in one row when the vertical centers of their boxes are near.
90
+ 2. In a row, a wide gap between two words starts a new cell.
91
+ 3. A column starts at an x position where many rows start a cell. A right-aligned column of numbers has starts that are far apart. Its cells end at the same x, so it stays one column.
92
+ 4. Each word goes to the column that holds the center of its box.
93
+
94
+ ```ts
95
+ import { tableOfText } from "@procedures/ocr/parse";
96
+
97
+ const table = tableOfText(scan, { minShare: 0.25 });
98
+ const prices = table.rows.map((row) => row.cells[3]?.text ?? null);
99
+ ```
100
+
101
+ Each row has one cell for each column, or `null` when the row has no word in that column. Each cell has its `text`, its `confidence`, its `box` and its `words`. The tolerances are shares of the median height of the words, so the same options work for pixels and for points. Give the words of one table only: a title above the table becomes a row too.
102
+
74
103
  ## The result
75
104
 
76
105
  Each result has `unit`, `width`, `height`, `text`, `confidence` and `lines`. Each line has `text`, `confidence`, `box` and `words`. Each word has `text`, `confidence` and `box`.
@@ -92,13 +121,15 @@ const registry = createRegistry(createOcrModule({ executables: { tesseract: "/op
92
121
  The search examines these paths, in this order:
93
122
 
94
123
  1. The `executables` option of `createOcrModule`.
95
- 2. The environment variable of the program: `TESSERACT_EXE`, `PDFTOTEXT_EXE` or `PDFTOPPM_EXE`.
124
+ 2. The environment variable of the program: `TESSERACT_EXE`, `PDFTOTEXT_EXE`, `PDFTOPPM_EXE` or `PDFINFO_EXE`.
96
125
  3. For Poppler, the folder of `POPPLER_PATH`.
97
126
  4. The install folders: `Tesseract-OCR` and `poppler\Library\bin` in the program files folders of Windows, and the Homebrew folders of macOS.
98
127
  5. The folders of the `PATH`.
99
128
 
100
129
  When the search finds no program, the call fails with an `OcrToolMissingError`. The error has the name of the program (`tool`), the paths that the search examined (`searched`) and the code `OCR_TOOL_MISSING`. A program that does not start gives the same error.
101
130
 
131
+ Xpdf has programs with the names `pdftotext` and `pdftoppm`, but not the options of Poppler. For example, Git for Windows puts the `pdftotext` of Xpdf on the `PATH`. When a run fails and its output comes from Xpdf, the call fails with an `OcrToolMissingError` with `other: "Xpdf"`. The error tells you to install Poppler or to set `POPPLER_PATH`. The field `others` of a `ProgramSpec` lists these different programs with the same name.
132
+
102
133
  ## The parsers
103
134
 
104
135
  The parsers start no process and read no file. The root and the entry `@procedures/ocr/parse` export them. A browser can also load the entry `./parse`.
@@ -106,7 +137,9 @@ The parsers start no process and read no file. The root and the entry `@procedur
106
137
  - `parseTesseractTsv(tsv)` reads the TSV output of tesseract (`tesseract <image> stdout tsv`).
107
138
  - `parsePdftotextBbox(xhtml)` reads the output of `pdftotext -bbox-layout` for one page.
108
139
  - `parseTesseractOsd(output)` reads the orientation output of tesseract (`tesseract <image> stdout --psm 0`).
140
+ - `parsePdfinfoPages(output)` gives the number of pages from the output of `pdfinfo <file>`.
109
141
  - `turnText(text, turn)` turns each box, the width and the height by 0, 90, 180 or 270 degrees in the clock direction.
142
+ - `tableOfText(text, options)` gives the rows and the columns of a table from the boxes of its words. Refer to [A table](#a-table).
110
143
  - `scaleText(text, factor, unit)` changes the unit of the boxes. For example, the factor `72 / 300` changes the pixels of an image at 300 dots per inch to PDF points.
111
144
 
112
145
  ## Other engines
package/dist/index.d.ts CHANGED
@@ -4,5 +4,5 @@ export * from "./parse.js";
4
4
  export * from "./engine.js";
5
5
  export * from "./programs.js";
6
6
  export { createOcrRunner, DEFAULT_TIMEOUT_MS, type OcrHostOptions, type OcrRunner } from "./run.js";
7
- export { DEFAULT_DPI, ocrImage, ocrPage, pdftoppmArgs, pdftotextArgs } from "./procedures/ocr/index.js";
7
+ export { DEFAULT_DPI, ocrImage, ocrPage, ocrPageCount, pdfinfoArgs, pdftoppmArgs, pdftotextArgs } from "./procedures/ocr/index.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC;AAE3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAE3B,cAAc,YAAY,CAAC;AAE3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -7,5 +7,5 @@ export * from "./parse.js";
7
7
  export * from "./engine.js";
8
8
  export * from "./programs.js";
9
9
  export { createOcrRunner, DEFAULT_TIMEOUT_MS } from "./run.js";
10
- export { DEFAULT_DPI, ocrImage, ocrPage, pdftoppmArgs, pdftotextArgs } from "./procedures/ocr/index.js";
10
+ export { DEFAULT_DPI, ocrImage, ocrPage, ocrPageCount, pdfinfoArgs, pdftoppmArgs, pdftotextArgs } from "./procedures/ocr/index.js";
11
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,mFAAmF;AACnF,cAAc,YAAY,CAAC;AAC3B,0FAA0F;AAC1F,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAuC,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,mFAAmF;AACnF,cAAc,YAAY,CAAC;AAC3B,0FAA0F;AAC1F,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAuC,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,KAAK,YAAY,EAGjB,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAehE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,cAAmB,GAAG,YAAY,EAAE,CAiChF;AAED,4FAA4F;AAC5F,eAAO,MAAM,aAAa,EAAE,YAAY,EAA0B,CAAC;AAInE,eAAO,MAAM,SAAS,EAAE,eAAmC,CAAC;eAE7C,SAAS;AAExB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CAG7E;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,UAAU,CAAuB,CAAC"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAIL,KAAK,YAAY,EAGjB,KAAK,iBAAiB,EAEtB,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AA+BhE;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,cAAmB,GAAG,YAAY,EAAE,CAgDhF;AAED,4FAA4F;AAC5F,eAAO,MAAM,aAAa,EAAE,YAAY,EAA0B,CAAC;AAInE,eAAO,MAAM,SAAS,EAAE,eAAmC,CAAC;eAE7C,SAAS;AAExB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,cAAmB,GAAG,eAAe,CAG7E;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,UAAU,CAAuB,CAAC"}
package/dist/module.js CHANGED
@@ -9,8 +9,9 @@ import { createProcedure, defineModule, definePackage, } from "@procedures/clien
9
9
  import shellModule from "@procedures/shell/module";
10
10
  import { ocrImage } from "./procedures/ocr/image.js";
11
11
  import { ocrPage } from "./procedures/ocr/page.js";
12
+ import { ocrPageCount } from "./procedures/ocr/pageCount.js";
12
13
  import { createOcrRunner } from "./run.js";
13
- import { OcrImageInputSchema, OcrImageOutputSchema, OcrPageInputSchema, OcrPageOutputSchema } from "./types.js";
14
+ import { OcrImageInputSchema, OcrImageOutputSchema, OcrPageCountInputSchema, OcrPageCountOutputSchema, OcrPageInputSchema, OcrPageOutputSchema, } from "./types.js";
14
15
  /** The rule of the procedures under a root of the files: the file of the input is in the root. */
15
16
  const FILE_IN_A_ROOT = { paths: ["file"] };
16
17
  /**
@@ -20,6 +21,8 @@ const FILE_IN_A_ROOT = { paths: ["file"] };
20
21
  const PAGE_EFFECTS = { reads: ["fs", "process"], writes: ["fs", "process"] };
21
22
  /** The effects of `ocr.image`. The engine reads the image file and writes only to its standard output. */
22
23
  const IMAGE_EFFECTS = { reads: ["fs", "process"], writes: ["process"] };
24
+ /** The effects of `ocr.pageCount`. `pdfinfo` reads the PDF file and writes only to its standard output. */
25
+ const PAGE_COUNT_EFFECTS = { reads: ["fs", "process"], writes: ["process"] };
23
26
  /**
24
27
  * This function gives the procedures of this package with the settings of the host. The settings
25
28
  * are the path of each program, the OCR engine and the folder of the temporary folders.
@@ -56,7 +59,22 @@ export function createOcrProcedures(options = {}) {
56
59
  })
57
60
  .handler(async (input, ctx) => ocrImage(input, ctx, runner))
58
61
  .build();
59
- return [page, image];
62
+ const pageCount = createProcedure()
63
+ .path(["ocr", "pageCount"])
64
+ .input(OcrPageCountInputSchema)
65
+ .output(OcrPageCountOutputSchema)
66
+ .meta({
67
+ description: "Give the number of pages of a PDF file (pdfinfo), so a caller can read each page with ocr.page",
68
+ args: ["file"],
69
+ shorts: { timeout: "t" },
70
+ output: "json",
71
+ calls: ["shell.run"],
72
+ effects: PAGE_COUNT_EFFECTS,
73
+ fsRoot: FILE_IN_A_ROOT,
74
+ })
75
+ .handler(async (input, ctx) => ocrPageCount(input, ctx, runner))
76
+ .build();
77
+ return [page, image, pageCount];
60
78
  }
61
79
  /** The procedures with the default settings: the search finds each program at each call. */
62
80
  export const ocrProcedures = createOcrProcedures();
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,aAAa,GAOd,MAAM,oBAAoB,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C;IACnF,OAAO,YAAY,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAkC,UAAU,CAAC,QAAQ,CAAC"}
package/dist/parse.d.ts CHANGED
@@ -6,4 +6,6 @@ export * from "./text.js";
6
6
  export * from "./tsv.js";
7
7
  export * from "./bbox.js";
8
8
  export * from "./osd.js";
9
+ export * from "./table.js";
10
+ export * from "./pdfinfo.js";
9
11
  //# sourceMappingURL=parse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
package/dist/parse.js CHANGED
@@ -6,4 +6,6 @@ export * from "./text.js";
6
6
  export * from "./tsv.js";
7
7
  export * from "./bbox.js";
8
8
  export * from "./osd.js";
9
+ export * from "./table.js";
10
+ export * from "./pdfinfo.js";
9
11
  //# sourceMappingURL=parse.js.map
package/dist/parse.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../src/parse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The parse of the output of `pdfinfo` of Poppler. This file starts no process and reads no file.
3
+ *
4
+ * The output has one line for each field, for example `Title: A report` and
5
+ * `Pages: 3`.
6
+ */
7
+ /**
8
+ * This function gives the number of pages from the output of `pdfinfo`: the value of its `Pages`
9
+ * line.
10
+ *
11
+ * @throws Error when the output has no `Pages` line with a whole number.
12
+ */
13
+ export declare function parsePdfinfoPages(output: string): number;
14
+ //# sourceMappingURL=pdfinfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdfinfo.d.ts","sourceRoot":"","sources":["../src/pdfinfo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The parse of the output of `pdfinfo` of Poppler. This file starts no process and reads no file.
3
+ *
4
+ * The output has one line for each field, for example `Title: A report` and
5
+ * `Pages: 3`.
6
+ */
7
+ /**
8
+ * This function gives the number of pages from the output of `pdfinfo`: the value of its `Pages`
9
+ * line.
10
+ *
11
+ * @throws Error when the output has no `Pages` line with a whole number.
12
+ */
13
+ export function parsePdfinfoPages(output) {
14
+ const match = /^Pages:[ \t]*([0-9]+)[ \t]*\r?$/m.exec(output);
15
+ const pages = match === null ? Number.NaN : Number(match[1]);
16
+ if (!Number.isSafeInteger(pages))
17
+ throw new Error("The output of pdfinfo has no Pages line with a whole number");
18
+ return pages;
19
+ }
20
+ //# sourceMappingURL=pdfinfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pdfinfo.js","sourceRoot":"","sources":["../src/pdfinfo.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC9C,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,MAAM,KAAK,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjH,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { DEFAULT_DPI, ocrPage, pdftoppmArgs, pdftotextArgs } from "./page.js";
2
2
  export { ocrImage } from "./image.js";
3
+ export { ocrPageCount, pdfinfoArgs } from "./pageCount.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/ocr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/procedures/ocr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { DEFAULT_DPI, ocrPage, pdftoppmArgs, pdftotextArgs } from "./page.js";
2
2
  export { ocrImage } from "./image.js";
3
+ export { ocrPageCount, pdfinfoArgs } from "./pageCount.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/ocr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/procedures/ocr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * ocr.pageCount procedure
3
+ *
4
+ * This procedure gives the number of pages of a PDF file, from `pdfinfo` of Poppler. A caller can
5
+ * then read each page with `ocr.page`, from page 1 to this number.
6
+ */
7
+ import type { ProcedureContext } from "@procedures/client";
8
+ import { type OcrRunner } from "../../run.js";
9
+ import type { OcrPageCountInput, OcrPageCountOutput } from "../../types.js";
10
+ /** This function gives the argv of `pdfinfo` for the fields of a PDF file. */
11
+ export declare function pdfinfoArgs(file: string): string[];
12
+ /**
13
+ * This function gives the number of pages of the PDF file of the input. The count comes from the
14
+ * same Poppler programs that `ocr.page` uses, so each page from 1 to the count is a valid page of
15
+ * `ocr.page`.
16
+ *
17
+ * @throws Error when the output of `pdfinfo` has no number of pages.
18
+ */
19
+ export declare function ocrPageCount(input: OcrPageCountInput, ctx: Pick<ProcedureContext, "client">, runner?: OcrRunner): Promise<OcrPageCountOutput>;
20
+ //# sourceMappingURL=pageCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageCount.d.ts","sourceRoot":"","sources":["../../../src/procedures/ocr/pageCount.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE5E,8EAA8E;AAC9E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAElD;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAE,SAA6B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAKtK"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * ocr.pageCount procedure
3
+ *
4
+ * This procedure gives the number of pages of a PDF file, from `pdfinfo` of Poppler. A caller can
5
+ * then read each page with `ocr.page`, from page 1 to this number.
6
+ */
7
+ import { resolve } from "node:path";
8
+ import { parsePdfinfoPages } from "../../pdfinfo.js";
9
+ import { PDFINFO } from "../../programs.js";
10
+ import { createOcrRunner, DEFAULT_TIMEOUT_MS } from "../../run.js";
11
+ /** This function gives the argv of `pdfinfo` for the fields of a PDF file. */
12
+ export function pdfinfoArgs(file) {
13
+ return [file];
14
+ }
15
+ /**
16
+ * This function gives the number of pages of the PDF file of the input. The count comes from the
17
+ * same Poppler programs that `ocr.page` uses, so each page from 1 to the count is a valid page of
18
+ * `ocr.page`.
19
+ *
20
+ * @throws Error when the output of `pdfinfo` has no number of pages.
21
+ */
22
+ export async function ocrPageCount(input, ctx, runner = createOcrRunner()) {
23
+ // An absolute path does not start with "-", so the program cannot read it as a flag
24
+ const file = resolve(input.file);
25
+ const timeout = input.timeout ?? DEFAULT_TIMEOUT_MS;
26
+ return { pages: parsePdfinfoPages(await runner.run(PDFINFO, pdfinfoArgs(file), timeout, ctx)) };
27
+ }
28
+ //# sourceMappingURL=pageCount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pageCount.js","sourceRoot":"","sources":["../../../src/procedures/ocr/pageCount.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAkB,MAAM,cAAc,CAAC;AAGnF,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB,EAAE,GAAqC,EAAE,MAAM,GAAc,eAAe,EAAE;IACvI,oFAAoF;IACpF,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,kBAAkB,CAAC;IACpD,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;AAClG,CAAC"}
@@ -1,10 +1,17 @@
1
1
  /**
2
2
  * The search for the programs of this package on the host: `tesseract` (the OCR engine), and
3
- * `pdftotext` and `pdftoppm` of Poppler. The package does not download a program. When the search
3
+ * `pdftotext`, `pdftoppm` and `pdfinfo` of Poppler. The package does not download a program. When the search
4
4
  * finds no program, `requireProgram` throws an `OcrToolMissingError`.
5
5
  */
6
6
  /** The environment of the search. */
7
7
  export type ProgramEnv = Readonly<Record<string, string | undefined>>;
8
+ /** A different program with the same name, for example the `pdftotext` of Xpdf. */
9
+ export interface OtherProgram {
10
+ /** The name of the other program, for the error, for example `Xpdf`. */
11
+ readonly name: string;
12
+ /** This function gives `true` when the output of a failed run comes from the other program. */
13
+ readonly matches: (output: string) => boolean;
14
+ }
8
15
  /** The description of a program for the search. */
9
16
  export interface ProgramSpec {
10
17
  /** The name of the program, without `.exe`, for example `tesseract`. */
@@ -17,6 +24,11 @@ export interface ProgramSpec {
17
24
  readonly installed: (platform: NodeJS.Platform, env: ProgramEnv) => readonly string[];
18
25
  /** The text that tells how to install the program, for the error. */
19
26
  readonly install: string;
27
+ /**
28
+ * The different programs with the same name. When a run fails and its output comes from one of
29
+ * them, the runner throws an `OcrToolMissingError`, not the error of the run.
30
+ */
31
+ readonly others?: readonly OtherProgram[] | undefined;
20
32
  }
21
33
  /** The options of the search. Each one has a default from the host. */
22
34
  export interface FindProgramOptions {
@@ -29,10 +41,18 @@ export interface FindProgramOptions {
29
41
  }
30
42
  /** The OCR engine tesseract. The installer for Windows puts it in `Tesseract-OCR`, and not on the `PATH`. */
31
43
  export declare const TESSERACT: ProgramSpec;
44
+ /**
45
+ * The programs of Xpdf have the names of the programs of Poppler, but not their options: for
46
+ * example, the `pdftotext` of Xpdf has no `-bbox-layout`. Git for Windows puts Xpdf on the `PATH`.
47
+ * The usage text of Xpdf names Glyph & Cog. The usage text of Poppler names Glyph & Cog and Poppler.
48
+ */
49
+ export declare const XPDF: OtherProgram;
32
50
  /** The program of Poppler that gives the text layer of a PDF page. */
33
51
  export declare const PDFTOTEXT: ProgramSpec;
34
52
  /** The program of Poppler that makes an image of a PDF page. */
35
53
  export declare const PDFTOPPM: ProgramSpec;
54
+ /** The program of Poppler that gives the fields of a PDF file, for example its number of pages. */
55
+ export declare const PDFINFO: ProgramSpec;
36
56
  /** The programs of this package. */
37
57
  export declare const OCR_PROGRAMS: readonly ProgramSpec[];
38
58
  /** The error when a program of this package is not on the host. */
@@ -43,8 +63,14 @@ export declare class OcrToolMissingError extends Error {
43
63
  readonly tool: string;
44
64
  /** The paths that the search examined, in order. */
45
65
  readonly searched: readonly string[];
66
+ /** The name of the different program that the search found, for example `Xpdf`, or `undefined`. */
67
+ readonly other: string | undefined;
46
68
  readonly name: string;
47
- constructor(spec: ProgramSpec, searched: readonly string[], cause?: string);
69
+ /**
70
+ * The `cause` is the error of a start that failed. The `other` is the name of a different
71
+ * program with the same name at `searched[0]`, for example `Xpdf`.
72
+ */
73
+ constructor(spec: ProgramSpec, searched: readonly string[], cause?: string, other?: string);
48
74
  }
49
75
  /**
50
76
  * This function gives the paths that the search examines for a program, in order. The order is
@@ -1 +1 @@
1
- {"version":3,"file":"programs.d.ts","sourceRoot":"","sources":["../src/programs.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,qCAAqC;AACrC,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEtE,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACnD,6FAA6F;IAC7F,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,GAAG,EAAE,UAAU,KAAK,SAAS,MAAM,EAAE,CAAC;IACtF,qEAAqE;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,uEAAuE;AACvE,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACtC,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE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IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAO,GAAG,MAAM,GAAG,SAAS,CASlJ;AAED,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,kBAAkB,GAAG;IAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAO,GAAG,MAAM,CAIzI"}
package/dist/programs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The search for the programs of this package on the host: `tesseract` (the OCR engine), and
3
- * `pdftotext` and `pdftoppm` of Poppler. The package does not download a program. When the search
3
+ * `pdftotext`, `pdftoppm` and `pdfinfo` of Poppler. The package does not download a program. When the search
4
4
  * finds no program, `requireProgram` throws an `OcrToolMissingError`.
5
5
  */
6
6
  import { existsSync } from "node:fs";
@@ -26,6 +26,15 @@ export const TESSERACT = {
26
26
  },
27
27
  install: "the package tesseract-ocr on Linux, brew install tesseract on macOS, or the Tesseract installer on Windows",
28
28
  };
29
+ /**
30
+ * The programs of Xpdf have the names of the programs of Poppler, but not their options: for
31
+ * example, the `pdftotext` of Xpdf has no `-bbox-layout`. Git for Windows puts Xpdf on the `PATH`.
32
+ * The usage text of Xpdf names Glyph & Cog. The usage text of Poppler names Glyph & Cog and Poppler.
33
+ */
34
+ export const XPDF = {
35
+ name: "Xpdf",
36
+ matches: (output) => /Glyph & Cog/.test(output) && !/poppler/i.test(output),
37
+ };
29
38
  function poppler(name, env) {
30
39
  return {
31
40
  name,
@@ -37,14 +46,17 @@ function poppler(name, env) {
37
46
  return platform === "darwin" ? HOMEBREW_FOLDERS.map((folder) => posix.join(folder, name)) : [];
38
47
  },
39
48
  install: "the package poppler-utils on Linux, brew install poppler on macOS, or a Poppler build on Windows",
49
+ others: [XPDF],
40
50
  };
41
51
  }
42
52
  /** The program of Poppler that gives the text layer of a PDF page. */
43
53
  export const PDFTOTEXT = poppler("pdftotext", "PDFTOTEXT_EXE");
44
54
  /** The program of Poppler that makes an image of a PDF page. */
45
55
  export const PDFTOPPM = poppler("pdftoppm", "PDFTOPPM_EXE");
56
+ /** The program of Poppler that gives the fields of a PDF file, for example its number of pages. */
57
+ export const PDFINFO = poppler("pdfinfo", "PDFINFO_EXE");
46
58
  /** The programs of this package. */
47
- export const OCR_PROGRAMS = [TESSERACT, PDFTOTEXT, PDFTOPPM];
59
+ export const OCR_PROGRAMS = [TESSERACT, PDFTOTEXT, PDFTOPPM, PDFINFO];
48
60
  /** The error when a program of this package is not on the host. */
49
61
  export class OcrToolMissingError extends Error {
50
62
  /** The code of the error, for a check without `instanceof`. */
@@ -53,13 +65,26 @@ export class OcrToolMissingError extends Error {
53
65
  tool;
54
66
  /** The paths that the search examined, in order. */
55
67
  searched;
68
+ /** The name of the different program that the search found, for example `Xpdf`, or `undefined`. */
69
+ other;
56
70
  name = "OcrToolMissingError";
57
- constructor(spec, searched, cause) {
71
+ /**
72
+ * The `cause` is the error of a start that failed. The `other` is the name of a different
73
+ * program with the same name at `searched[0]`, for example `Xpdf`.
74
+ */
75
+ constructor(spec, searched, cause, other) {
58
76
  const variables = [...spec.env, ...(spec.folderEnv ?? [])].join(" or ");
59
- const reason = cause === undefined ? `The search examined ${searched.length} paths.` : `It did not start: ${cause}.`;
60
- super(`The program ${spec.name} is not on this host. ${reason} Install ${spec.install}, or set ${variables}.`);
77
+ const fix = `Install ${spec.install}, or set ${variables}.`;
78
+ if (other !== undefined) {
79
+ super(`The program ${spec.name} at ${searched[0] ?? "the path of the search"} is the program of ${other}, and this package cannot use it. ${fix}`);
80
+ }
81
+ else {
82
+ const reason = cause === undefined ? `The search examined ${searched.length} paths.` : `It did not start: ${cause}.`;
83
+ super(`The program ${spec.name} is not on this host. ${reason} ${fix}`);
84
+ }
61
85
  this.tool = spec.name;
62
86
  this.searched = searched;
87
+ this.other = other;
63
88
  }
64
89
  }
65
90
  /** This function gives the folders of the `PATH`, in order. */
@@ -1 +1 @@
1
- {"version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AAO,OAAO,CAAC,UAAU,CAAC;IACjG,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;IAC5D,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,UAAU,CAAC;IAC5C,OAAO,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;AACnH,CAAC;AAED,mHAAmH;AACnH,MAAM,UAAU,cAAc,CAAC,IAAiB,EAAE,OAAO,GAAsE,EAAE;IAC/H,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,MAAM,IAAI,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,CAAC,IAAI,EAAE,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;AACjI,CAAC"}
package/dist/run.d.ts CHANGED
@@ -11,8 +11,8 @@ export declare const DEFAULT_TIMEOUT_MS = 120000;
11
11
  /** The settings of the host for the procedures of this package. The procedure input cannot change them. */
12
12
  export interface OcrHostOptions extends FindProgramOptions {
13
13
  /**
14
- * The path of each program, by name: `tesseract`, `pdftotext` or `pdftoppm`. A program with no
15
- * path comes from the search of `findProgram`.
14
+ * The path of each program, by name: `tesseract`, `pdftotext`, `pdftoppm` or `pdfinfo`. A
15
+ * program with no path comes from the search of `findProgram`.
16
16
  */
17
17
  readonly executables?: Readonly<Record<string, string | undefined>> | undefined;
18
18
  /** The OCR engine (default: `tesseractEngine`). */
package/dist/run.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAuC,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE/G,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,SAAU,CAAC;AAE1C,2GAA2G;AAC3G,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC;IAChF,mDAAmD;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACxC,yFAAyF;IACzF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,oEAAoE;IACpE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1H;AAUD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,OAAO,GAAE,cAAmB,GAAG,SAAS,CA2BvE"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAuC,KAAK,kBAAkB,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAE/G,8DAA8D;AAC9D,eAAO,MAAM,kBAAkB,SAAU,CAAC;AAE1C,2GAA2G;AAC3G,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,CAAC;IAChF,mDAAmD;IACnD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IACxC,yFAAyF;IACzF,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,gDAAgD;AAChD,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,oEAAoE;IACpE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1H;AAUD,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,OAAO,GAAE,cAAmB,GAAG,SAAS,CA6BvE"}
package/dist/run.js CHANGED
@@ -38,6 +38,9 @@ export function createOcrRunner(options = {}) {
38
38
  if (notFound(result))
39
39
  throw new OcrToolMissingError(spec, [input.command], result.stderr.trim());
40
40
  if (result.exitCode !== 0) {
41
+ const other = spec.others?.find((program) => program.matches(`${result.stderr}\n${result.stdout}`));
42
+ if (other !== undefined)
43
+ throw new OcrToolMissingError(spec, [input.command], undefined, other.name);
41
44
  const text = result.stderr.trim() || result.stdout.trim();
42
45
  throw new CliToolError(`${spec.name} failed (exit code ${result.exitCode}): ${text}`.trim(), result.exitCode, result.stderr);
43
46
  }
package/dist/run.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAgB,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAkB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAA6C,MAAM,eAAe,CAAC;AAE/G,8DAA8D;AAC9D,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAuB1C;;;GAGG;AACH,SAAS,QAAQ,CAAC,MAA4D;IAC5E,OAAO,MAAM,CAAC,QAAQ,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,EAAE,IAAI,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;AACzG,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,eAAe,CAAC,OAAO,GAAmB,EAAE;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,eAAe,CAAC;IACjD,MAAM,IAAI,GAAuB,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IAC1G,MAAM,KAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;IACzC,MAAM,MAAM,GAAG,CAAC,I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