pdf-skryba 0.7.0 → 0.8.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +173 -0
  2. package/LICENSE +661 -661
  3. package/README.md +169 -115
  4. package/THIRD-PARTY.md +134 -134
  5. package/dist/index.js.map +1 -1
  6. package/dist/light.js.map +1 -1
  7. package/dist/types/packages/doc-ir/src/extractor/image-pixel-width.d.ts +1 -1
  8. package/dist/types/packages/doc-ir/src/layout/aligned-grid.d.ts +1 -1
  9. package/dist/types/packages/doc-ir/src/layout/baseline-lines.d.ts +1 -1
  10. package/dist/types/packages/doc-ir/src/layout/cell-text.d.ts +1 -1
  11. package/dist/types/packages/doc-ir/src/layout/column-discriminant.d.ts +1 -1
  12. package/dist/types/packages/doc-ir/src/layout/column-grid.d.ts +1 -1
  13. package/dist/types/packages/doc-ir/src/layout/cut-word.d.ts +2 -2
  14. package/dist/types/packages/doc-ir/src/layout/fragment-cells.d.ts +1 -1
  15. package/dist/types/packages/doc-ir/src/layout/geometry.d.ts +9 -9
  16. package/dist/types/packages/doc-ir/src/layout/gutter.d.ts +1 -1
  17. package/dist/types/packages/doc-ir/src/layout/hyphenation.d.ts +1 -1
  18. package/dist/types/packages/doc-ir/src/layout/intersection-cells.d.ts +1 -1
  19. package/dist/types/packages/doc-ir/src/layout/merged-cells.d.ts +1 -1
  20. package/dist/types/packages/doc-ir/src/layout/page-furniture.d.ts +1 -1
  21. package/dist/types/packages/doc-ir/src/layout/painted-paths.d.ts +1 -1
  22. package/dist/types/packages/doc-ir/src/layout/rect-rules.d.ts +1 -1
  23. package/dist/types/packages/doc-ir/src/layout/text-size.d.ts +1 -1
  24. package/dist/types/packages/doc-ir/src/layout/vector-grid.d.ts +1 -1
  25. package/dist/types/packages/doc-ir/src/lib/ir-walk.d.ts +1 -1
  26. package/dist/types/packages/doc-ir/src/lib/page-labels.d.ts +1 -1
  27. package/dist/types/packages/doc-ir/src/lib/reader-limits.d.ts +1 -1
  28. package/dist/types/packages/doc-ir/src/lib/table-empty-parts.d.ts +1 -1
  29. package/dist/types/packages/doc-ir/src/lib/table-width-cap.d.ts +2 -2
  30. package/dist/types/packages/doc-ir/src/lib/vision-port.d.ts +1 -1
  31. package/dist/types/packages/doc-ir/src/pipeline/detect-language.d.ts +1 -1
  32. package/dist/types/packages/doc-read/src/extractor/glyph-accents.d.ts +1 -1
  33. package/dist/types/packages/doc-read/src/extractor/glyph-double-draw.d.ts +1 -1
  34. package/dist/types/packages/doc-read/src/extractor/glyph-positions.d.ts +3 -3
  35. package/dist/types/packages/doc-read/src/extractor/glyph-runs.d.ts +2 -2
  36. package/dist/types/packages/doc-read/src/extractor/glyph-window.d.ts +1 -1
  37. package/dist/types/packages/doc-read/src/extractor/pdf-aside-figures.d.ts +3 -3
  38. package/dist/types/packages/doc-read/src/extractor/pdf-bands.d.ts +1 -1
  39. package/dist/types/packages/doc-read/src/extractor/pdf-ccitt-images.d.ts +2 -2
  40. package/dist/types/packages/doc-read/src/extractor/pdf-cell-paragraphs.d.ts +2 -2
  41. package/dist/types/packages/doc-read/src/extractor/pdf-column-cut.d.ts +1 -1
  42. package/dist/types/packages/doc-read/src/extractor/pdf-document-info.d.ts +1 -1
  43. package/dist/types/packages/doc-read/src/extractor/pdf-document-scale.d.ts +4 -4
  44. package/dist/types/packages/doc-read/src/extractor/pdf-embedded-images.d.ts +3 -3
  45. package/dist/types/packages/doc-read/src/extractor/pdf-facts.d.ts +2 -2
  46. package/dist/types/packages/doc-read/src/extractor/pdf-flate-images.d.ts +3 -3
  47. package/dist/types/packages/doc-read/src/extractor/pdf-font-bridge.d.ts +1 -1
  48. package/dist/types/packages/doc-read/src/extractor/pdf-font-objects.d.ts +2 -2
  49. package/dist/types/packages/doc-read/src/extractor/pdf-fonts/font-text.d.ts +4 -4
  50. package/dist/types/packages/doc-read/src/extractor/pdf-fonts/widths.d.ts +3 -3
  51. package/dist/types/packages/doc-read/src/extractor/pdf-framed-blocks.d.ts +2 -2
  52. package/dist/types/packages/doc-read/src/extractor/pdf-glyph-source.d.ts +4 -4
  53. package/dist/types/packages/doc-read/src/extractor/pdf-hidden-text.d.ts +1 -1
  54. package/dist/types/packages/doc-read/src/extractor/pdf-image-anchors.d.ts +6 -6
  55. package/dist/types/packages/doc-read/src/extractor/pdf-image-pixels.d.ts +2 -2
  56. package/dist/types/packages/doc-read/src/extractor/pdf-image-refusal.d.ts +3 -3
  57. package/dist/types/packages/doc-read/src/extractor/pdf-image-store.d.ts +2 -2
  58. package/dist/types/packages/doc-read/src/extractor/pdf-images.d.ts +1 -1
  59. package/dist/types/packages/doc-read/src/extractor/pdf-jpeg-images.d.ts +3 -3
  60. package/dist/types/packages/doc-read/src/extractor/pdf-layers.d.ts +1 -1
  61. package/dist/types/packages/doc-read/src/extractor/pdf-letter-spacing.d.ts +2 -2
  62. package/dist/types/packages/doc-read/src/extractor/pdf-line-breaks.d.ts +2 -2
  63. package/dist/types/packages/doc-read/src/extractor/pdf-lines.d.ts +3 -3
  64. package/dist/types/packages/doc-read/src/extractor/pdf-links-ours.d.ts +2 -2
  65. package/dist/types/packages/doc-read/src/extractor/pdf-links.d.ts +3 -3
  66. package/dist/types/packages/doc-read/src/extractor/pdf-model.d.ts +8 -8
  67. package/dist/types/packages/doc-read/src/extractor/pdf-objects/content.d.ts +1 -1
  68. package/dist/types/packages/doc-read/src/extractor/pdf-objects/document.d.ts +1 -1
  69. package/dist/types/packages/doc-read/src/extractor/pdf-objects/parse.d.ts +1 -1
  70. package/dist/types/packages/doc-read/src/extractor/pdf-objects/refusal.d.ts +1 -1
  71. package/dist/types/packages/doc-read/src/extractor/pdf-objects/streams.d.ts +1 -1
  72. package/dist/types/packages/doc-read/src/extractor/pdf-objects/xref.d.ts +1 -1
  73. package/dist/types/packages/doc-read/src/extractor/pdf-objstm-source.d.ts +2 -2
  74. package/dist/types/packages/doc-read/src/extractor/pdf-open.d.ts +4 -4
  75. package/dist/types/packages/doc-read/src/extractor/pdf-ops-ours.d.ts +3 -3
  76. package/dist/types/packages/doc-read/src/extractor/pdf-ops.d.ts +1 -1
  77. package/dist/types/packages/doc-read/src/extractor/pdf-outline.d.ts +1 -1
  78. package/dist/types/packages/doc-read/src/extractor/pdf-page-content.d.ts +3 -3
  79. package/dist/types/packages/doc-read/src/extractor/pdf-page-figures.d.ts +7 -7
  80. package/dist/types/packages/doc-read/src/extractor/pdf-page-markers.d.ts +5 -5
  81. package/dist/types/packages/doc-read/src/extractor/pdf-page-plan.d.ts +4 -4
  82. package/dist/types/packages/doc-read/src/extractor/pdf-page-stages.d.ts +13 -13
  83. package/dist/types/packages/doc-read/src/extractor/pdf-page-tables.d.ts +7 -7
  84. package/dist/types/packages/doc-read/src/extractor/pdf-page-tabs.d.ts +3 -3
  85. package/dist/types/packages/doc-read/src/extractor/pdf-paragraphs.d.ts +3 -3
  86. package/dist/types/packages/doc-read/src/extractor/pdf-paths-ours.d.ts +2 -2
  87. package/dist/types/packages/doc-read/src/extractor/pdf-reading-order.d.ts +2 -2
  88. package/dist/types/packages/doc-read/src/extractor/pdf-reference-ours.d.ts +2 -2
  89. package/dist/types/packages/doc-read/src/extractor/pdf-region-order.d.ts +3 -3
  90. package/dist/types/packages/doc-read/src/extractor/pdf-rotated-lines.d.ts +1 -1
  91. package/dist/types/packages/doc-read/src/extractor/pdf-rotated-words.d.ts +1 -1
  92. package/dist/types/packages/doc-read/src/extractor/pdf-row-url-join.d.ts +1 -1
  93. package/dist/types/packages/doc-read/src/extractor/pdf-scanned.d.ts +8 -8
  94. package/dist/types/packages/doc-read/src/extractor/pdf-smask.d.ts +2 -2
  95. package/dist/types/packages/doc-read/src/extractor/pdf-source.d.ts +13 -13
  96. package/dist/types/packages/doc-read/src/extractor/pdf-stencil-images.d.ts +3 -3
  97. package/dist/types/packages/doc-read/src/extractor/pdf-structure.d.ts +1 -1
  98. package/dist/types/packages/doc-read/src/extractor/pdf-symbol-page.d.ts +2 -2
  99. package/dist/types/packages/doc-read/src/extractor/pdf-symbol-verdict.d.ts +1 -1
  100. package/dist/types/packages/doc-read/src/extractor/pdf-table-detector.d.ts +7 -7
  101. package/dist/types/packages/doc-read/src/extractor/pdf-table-render.d.ts +3 -3
  102. package/dist/types/packages/doc-read/src/extractor/pdf.d.ts +14 -14
  103. package/dist/types/packages/doc-read/src/lib/pdf-light.d.ts +15 -15
  104. package/dist/types/packages/doc-read/src/lib/pdf.d.ts +5 -5
  105. package/dist/types/packages/doc-read/src/lib/reader-options.d.ts +3 -3
  106. package/dist/types/packages/doc-read/src/pipeline/cut-paragraph-repair.d.ts +1 -1
  107. package/dist/types/packages/doc-read/src/pipeline/glued-word-repair.d.ts +1 -1
  108. package/dist/types/packages/doc-read/src/pipeline/lost-text-repair.d.ts +1 -1
  109. package/dist/types/packages/doc-read/src/pipeline/pdf-conservation-source.d.ts +1 -1
  110. package/package.json +7 -6
package/README.md CHANGED
@@ -1,115 +1,169 @@
1
- # pdf-skryba
2
-
3
- Reads a PDF into a structured representation, and checks that no word was lost on the way.
4
-
5
- The PDF reader of [Miksumia Publisher](https://miksumia.com), the Atlassian Marketplace
6
- [app](https://marketplace.atlassian.com/apps/2647582831/miksumia-publisher-for-confluence) that turns
7
- uploaded files into Confluence pages.
8
-
9
- ## Read a PDF
10
-
11
- ```js
12
- import { readFileSync } from "node:fs";
13
- import { extractPdf } from "pdf-skryba";
14
-
15
- const bytes = new Uint8Array(readFileSync("report.pdf"));
16
- const { doc, pageCount, notices } = await extractPdf(bytes, vision, { ocr: false });
17
-
18
- pageCount; // 12
19
- doc.blocks[0].kind; // "tabs" — one tab per page
20
- doc.blocks[0].tabs[0]; // its blocks: headings, paragraphs, lists, tables, images
21
- notices; // every part it could not read, each with a named reason
22
- ```
23
-
24
- ## Scanned pages: the AI reading is yours
25
-
26
- `vision` is a port you implement. It receives a small PDF holding the pages to read and returns one
27
- result per page, in order. With `ocr: false` a page with no text layer is counted and never read; a
28
- file that is a scan from end to end is refused (`SCANNED_PDF_NEEDS_AI_OCR`).
29
-
30
- ```js
31
- const vision = {
32
- analyzeDocument: (slice, opts) => yourModel(slice, opts?.languages),
33
- };
34
-
35
- // Hand back the page pictures instead of refusing a full scan:
36
- await extractPdf(bytes, vision, { ocr: false, scanAsImages: true });
37
-
38
- // Or let the AI read every page, text layer included:
39
- await extractPdf(bytes, vision, { readAll: true, languages: ["en", "fr"] });
40
- ```
41
-
42
- ## Your own ceilings
43
-
44
- It withholds nothing by default: a ceiling shaped by where a document is going is yours to set. The
45
- reader's own bounds (bytes, references, depth, glyphs) have values you can only lower.
46
-
47
- ```js
48
- await extractPdf(bytes, vision, {
49
- limits: { pageLimit: 50, tableRows: 200, tableCols: 20 },
50
- });
51
- ```
52
-
53
- ## Refusals carry a code
54
-
55
- ```js
56
- import { ReaderError } from "pdf-skryba/light";
57
-
58
- try {
59
- await extractPdf(bytes, vision, { ocr: false });
60
- } catch (error) {
61
- if (error instanceof ReaderError) {
62
- error.code; // "SCANNED_PDF_NEEDS_AI_OCR", "FILE_UNSAFE", "EXTRACT_FAILED"…
63
- error.pageCount; // what it knew before refusing
64
- }
65
- }
66
- ```
67
-
68
- ## Check what you published
69
-
70
- `pdf-skryba/light` loads no reader. Hand it the text you published, block by block, and it tells you what
71
- the page lost, invented, glued or split — in YOUR coordinates, never your markup.
72
-
73
- ```js
74
- import { textConservation } from "pdf-skryba/light";
75
-
76
- const { conservationSource } = await extractPdf(bytes, vision);
77
- const verdict = textConservation(conservationSource.runs, { blocks: myPublishedTexts });
78
-
79
- verdict.decision; // "ok" | "lost" | "glued" | "abstain"
80
- verdict.lostLetters; // how many, and
81
- verdict.lostPassages; // where: each passage, with the page it came from
82
- verdict.pages; // the pages concerned
83
- ```
84
-
85
- ## Principles
86
-
87
- - **One page, one tab.** Nothing of page 7 is attributed to page 6.
88
- - **It abstains instead of inventing.** A glyph nothing identifies — `g03`, a composite font with no
89
- `/ToUnicode` — publishes nothing. Reading its number as a character puts stray letters into real sentences.
90
- - **Silence is never an answer.** Every ceiling hit and every part it could not read comes back as a `notice`.
91
- Since 0.7.0 a `pdf-text-unread` notice names the pages published without their text, and those where a font
92
- could not be read (reason `font`): no stand-in table is tried, its words are missing and said so. Text a viewer
93
- would not show raises none.
94
- - **Unreadable is not scanned.** Since 0.7.0 a page whose text could not be read never counts as a scan, and a
95
- file none of whose pages gave text is refused (`EXTRACT_FAILED`) instead of being published empty.
96
- - **It can check itself.** Hand it the text you published, block by block (`pdf-skryba/light`, which loads no
97
- reader): it names what was lost, invented, glued or split, and returns repairs in YOUR coordinates.
98
- - **Deterministic.** Same bytes, same document.
99
- - **Every input is hostile.** Bytes, cross-references, reference hops, page-tree depth, operators, glyphs:
100
- each bound refuses with a named reason, never a guess.
101
- - **It talks to nobody.** No network, no filesystem, no credentials — except the `vision` port, yours.
102
-
103
- ## Prior work
104
-
105
- Side Liu, Jiangpeng Liu, Jinwen Xin, Guojun Peng and Jiang Ming, **"Beyond the Editing Canvas:
106
- Evidence Divergence in OOXML-to-LLM Ingestion"**, arXiv:2608.25880 —
107
- <https://arxiv.org/abs/2608.25880>. About the Office formats, not this one, and its lesson is why this
108
- reader exists: the extraction path, not the model, decides what a language model sees.
109
-
110
- ## Licence
111
-
112
- AGPL-3.0-or-later: run a modified version as a network service and its source must be available to its
113
- users. Named `skryba` until 0.6.2. Since 0.7.0 the code comes readable (`dist/index.js`), with the same code minified beside
114
- it (`pdf-skryba/min`). This package ships a bundle and its source map. The Corresponding Source is published at
115
- <https://github.com/numiastowski-design/pdf-skryba>, as one snapshot for each released version.
1
+ # pdf-skryba
2
+
3
+ Reads a PDF into a structured representation, and checks that no word was lost on the way.
4
+
5
+ The PDF reader of [Miksumia Publisher](https://miksumia.com), the Atlassian Marketplace
6
+ [app](https://marketplace.atlassian.com/apps/2647582831/miksumia-publisher-for-confluence) that turns
7
+ uploaded files into Confluence pages.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install pdf-skryba
13
+ ```
14
+
15
+ ES modules only, for Node.js 24 or later; the types ship with the package. From CommonJS,
16
+ `require("pdf-skryba")` loads the same ES module on these Node.js versions.
17
+
18
+ ## A complete example
19
+
20
+ ```ts
21
+ // read.ts: node read.js report.pdf
22
+ import { readFileSync } from "node:fs";
23
+ import { extractPdf } from "pdf-skryba";
24
+ import { ReaderError } from "pdf-skryba/light";
25
+
26
+ const path = process.argv[2];
27
+ if (path === undefined) throw new Error("usage: node read.js <file.pdf>");
28
+
29
+ // No AI reading here: with `ocr: false`, a page without a text layer is counted, never sent.
30
+ const vision = { analyzeDocument: () => Promise.reject(new Error("no AI reading configured")) };
31
+
32
+ try {
33
+ const { doc, pageCount, notices } = await extractPdf(new Uint8Array(readFileSync(path)), vision, { ocr: false });
34
+ console.log(`pages: ${pageCount}`);
35
+ const [pages] = doc.blocks;
36
+ if (pages?.kind === "tabs") console.log(`blocks on page 1: ${pages.tabs[0]?.blocks.length ?? 0}`);
37
+ console.log(`notices: ${notices?.length ?? 0}`);
38
+ } catch (error) {
39
+ if (!(error instanceof ReaderError)) throw error;
40
+ console.error(`refused: ${error.code}`);
41
+ process.exitCode = 1;
42
+ }
43
+ ```
44
+
45
+ ## Read a PDF
46
+
47
+ ```js
48
+ import { readFileSync } from "node:fs";
49
+ import { extractPdf } from "pdf-skryba";
50
+
51
+ const bytes = new Uint8Array(readFileSync("report.pdf"));
52
+ const { doc, pageCount, notices } = await extractPdf(bytes, vision, { ocr: false });
53
+
54
+ pageCount; // 12
55
+ doc.blocks[0].kind; // "tabs" — one tab per page
56
+ doc.blocks[0].tabs[0]; // its blocks: headings, paragraphs, lists, tables, images
57
+ notices; // every part it could not read, each with a named reason
58
+ ```
59
+
60
+ ## Scanned pages: the AI reading is yours
61
+
62
+ `vision` is a port you implement. It receives a small PDF holding the pages to read and returns one
63
+ result per page, in order. With `ocr: false` a page with no text layer is counted and never read; a
64
+ file that is a scan from end to end is refused (`SCANNED_PDF_NEEDS_AI_OCR`).
65
+
66
+ ```js
67
+ const vision = {
68
+ analyzeDocument: (slice, opts) => yourModel(slice, opts?.languages),
69
+ };
70
+
71
+ // Hand back the page pictures instead of refusing a full scan:
72
+ await extractPdf(bytes, vision, { ocr: false, scanAsImages: true });
73
+
74
+ // Or let the AI read every page, text layer included:
75
+ await extractPdf(bytes, vision, { readAll: true, languages: ["en", "fr"] });
76
+ ```
77
+
78
+ ## Your own ceilings
79
+
80
+ It withholds nothing by default: a ceiling shaped by where a document is going is yours to set. The
81
+ reader's own bounds (bytes, references, depth, glyphs) have values you can only lower.
82
+
83
+ ```js
84
+ await extractPdf(bytes, vision, {
85
+ limits: { pageLimit: 50, tableRows: 200, tableCols: 20 },
86
+ });
87
+ ```
88
+
89
+ ## Refusals carry a code
90
+
91
+ ```js
92
+ import { ReaderError } from "pdf-skryba/light";
93
+
94
+ try {
95
+ await extractPdf(bytes, vision, { ocr: false });
96
+ } catch (error) {
97
+ if (error instanceof ReaderError) {
98
+ error.code; // "SCANNED_PDF_NEEDS_AI_OCR", "FILE_UNSAFE", "EXTRACT_FAILED"…
99
+ error.pageCount; // what it knew before refusing
100
+ }
101
+ }
102
+ ```
103
+
104
+ ## Check what you published
105
+
106
+ `pdf-skryba/light` loads no reader. Hand it the text you published, block by block, and it tells you what
107
+ the page lost, invented, glued or split — in YOUR coordinates, never your markup.
108
+
109
+ ```js
110
+ import { textConservation } from "pdf-skryba/light";
111
+
112
+ const { conservationSource } = await extractPdf(bytes, vision);
113
+ const verdict = textConservation(conservationSource.runs, { blocks: myPublishedTexts });
114
+
115
+ verdict.decision; // "ok" | "lost" | "glued" | "abstain"
116
+ verdict.lostLetters; // how many, and
117
+ verdict.lostPassages; // where: each passage, with the page it came from
118
+ verdict.pages; // the pages concerned
119
+ ```
120
+
121
+ ## Principles
122
+
123
+ - **One page, one tab.** Nothing of page 7 is attributed to page 6.
124
+ - **It abstains instead of inventing.** A glyph nothing identifies — `g03`, a composite font with no
125
+ `/ToUnicode` — publishes nothing. Reading its number as a character puts stray letters into real sentences.
126
+ - **Silence is never an answer.** Every ceiling hit and every part it could not read comes back as a `notice`.
127
+ Since 0.7.0 a `pdf-text-unread` notice names the pages published without their text, and those where a font
128
+ could not be read (reason `font`): no stand-in table is tried, its words are missing and said so. Text a viewer
129
+ would not show raises none.
130
+ - **Unreadable is not scanned.** Since 0.7.0 a page whose text could not be read never counts as a scan, and a
131
+ file none of whose pages gave text is refused (`EXTRACT_FAILED`) instead of being published empty.
132
+ - **It can check itself.** Hand it the text you published, block by block (`pdf-skryba/light`, which loads no
133
+ reader): it names what was lost, invented, glued or split, and returns repairs in YOUR coordinates.
134
+ - **Deterministic.** Same bytes, same document.
135
+ - **Every input is hostile.** Bytes, cross-references, reference hops, page-tree depth, operators, glyphs:
136
+ each bound refuses with a named reason, never a guess.
137
+ - **It talks to nobody.** No network, no filesystem, no credentials — except the `vision` port, yours.
138
+
139
+ ## Prior work
140
+
141
+ Side Liu, Jiangpeng Liu, Jinwen Xin, Guojun Peng and Jiang Ming, **"Beyond the Editing Canvas:
142
+ Evidence Divergence in OOXML-to-LLM Ingestion"**, arXiv:2608.25880 —
143
+ <https://arxiv.org/abs/2608.25880>. About the Office formats, not this one, and its lesson is why this
144
+ reader exists: the extraction path, not the model, decides what a language model sees.
145
+
146
+ ## API
147
+
148
+ Four entries, two of them the minified twins of the others.
149
+
150
+ - `pdf-skryba` — the reader, `extractPdf`, called as `extractPdf(bytes, vision, options?)`; and
151
+ `detectLanguage`; with the types of its options and results (`ExtractOptions`, `PdfDocumentFacts`…).
152
+ - `pdf-skryba/light` — loads no reader. The conservation check: `textConservation`, `lostWords`,
153
+ `placeLostPassages`, `gluedWordEdits`, `cutParagraphEdits`, `noWorse`, `joinNoWorse`, `wordKeysOf`,
154
+ `conservationKey`. Refusals and ceilings: `ReaderError`, `MAX_PAYLOAD_BYTES`. And the types of the
155
+ representation (`IRDoc`, `IRBlock`, `TableData`…).
156
+ - `pdf-skryba/min` and `pdf-skryba/light/min` — the same code, minified.
157
+
158
+ ## Versioning
159
+
160
+ The package follows [Semantic Versioning](https://semver.org): while it is `0.x`, a minor version
161
+ may break the published surface, and a patch never does. Each release is described in
162
+ `CHANGELOG.md`, shipped in the package.
163
+
164
+ ## Licence
165
+
166
+ AGPL-3.0-or-later: run a modified version as a network service and its source must be available to its
167
+ users. Named `skryba` until 0.6.2. Since 0.7.0 the code comes readable (`dist/index.js`), with the same code minified beside
168
+ it (`pdf-skryba/min`). This package ships a bundle and its source map. The Corresponding Source is published at
169
+ <https://github.com/numiastowski-design/pdf-skryba>, as one snapshot for each released version.
package/THIRD-PARTY.md CHANGED
@@ -1,134 +1,134 @@
1
- # Third-party notices
2
-
3
- This package is AGPL-3.0-or-later. It also **redistributes** material owned by others, inside
4
- `dist/index.js`, and carries their notices here.
5
-
6
- ## Adobe CMap resources: `UniCNS-UCS2-H` and `UniJIS-UCS2-H`, code → CID
7
-
8
- `dist/index.js` carries the code → CID tables of Adobe's `UniCNS-UCS2-H` (collection Adobe-CNS1) and
9
- `UniJIS-UCS2-H` (Adobe-Japan1) CMaps, transcribed into three sixteen-bit columns by
10
- `tools/poc/build-cns-cmap.ts` from Adobe's own resources — nothing is taken from any reader. Source:
11
- `adobe-type-tools/cmap-resources`. Their notice:
12
-
13
- > Copyright 1990-2019 Adobe. All rights reserved.
14
- >
15
- > Redistribution and use in source and binary forms, with or without modification, are permitted provided
16
- > that the following conditions are met:
17
- >
18
- > Redistributions of source code must retain the above copyright notice, this list of conditions and the
19
- > following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list
20
- > of conditions and the following disclaimer in the documentation and/or other materials provided with the
21
- > distribution. Neither the name of Adobe nor the names of its contributors may be used to endorse or promote
22
- > products derived from this software without specific prior written permission.
23
- >
24
- > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
25
- > WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
- > PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
27
- > DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28
- > PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
- > HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
- > NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
- > POSSIBILITY OF SUCH DAMAGE.
32
-
33
- **What is carried and what is not.** The 16 418 `cidrange` entries of the Chinese table and the 8 533 of the
34
- Japanese one, whole and exact — neither resource holds a `cidchar` block or a `usecmap`, so nothing is
35
- inherited from another file (the generator refuses loudly if either ever appears). Left out: the codespace
36
- declaration (`<0000>–<D7FF>`, `<E000>–<FFFF>`), which the reader already applies by cutting two-byte codes;
37
- and the single `notdefrange` of each (`<0000>–<001F>` → CID 1), the C0 control characters, which this product
38
- never publishes anyway.
39
-
40
- Until 1/11/2026 the bundle embedded instead the predefined CMaps of pdf.js (`pdfjs-dist/cmaps/*.bcmap`), ~594 KB
41
- for every collection; they left with pdf.js. A PDF that relies on any OTHER predefined CMap (`90ms-RKSJ-H`,
42
- `ETen-B5-H`, the GB and KS collections) falls back on the font's own default width `/DW`, and says so in its tests.
43
-
44
- ## PDFium, CCITT fax decoding
45
-
46
- `dist/index.js` carries a port of the fax (CCITT G3 / G4) decoder of PDFium, in TypeScript:
47
- `src/extractor/codecs/ccitt-fax.ts` and its run-length code tables `ccitt-run-tables.ts`, ported
48
- line for line from PDFium's `core/fxcodec/fax/faxmodule.cpp` (the decoding half). The original
49
- notice, in each file:
50
-
51
- > Copyright 2014 The PDFium Authors. Use of this source code is governed by a BSD-style license
52
- > that can be found in the LICENSE file. Original code copyright 2014 Foxit Software Inc.
53
-
54
- The licence text is PDFium's own (BSD-3-Clause, Google Inc. and the PDFium Authors). Redistribution
55
- is permitted under it, provided this notice and the copyright line travel with the code. They do.
56
-
57
- ## JPEG decoder (jpeg-js 0.4.4), vendored
58
-
59
- `dist/index.js` carries the decoder of jpeg-js 0.4.4, kept as published in
60
- `src/extractor/codecs/vendor/jpeg-js-decoder.cjs`, with one function added (`decodeRaw`: the four-component
61
- components before colour conversion). The decoding code is jpgjs, copyright 2011 notmasteryet, under the
62
- Apache License 2.0 (its notice is in the file). The jpeg-js package is under the BSD 3-Clause licence below
63
- (Copyright (c) 2014, Eugene Ware).
64
-
65
- ```
66
- Copyright (c) 2014, Eugene Ware
67
- All rights reserved.
68
-
69
- Redistribution and use in source and binary forms, with or without
70
- modification, are permitted provided that the following conditions are met:
71
-
72
- 1. Redistributions of source code must retain the above copyright
73
- notice, this list of conditions and the following disclaimer.
74
- 2. Redistributions in binary form must reproduce the above copyright
75
- notice, this list of conditions and the following disclaimer in the
76
- documentation and/or other materials provided with the distribution.
77
- 3. Neither the name of Eugene Ware nor the names of its contributors
78
- may be used to endorse or promote products derived from this software
79
- without specific prior written permission.
80
-
81
- THIS SOFTWARE IS PROVIDED BY EUGENE WARE ''AS IS'' AND ANY
82
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
83
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84
- DISCLAIMED. IN NO EVENT SHALL EUGENE WARE BE LIABLE FOR ANY
85
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
86
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
87
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91
- ```
92
-
93
- ## Dependencies, not redistributed
94
-
95
- These are **not** in the bundle; a consumer installs them and their licences apply to their own
96
- copies: `parse5` (MIT), `@cantoo/pdf-lib` (MIT).
97
-
98
- ## Why this file exists
99
-
100
- A licence scanner reads the registry metadata, which says AGPL only, and a reader of the README
101
- has no reason to suspect embedded resources. Found by the security review of 30/10/2026, before
102
- the first publication — which would have been irreversible.
103
-
104
- ### PDFium licence (verbatim, BSD part)
105
-
106
- ```
107
- // Copyright 2014 The PDFium Authors
108
- //
109
- // Redistribution and use in source and binary forms, with or without
110
- // modification, are permitted provided that the following conditions are
111
- // met:
112
- //
113
- // * Redistributions of source code must retain the above copyright
114
- // notice, this list of conditions and the following disclaimer.
115
- // * Redistributions in binary form must reproduce the above
116
- // copyright notice, this list of conditions and the following disclaimer
117
- // in the documentation and/or other materials provided with the
118
- // distribution.
119
- // * Neither the name of Google Inc. nor the names of its
120
- // contributors may be used to endorse or promote products derived from
121
- // this software without specific prior written permission.
122
- //
123
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
124
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
125
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
126
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
127
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
128
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
129
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
130
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
131
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
132
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
133
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
134
- ```
1
+ # Third-party notices
2
+
3
+ This package is AGPL-3.0-or-later. It also **redistributes** material owned by others, inside
4
+ `dist/index.js`, and carries their notices here.
5
+
6
+ ## Adobe CMap resources: `UniCNS-UCS2-H` and `UniJIS-UCS2-H`, code → CID
7
+
8
+ `dist/index.js` carries the code → CID tables of Adobe's `UniCNS-UCS2-H` (collection Adobe-CNS1) and
9
+ `UniJIS-UCS2-H` (Adobe-Japan1) CMaps, transcribed into three sixteen-bit columns by
10
+ `tools/poc/build-cns-cmap.ts` from Adobe's own resources — nothing is taken from any reader. Source:
11
+ `adobe-type-tools/cmap-resources`. Their notice:
12
+
13
+ > Copyright 1990-2019 Adobe. All rights reserved.
14
+ >
15
+ > Redistribution and use in source and binary forms, with or without modification, are permitted provided
16
+ > that the following conditions are met:
17
+ >
18
+ > Redistributions of source code must retain the above copyright notice, this list of conditions and the
19
+ > following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list
20
+ > of conditions and the following disclaimer in the documentation and/or other materials provided with the
21
+ > distribution. Neither the name of Adobe nor the names of its contributors may be used to endorse or promote
22
+ > products derived from this software without specific prior written permission.
23
+ >
24
+ > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
25
+ > WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26
+ > PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
27
+ > DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28
+ > PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29
+ > HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30
+ > NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
+ > POSSIBILITY OF SUCH DAMAGE.
32
+
33
+ **What is carried and what is not.** The 16 418 `cidrange` entries of the Chinese table and the 8 533 of the
34
+ Japanese one, whole and exact — neither resource holds a `cidchar` block or a `usecmap`, so nothing is
35
+ inherited from another file (the generator refuses loudly if either ever appears). Left out: the codespace
36
+ declaration (`<0000>–<D7FF>`, `<E000>–<FFFF>`), which the reader already applies by cutting two-byte codes;
37
+ and the single `notdefrange` of each (`<0000>–<001F>` → CID 1), the C0 control characters, which this product
38
+ never publishes anyway.
39
+
40
+ Until 1/11/2026 the bundle embedded instead the predefined CMaps of pdf.js (`pdfjs-dist/cmaps/*.bcmap`), ~594 KB
41
+ for every collection; they left with pdf.js. A PDF that relies on any OTHER predefined CMap (`90ms-RKSJ-H`,
42
+ `ETen-B5-H`, the GB and KS collections) falls back on the font's own default width `/DW`, and says so in its tests.
43
+
44
+ ## PDFium, CCITT fax decoding
45
+
46
+ `dist/index.js` carries a port of the fax (CCITT G3 / G4) decoder of PDFium, in TypeScript:
47
+ `src/extractor/codecs/ccitt-fax.ts` and its run-length code tables `ccitt-run-tables.ts`, ported
48
+ line for line from PDFium's `core/fxcodec/fax/faxmodule.cpp` (the decoding half). The original
49
+ notice, in each file:
50
+
51
+ > Copyright 2014 The PDFium Authors. Use of this source code is governed by a BSD-style license
52
+ > that can be found in the LICENSE file. Original code copyright 2014 Foxit Software Inc.
53
+
54
+ The licence text is PDFium's own (BSD-3-Clause, Google Inc. and the PDFium Authors). Redistribution
55
+ is permitted under it, provided this notice and the copyright line travel with the code. They do.
56
+
57
+ ## JPEG decoder (jpeg-js 0.4.4), vendored
58
+
59
+ `dist/index.js` carries the decoder of jpeg-js 0.4.4, kept as published in
60
+ `src/extractor/codecs/vendor/jpeg-js-decoder.cjs`, with one function added (`decodeRaw`: the four-component
61
+ components before colour conversion). The decoding code is jpgjs, copyright 2011 notmasteryet, under the
62
+ Apache License 2.0 (its notice is in the file). The jpeg-js package is under the BSD 3-Clause licence below
63
+ (Copyright (c) 2014, Eugene Ware).
64
+
65
+ ```
66
+ Copyright (c) 2014, Eugene Ware
67
+ All rights reserved.
68
+
69
+ Redistribution and use in source and binary forms, with or without
70
+ modification, are permitted provided that the following conditions are met:
71
+
72
+ 1. Redistributions of source code must retain the above copyright
73
+ notice, this list of conditions and the following disclaimer.
74
+ 2. Redistributions in binary form must reproduce the above copyright
75
+ notice, this list of conditions and the following disclaimer in the
76
+ documentation and/or other materials provided with the distribution.
77
+ 3. Neither the name of Eugene Ware nor the names of its contributors
78
+ may be used to endorse or promote products derived from this software
79
+ without specific prior written permission.
80
+
81
+ THIS SOFTWARE IS PROVIDED BY EUGENE WARE ''AS IS'' AND ANY
82
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
83
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84
+ DISCLAIMED. IN NO EVENT SHALL EUGENE WARE BE LIABLE FOR ANY
85
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
86
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
87
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
88
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91
+ ```
92
+
93
+ ## Dependencies, not redistributed
94
+
95
+ These are **not** in the bundle; a consumer installs them and their licences apply to their own
96
+ copies: `parse5` (MIT), `@cantoo/pdf-lib` (MIT).
97
+
98
+ ## Why this file exists
99
+
100
+ A licence scanner reads the registry metadata, which says AGPL only, and a reader of the README
101
+ has no reason to suspect embedded resources. Found by the security review of 30/10/2026, before
102
+ the first publication — which would have been irreversible.
103
+
104
+ ### PDFium licence (verbatim, BSD part)
105
+
106
+ ```
107
+ // Copyright 2014 The PDFium Authors
108
+ //
109
+ // Redistribution and use in source and binary forms, with or without
110
+ // modification, are permitted provided that the following conditions are
111
+ // met:
112
+ //
113
+ // * Redistributions of source code must retain the above copyright
114
+ // notice, this list of conditions and the following disclaimer.
115
+ // * Redistributions in binary form must reproduce the above
116
+ // copyright notice, this list of conditions and the following disclaimer
117
+ // in the documentation and/or other materials provided with the
118
+ // distribution.
119
+ // * Neither the name of Google Inc. nor the names of its
120
+ // contributors may be used to endorse or promote products derived from
121
+ // this software without specific prior written permission.
122
+ //
123
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
124
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
125
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
126
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
127
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
128
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
129
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
130
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
131
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
132
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
133
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
134
+ ```