@reportwright/pdf 0.1.0-beta.5 → 0.1.0-beta.9
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 +35 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/fflate.js +2341 -0
- package/dist/index.js +1616 -2010
- package/fflate.d.ts +3 -0
- package/index.d.ts +15 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -269,6 +269,34 @@ worker takes the next. `workers` defaults to `os.availableParallelism() - 1`. No
|
|
|
269
269
|
`node:worker_threads`), and with `workers: 1`, the same tasks run one at a time in the calling thread, without the
|
|
270
270
|
heap cap. [`examples/bulk.mjs`](./examples/bulk.mjs).
|
|
271
271
|
|
|
272
|
+
Workers stay warm (unref'd, so they never keep the process alive) for 2 s after a call, so the next call skips their
|
|
273
|
+
start-up; small files are sent several at a time (up to 8, or 256 KB, a worker). Each item has `itemTimeoutMs` (default 120000) in a worker: past it the worker is ended and the item fails with `E_TIMEOUT`; a failed item is never retried, so a batch of stuck or worker-killing files ends with each failing alone (`workers` is 1–64, `memoryMb` 16–16384; with `workers: 1` there is no item timeout or heap cap). Pass `signal` to stop a call (or
|
|
274
|
+
`AbortSignal.timeout(ms)` for a time limit): its workers are ended and `bulk` rejects with the signal's reason. When
|
|
275
|
+
to use it: CPU-heavy items (encrypt, the text of long files) gain from the first call; cheap items on small files
|
|
276
|
+
(extractText or merge of 1–2 page files) gain only once the workers are warm: the first call pays ~25 ms a worker to
|
|
277
|
+
start them, so a one-off batch of under ~100 ms of work is quicker with `workers: 1`.
|
|
278
|
+
|
|
279
|
+
Measured on an Apple M2 (4 performance + 4 efficiency cores, 8 GB, busy laptop), Node 22, files made with
|
|
280
|
+
`toBytes` (small: 200 files of 2 pages, 0.4 MB in all; large: 20 files of 200 pages of text, 2.3 MB in all). Items/s
|
|
281
|
+
from the best of 3 calls in one process (warm), and the first call's ms (cold); results equal to `workers: 1`'s
|
|
282
|
+
(encrypt: the same text once opened). Before: one worker started per call, one item a round trip.
|
|
283
|
+
|
|
284
|
+
| files | task | workers | items/s before | items/s now | first call ms before | now | peak RSS MB |
|
|
285
|
+
|---|---|---|---|---|---|---|---|
|
|
286
|
+
| small | extractText | 1 | 4762 | 4762 | 80 | 78 | 135 |
|
|
287
|
+
| small | extractText | 2 | 1923 | 5882 | 106 | 99 | 246 |
|
|
288
|
+
| small | extractText | 4 | 1754 | 6452 | 123 | 100 | 351 |
|
|
289
|
+
| small | merge | 1 | 2174 | 2128 | 137 | 136 | 148 |
|
|
290
|
+
| small | merge | 4 | 1299 | 3175 | 171 | 142 | 429 |
|
|
291
|
+
| small | encrypt | 1 | 284 | 288 | 733 | 738 | 171 |
|
|
292
|
+
| small | encrypt | 4 | 563 | 813 | 370 | 373 | 465 |
|
|
293
|
+
| large | extractText | 1 | 11 | 11 | 1906 | 1891 | 218 |
|
|
294
|
+
| large | extractText | 4 | 29 | 37 | 684 | 653 | 422 |
|
|
295
|
+
| large | merge | 1 | 143 | 135 | 224 | 220 | 176 |
|
|
296
|
+
| large | merge | 4 | 77 | 196 | 276 | 249 | 429 |
|
|
297
|
+
| large | encrypt | 1 | 149 | 155 | 213 | 212 | 181 |
|
|
298
|
+
| large | encrypt | 4 | 93 | 217 | 218 | 210 | 416 |
|
|
299
|
+
|
|
272
300
|
## Examples
|
|
273
301
|
|
|
274
302
|
| file | what it shows | run |
|
|
@@ -1105,6 +1133,13 @@ bidi algorithm, hyphenation, kerning of the standard fonts, WOFF fonts; popup an
|
|
|
1105
1133
|
|
|
1106
1134
|
## Changes
|
|
1107
1135
|
|
|
1136
|
+
0.1.0-beta.9: stamping every page (`page.draw` then `save()`) is about 35% faster on a 1,000-page file: a page's open
|
|
1137
|
+
graphics states are counted with a byte scan instead of a full parse, and FlateDecode inflates whole, valid zlib
|
|
1138
|
+
streams with Node's zlib (damaged, truncated, raw or over-budget streams still go through fflate as before); the output
|
|
1139
|
+
is byte-identical. `bulk` starts an item's `itemTimeoutMs` clock when its worker is ready, so a respawned worker's
|
|
1140
|
+
start-up no longer fails good files; a stopped export (`timeoutMs` or `signal`) aborts its WritableStream even when
|
|
1141
|
+
the stop lands between two calls.
|
|
1142
|
+
|
|
1108
1143
|
0.1.0-beta.2: a left-to-right shaped cluster in an ActualText span has its text only in the ActualText, so MuPDF
|
|
1109
1144
|
no longer reads it twice (pdf.js, which ignores ActualText, now misses those clusters; poppler, PDFium and
|
|
1110
1145
|
`extractText` read them); `extractText` drops WJ (U+2060) and reads a code a ToUnicode skips as nothing (U+FFFD
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
| Component | Version | License | Used for |
|
|
6
6
|
|---|---|---|---|
|
|
7
|
-
| [fflate](https://github.com/101arrowz/fflate) by Arjun Barrett | 0.8.3 | MIT | Flate (zlib) compression and decompression, bundled into `dist/
|
|
7
|
+
| [fflate](https://github.com/101arrowz/fflate) by Arjun Barrett | 0.8.3 | MIT | Flate (zlib) compression and decompression, bundled into `dist/fflate.js` |
|
|
8
8
|
| Adobe Font Metrics (AFM) for the 14 standard PDF fonts, via [@pdf-lib/standard-fonts](https://github.com/Hopding/standard-fonts) | 1.0.0 | MIT (the package); the AFM files are © Adobe, distributed with permission to use, copy and distribute | widths and metrics of Helvetica, Times, Courier, Symbol and ZapfDingbats (`src/fonts/standard-metrics.js`, generated) |
|
|
9
9
|
| `sRGB-v2-magic.icc` from [Compact-ICC-Profiles](https://github.com/saucecontrol/Compact-ICC-Profiles) by Clinton Ingram | — | CC0 1.0 (public domain) | the sRGB output intent of PDF/A files |
|
|
10
10
|
|