[pdf] Word: PDF to .docx (headings, paragraphs, tables, images, OCR text for scans); worker ops compress, to_word, page_png

This commit is contained in:
2026-11-17 00:18:20 +01:00
parent a400ff88a6
commit fcc9840fdc
9 changed files with 1481 additions and 788 deletions
+234 -233
View File
@@ -1,233 +1,234 @@
# Dependencies and their licences
Every crate and binary Pictor's core uses, with its licence, recorded **before** it is used.
The brief's rule: only components that need no licence deal — MIT, Apache-2.0, BSD, Zlib, MPL-2.0, or a codec the
OS already provides. Nothing paid, copyleft-to-bundle, patent-encumbered or non-commercial.
## The allowed set, as checked by `scripts/deps.mjs`
| Licence (SPDX) | Why it is allowed |
| :-- | :-- |
| MIT, MIT-0 | named in the brief |
| Apache-2.0, Apache-2.0 WITH LLVM-exception | named in the brief |
| BSD-2-Clause, BSD-3-Clause, 0BSD | named in the brief ("BSD") |
| Zlib | named in the brief |
| MPL-2.0 | named in the brief (file-level copyleft: our own changes to such files stay MPL, which suits this repo) |
| ISC | **interpretation, Mark to confirm**: the BSD-style licence of the ISC; OSI calls it functionally the simplified BSD licence |
| Unicode-3.0, Unicode-DFS-2016 | **interpretation, Mark to confirm**: the MIT-style licence of Unicode's data tables; every Rust program that parses identifiers or text pulls it in (`unicode-ident`) |
| BSL-1.0, CC0-1.0 | **interpretation, Mark to confirm**: Boost (MIT-like, no attribution in binaries) and public domain |
An SPDX expression with `OR` passes when one branch passes; `AND` needs every part to pass. Anything else makes the
script exit 1, and the feature that needs it waits (the brief: "it never gets a fallback").
## Direct dependencies
| Crate | Version | Licence | Used by | For |
| :-- | :-- | :-- | :-- | :-- |
| thiserror | 2 | MIT OR Apache-2.0 | all | error types |
| serde, serde_json | 1 | MIT OR Apache-2.0 | worker, pdf, meta, qr | the worker protocol, reports |
| base64 | 0.22 | MIT OR Apache-2.0 | worker | binary payloads in the protocol |
| image | 0.25 | MIT OR Apache-2.0 | raster, pdf, qr | PNG, JPG, WebP, BMP, GIF, TIFF, ICO decode/encode (no default features: only these codecs) |
| kamadak-exif | 0.6 | BSD-2-Clause | meta | reading EXIF (and writing EXIF fixtures in tests) |
| img-parts | 0.4 (dev) | MIT OR Apache-2.0 | meta tests | building PNG and WebP fixtures (meta walks the containers with its own bounds-checked parsers) |
| qrcode | 0.14 | MIT OR Apache-2.0 | qr | QR matrix and SVG |
| lopdf | 0.47 | MIT | pdf, meta | PDF structure: annotations, stamps, the redaction rebuild, encryption, metadata |
| pdfium-render | 0.9.5 | MIT OR Apache-2.0 | pdf | bindings to pdfium (render, text, forms, pages) |
| tempfile | 3 | MIT OR Apache-2.0 | save (and tests) | temporary files next to the target |
| sha2 | 0.11 | MIT OR Apache-2.0 | worker, tests | hashes for fixtures and the fetch scripts' self-check |
| getrandom | 0.4 | MIT OR Apache-2.0 | pdf | the OS random generator, for the AES-256 file key of a password-protected PDF |
| flate2 | 1 (dev) | MIT OR Apache-2.0 | pdf tests | building compressed hostile fixtures (a deflate bomb) |
| windows | 0.62 | MIT OR Apache-2.0 | raster (Windows only), worker | WIC (HEIC), MFTEnumEx (is an HEVC decoder installed?), Job Objects |
| rqrr | 0.11 (dev) | (MIT OR Apache-2.0) AND ISC | qr tests | decoding generated codes back (ISC: see above) |
| proptest | 1 (dev) | MIT OR Apache-2.0 | tests | property tests |
## Binaries (fetched, never in git)
| Binary | Licence | Fetched by |
| :-- | :-- | :-- |
| pdfium (bblanchon/pdfium-binaries, Windows x64) | see "pdfium" below | `scripts/fetch-pdfium.ps1`, sha256-pinned |
### pdfium
Release `chromium/8125` (PDFium 158.0.8125.0), `pdfium-win-x64.tgz`, sha256
`9a964261760cff52570aabf038ab346d3a5034dd8b30d0d5fe8861235d356b8b`, built without V8 and XFA (`args.gn`). It matches
pdfium-render 0.9.5's `pdfium_latest` (= `pdfium_8125`). The archive's `LICENSE` and `licenses/` folder ship beside
the dll (the app's installer copies them). Read from those files on 2026-11-16:
| Component inside pdfium.dll | Licence | In the allowed set? |
| :-- | :-- | :-- |
| the binary build (bblanchon/pdfium-binaries) | MIT | yes |
| PDFium | BSD-3-Clause (+ Apache-2.0 parts) | yes |
| abseil, highway | Apache-2.0 | yes |
| llvm-libc, dragonbox | Apache-2.0 WITH LLVM-exception (dragonbox also BSL-1.0) | yes |
| fast_float, simdutf | MIT | yes |
| lcms2, agg 2.3 | MIT-style permission notice | yes (MIT family) |
| OpenJPEG | BSD-2-Clause | yes |
| zlib | Zlib | yes |
| HarfBuzz | "Old MIT" | yes (MIT family) |
| ICU | Unicode-3.0 | **interpretation** (see above) |
| libpng | PNG Reference Library License v2 (Libpng-2.0, zlib-style) | **interpretation**: zlib-style permissive |
| libjpeg-turbo | IJG + BSD-3-Clause | **interpretation**: IJG is BSD-style (credit in documentation) |
| FreeType | The FreeType Project License (FTL; dual with GPL-2.0, we take FTL) | **interpretation**: BSD-style with a credit clause — the app's About box says "Portions of this software are copyright © The FreeType Project (www.freetype.org). All rights reserved." |
None of these needs a licence deal, is paid, copyleft-to-bundle, patent-encumbered or non-commercial. The four marked
"interpretation" are not named in the brief's list; they are BSD/zlib-style, and **Mark should confirm** them (PDF
support depends on pdfium, which the brief chose).
## OS codecs (not bundled)
| Codec | Provided by | Used for |
| :-- | :-- | :-- |
| HEIF/HEIC through WIC | Windows (HEIF Image Extensions + an HEVC decoder from the Microsoft Store) | decoding iPhone photos; never bundled |
## Every crate in Cargo.lock
Generated by `node scripts/deps.mjs` from `cargo metadata`; do not edit by hand.
<!-- deps:begin -->
141 crates; 0 outside the allowed set.
| Crate | Version | Licence | Allowed |
| :-- | :-- | :-- | :-- |
| adler2 | 2.0.1 | 0BSD OR MIT OR Apache-2.0 | yes |
| aes | 0.9.2 | MIT OR Apache-2.0 | yes |
| alloc-no-stdlib | 2.0.4 | BSD-3-Clause | yes |
| alloc-stdlib | 0.2.4 | BSD-3-Clause | yes |
| autocfg | 1.5.1 | Apache-2.0 OR MIT | yes |
| base64 | 0.22.1 | MIT OR Apache-2.0 | yes |
| bit-set | 0.11.1 | Apache-2.0 OR MIT | yes |
| bit-vec | 0.10.2 | Apache-2.0 OR MIT | yes |
| bitflags | 2.13.2 | MIT OR Apache-2.0 | yes |
| block-buffer | 0.12.1 | MIT OR Apache-2.0 | yes |
| block-padding | 0.4.2 | MIT OR Apache-2.0 | yes |
| borsh | 1.8.1 | MIT OR Apache-2.0 | yes |
| borsh-derive | 1.8.1 | Apache-2.0 | yes |
| brotli-decompressor | 5.0.3 | BSD-3-Clause/MIT | yes |
| bytemuck | 1.25.2 | Zlib OR Apache-2.0 OR MIT | yes |
| byteorder | 1.5.0 | Unlicense OR MIT | yes |
| byteorder-lite | 0.1.0 | Unlicense OR MIT | yes |
| bytes | 1.12.1 | MIT | yes |
| cbc | 0.2.1 | MIT OR Apache-2.0 | yes |
| cfg_aliases | 0.2.2 | MIT | yes |
| cfg-if | 1.0.5 | MIT OR Apache-2.0 | yes |
| chacha20 | 0.10.2 | MIT OR Apache-2.0 | yes |
| chrono | 0.4.45 | MIT OR Apache-2.0 | yes |
| cipher | 0.5.2 | MIT OR Apache-2.0 | yes |
| color_quant | 1.1.0 | MIT | yes |
| const-oid | 0.10.3 | Apache-2.0 OR MIT | yes |
| core_detect | 1.0.0 | MIT/Apache-2.0 | yes |
| cpubits | 0.1.1 | MIT OR Apache-2.0 | yes |
| cpufeatures | 0.3.1 | MIT OR Apache-2.0 | yes |
| crc32fast | 1.5.5 | MIT OR Apache-2.0 | yes |
| crypto-common | 0.2.2 | MIT OR Apache-2.0 | yes |
| digest | 0.11.3 | MIT OR Apache-2.0 | yes |
| ecb | 0.2.1 | MIT OR Apache-2.0 | yes |
| either | 1.19.0 | MIT OR Apache-2.0 | yes |
| encoding_rs | 0.8.44 | (Apache-2.0 OR MIT) AND BSD-3-Clause | yes |
| equivalent | 1.0.3 | Apache-2.0 OR MIT | yes |
| fastrand | 2.5.0 | Apache-2.0 OR MIT | yes |
| fax | 0.2.7 | MIT | yes |
| fdeflate | 0.3.7 | MIT OR Apache-2.0 | yes |
| flate2 | 1.1.11 | MIT OR Apache-2.0 | yes |
| fnv | 1.0.7 | Apache-2.0 / MIT | yes |
| foldhash | 0.2.0 | Zlib | yes |
| g2gen | 1.2.2 | MIT/Apache-2.0 | yes |
| g2p | 1.2.2 | MIT/Apache-2.0 | yes |
| g2poly | 1.2.2 | MIT/Apache-2.0 | yes |
| getrandom | 0.4.3 | MIT OR Apache-2.0 | yes |
| gif | 0.14.2 | MIT OR Apache-2.0 | yes |
| half | 2.7.1 | MIT OR Apache-2.0 | yes |
| hashbrown | 0.17.1 | MIT OR Apache-2.0 | yes |
| hybrid-array | 0.4.15 | MIT OR Apache-2.0 | yes |
| image | 0.25.10 | MIT OR Apache-2.0 | yes |
| image-webp | 0.2.4 | MIT OR Apache-2.0 | yes |
| img-parts | 0.4.2 | MIT OR Apache-2.0 | yes |
| indexmap | 2.14.2 | Apache-2.0 OR MIT | yes |
| inout | 0.2.6 | MIT OR Apache-2.0 | yes |
| itertools | 0.15.0 | MIT OR Apache-2.0 | yes |
| itoa | 1.0.19 | MIT OR Apache-2.0 | yes |
| kamadak-exif | 0.6.2 | BSD-2-Clause | yes |
| libloading | 0.9.1 | ISC | yes |
| log | 0.4.35 | MIT OR Apache-2.0 | yes |
| lopdf | 0.47.0 | MIT | yes |
| lru | 0.18.5 | MIT | yes |
| maybe-owned | 0.3.4 | MIT OR Apache-2.0 | yes |
| md-5 | 0.11.0 | MIT OR Apache-2.0 | yes |
| memchr | 2.8.3 | Unlicense OR MIT | yes |
| miniz_oxide | 0.8.9 | MIT OR Zlib OR Apache-2.0 | yes |
| miniz_oxide | 0.9.1 | MIT OR Zlib OR Apache-2.0 | yes |
| moxcms | 0.8.1 | BSD-3-Clause OR Apache-2.0 | yes |
| multiversion_no_op | 1.0.0 | Apache-2.0 OR MIT | yes |
| mutate_once | 0.1.2 | BSD-2-Clause | yes |
| nom | 8.0.0 | MIT | yes |
| num-traits | 0.2.19 | MIT OR Apache-2.0 | yes |
| once_cell | 1.21.4 | MIT OR Apache-2.0 | yes |
| pdfium-render | 0.9.5 | MIT OR Apache-2.0 | yes |
| piston-float | 1.0.1 | MIT | yes |
| png | 0.18.1 | MIT OR Apache-2.0 | yes |
| proc-macro-crate | 3.5.0 | MIT OR Apache-2.0 | yes |
| proc-macro2 | 1.0.107 | MIT OR Apache-2.0 | yes |
| proptest | 1.12.0 | MIT OR Apache-2.0 | yes |
| pxfm | 0.1.30 | BSD-3-Clause OR Apache-2.0 | yes |
| qrcode | 0.14.1 | MIT OR Apache-2.0 | yes |
| quick-error | 1.2.3 | MIT/Apache-2.0 | yes |
| quick-error | 2.0.1 | MIT/Apache-2.0 | yes |
| quote | 1.0.47 | MIT OR Apache-2.0 | yes |
| rand | 0.10.4 | MIT OR Apache-2.0 | yes |
| rand_core | 0.10.1 | MIT OR Apache-2.0 | yes |
| rand_xorshift | 0.5.0 | MIT OR Apache-2.0 | yes |
| rangemap | 1.8.0 | MIT/Apache-2.0 | yes |
| regex-syntax | 0.8.11 | MIT OR Apache-2.0 | yes |
| rqrr | 0.11.0 | (MIT OR Apache-2.0) AND ISC | yes |
| rustversion | 1.0.23 | MIT OR Apache-2.0 | yes |
| rusty-fork | 0.3.1 | MIT/Apache-2.0 | yes |
| scopeguard | 1.2.0 | MIT OR Apache-2.0 | yes |
| serde | 1.0.229 | MIT OR Apache-2.0 | yes |
| serde_core | 1.0.229 | MIT OR Apache-2.0 | yes |
| serde_derive | 1.0.229 | MIT OR Apache-2.0 | yes |
| serde_json | 1.0.154 | MIT OR Apache-2.0 | yes |
| sha2 | 0.11.1 | MIT OR Apache-2.0 | yes |
| simd-adler32 | 0.3.10 | MIT | yes |
| simdutf8 | 0.1.5 | MIT OR Apache-2.0 | yes |
| stringprep | 0.1.5 | MIT/Apache-2.0 | yes |
| syn | 2.0.119 | MIT OR Apache-2.0 | yes |
| syn | 3.0.10 | MIT OR Apache-2.0 | yes |
| tempfile | 3.27.0 | MIT OR Apache-2.0 | yes |
| thiserror | 2.0.21 | MIT OR Apache-2.0 | yes |
| thiserror-impl | 2.0.21 | MIT OR Apache-2.0 | yes |
| tiff | 0.11.3 | MIT | yes |
| tinyvec | 1.13.3 | Zlib OR Apache-2.0 OR MIT | yes |
| toml_datetime | 1.1.3+spec-1.1.0 | MIT OR Apache-2.0 | yes |
| toml_edit | 0.25.19+spec-1.1.0 | MIT OR Apache-2.0 | yes |
| toml_parser | 1.1.5+spec-1.1.0 | MIT OR Apache-2.0 | yes |
| typenum | 1.20.1 | MIT OR Apache-2.0 | yes |
| unarray | 0.1.4 | MIT OR Apache-2.0 | yes |
| unicode-bidi | 0.3.18 | MIT OR Apache-2.0 | yes |
| unicode-ident | 1.0.27 | (MIT OR Apache-2.0) AND Unicode-3.0 | yes |
| unicode-normalization | 0.1.26 | (MIT OR Apache-2.0) AND Unicode-3.0 | yes |
| unicode-properties | 0.1.5 | (MIT OR Apache-2.0) AND Unicode-3.0 | yes |
| utf16string | 0.2.0 | MIT OR Apache-2.0 | yes |
| vecmath | 1.0.0 | MIT | yes |
| wait-timeout | 0.2.1 | MIT/Apache-2.0 | yes |
| weezl | 0.1.12 | MIT OR Apache-2.0 | yes |
| weezl | 0.2.1 | MIT OR Apache-2.0 | yes |
| windows | 0.62.2 | MIT OR Apache-2.0 | yes |
| windows-collections | 0.3.2 | MIT OR Apache-2.0 | yes |
| windows-core | 0.62.2 | MIT OR Apache-2.0 | yes |
| windows-future | 0.3.2 | MIT OR Apache-2.0 | yes |
| windows-implement | 0.60.2 | MIT OR Apache-2.0 | yes |
| windows-interface | 0.59.3 | MIT OR Apache-2.0 | yes |
| windows-link | 0.2.1 | MIT OR Apache-2.0 | yes |
| windows-numerics | 0.3.1 | MIT OR Apache-2.0 | yes |
| windows-result | 0.4.1 | MIT OR Apache-2.0 | yes |
| windows-strings | 0.5.1 | MIT OR Apache-2.0 | yes |
| windows-sys | 0.61.2 | MIT OR Apache-2.0 | yes |
| windows-threading | 0.2.1 | MIT OR Apache-2.0 | yes |
| winnow | 1.0.5 | MIT | yes |
| zerocopy | 0.8.63 | BSD-2-Clause OR Apache-2.0 OR MIT | yes |
| zerocopy-derive | 0.8.63 | BSD-2-Clause OR Apache-2.0 OR MIT | yes |
| zlib-rs | 0.6.8 | Zlib | yes |
| zmij | 1.0.23 | MIT | yes |
| zune-core | 0.5.3 | MIT OR Apache-2.0 OR Zlib | yes |
| zune-jpeg | 0.5.15 | MIT OR Apache-2.0 OR Zlib | yes |
<!-- deps:end -->
# Dependencies and their licences
Every crate and binary Pictor's core uses, with its licence, recorded **before** it is used.
The brief's rule: only components that need no licence deal — MIT, Apache-2.0, BSD, Zlib, MPL-2.0, or a codec the
OS already provides. Nothing paid, copyleft-to-bundle, patent-encumbered or non-commercial.
## The allowed set, as checked by `scripts/deps.mjs`
| Licence (SPDX) | Why it is allowed |
| :-- | :-- |
| MIT, MIT-0 | named in the brief |
| Apache-2.0, Apache-2.0 WITH LLVM-exception | named in the brief |
| BSD-2-Clause, BSD-3-Clause, 0BSD | named in the brief ("BSD") |
| Zlib | named in the brief |
| MPL-2.0 | named in the brief (file-level copyleft: our own changes to such files stay MPL, which suits this repo) |
| ISC | **interpretation, Mark to confirm**: the BSD-style licence of the ISC; OSI calls it functionally the simplified BSD licence |
| Unicode-3.0, Unicode-DFS-2016 | **interpretation, Mark to confirm**: the MIT-style licence of Unicode's data tables; every Rust program that parses identifiers or text pulls it in (`unicode-ident`) |
| BSL-1.0, CC0-1.0 | **interpretation, Mark to confirm**: Boost (MIT-like, no attribution in binaries) and public domain |
An SPDX expression with `OR` passes when one branch passes; `AND` needs every part to pass. Anything else makes the
script exit 1, and the feature that needs it waits (the brief: "it never gets a fallback").
## Direct dependencies
| Crate | Version | Licence | Used by | For |
| :-- | :-- | :-- | :-- | :-- |
| thiserror | 2 | MIT OR Apache-2.0 | all | error types |
| serde, serde_json | 1 | MIT OR Apache-2.0 | worker, pdf, meta, qr | the worker protocol, reports |
| base64 | 0.22 | MIT OR Apache-2.0 | worker | binary payloads in the protocol |
| image | 0.25 | MIT OR Apache-2.0 | raster, pdf, qr | PNG, JPG, WebP, BMP, GIF, TIFF, ICO decode/encode (no default features: only these codecs) |
| kamadak-exif | 0.6 | BSD-2-Clause | meta | reading EXIF (and writing EXIF fixtures in tests) |
| img-parts | 0.4 (dev) | MIT OR Apache-2.0 | meta tests | building PNG and WebP fixtures (meta walks the containers with its own bounds-checked parsers) |
| qrcode | 0.14 | MIT OR Apache-2.0 | qr | QR matrix and SVG |
| lopdf | 0.47 | MIT | pdf, meta | PDF structure: annotations, stamps, the redaction rebuild, encryption, metadata |
| pdfium-render | 0.9.5 | MIT OR Apache-2.0 | pdf | bindings to pdfium (render, text, forms, pages) |
| docx-rs | 0.4 | MIT | pdf | PDF to Word: writing the .docx (headings, runs, tables, inline images) |
| tempfile | 3 | MIT OR Apache-2.0 | save (and tests) | temporary files next to the target |
| sha2 | 0.11 | MIT OR Apache-2.0 | worker, tests | hashes for fixtures and the fetch scripts' self-check |
| getrandom | 0.4 | MIT OR Apache-2.0 | pdf | the OS random generator, for the AES-256 file key of a password-protected PDF |
| flate2 | 1 (dev) | MIT OR Apache-2.0 | pdf tests | building compressed hostile fixtures (a deflate bomb) |
| windows | 0.62 | MIT OR Apache-2.0 | raster (Windows only), worker | WIC (HEIC), MFTEnumEx (is an HEVC decoder installed?), Job Objects |
| rqrr | 0.11 (dev) | (MIT OR Apache-2.0) AND ISC | qr tests | decoding generated codes back (ISC: see above) |
| proptest | 1 (dev) | MIT OR Apache-2.0 | tests | property tests |
## Binaries (fetched, never in git)
| Binary | Licence | Fetched by |
| :-- | :-- | :-- |
| pdfium (bblanchon/pdfium-binaries, Windows x64) | see "pdfium" below | `scripts/fetch-pdfium.ps1`, sha256-pinned |
### pdfium
Release `chromium/8125` (PDFium 158.0.8125.0), `pdfium-win-x64.tgz`, sha256
`9a964261760cff52570aabf038ab346d3a5034dd8b30d0d5fe8861235d356b8b`, built without V8 and XFA (`args.gn`). It matches
pdfium-render 0.9.5's `pdfium_latest` (= `pdfium_8125`). The archive's `LICENSE` and `licenses/` folder ship beside
the dll (the app's installer copies them). Read from those files on 2026-11-16:
| Component inside pdfium.dll | Licence | In the allowed set? |
| :-- | :-- | :-- |
| the binary build (bblanchon/pdfium-binaries) | MIT | yes |
| PDFium | BSD-3-Clause (+ Apache-2.0 parts) | yes |
| abseil, highway | Apache-2.0 | yes |
| llvm-libc, dragonbox | Apache-2.0 WITH LLVM-exception (dragonbox also BSL-1.0) | yes |
| fast_float, simdutf | MIT | yes |
| lcms2, agg 2.3 | MIT-style permission notice | yes (MIT family) |
| OpenJPEG | BSD-2-Clause | yes |
| zlib | Zlib | yes |
| HarfBuzz | "Old MIT" | yes (MIT family) |
| ICU | Unicode-3.0 | **interpretation** (see above) |
| libpng | PNG Reference Library License v2 (Libpng-2.0, zlib-style) | **interpretation**: zlib-style permissive |
| libjpeg-turbo | IJG + BSD-3-Clause | **interpretation**: IJG is BSD-style (credit in documentation) |
| FreeType | The FreeType Project License (FTL; dual with GPL-2.0, we take FTL) | **interpretation**: BSD-style with a credit clause — the app's About box says "Portions of this software are copyright © The FreeType Project (www.freetype.org). All rights reserved." |
None of these needs a licence deal, is paid, copyleft-to-bundle, patent-encumbered or non-commercial. The four marked
"interpretation" are not named in the brief's list; they are BSD/zlib-style, and **Mark should confirm** them (PDF
support depends on pdfium, which the brief chose).
## OS codecs (not bundled)
| Codec | Provided by | Used for |
| :-- | :-- | :-- |
| HEIF/HEIC through WIC | Windows (HEIF Image Extensions + an HEVC decoder from the Microsoft Store) | decoding iPhone photos; never bundled |
## Every crate in Cargo.lock
Generated by `node scripts/deps.mjs` from `cargo metadata`; do not edit by hand.
<!-- deps:begin -->
141 crates; 0 outside the allowed set.
| Crate | Version | Licence | Allowed |
| :-- | :-- | :-- | :-- |
| adler2 | 2.0.1 | 0BSD OR MIT OR Apache-2.0 | yes |
| aes | 0.9.2 | MIT OR Apache-2.0 | yes |
| alloc-no-stdlib | 2.0.4 | BSD-3-Clause | yes |
| alloc-stdlib | 0.2.4 | BSD-3-Clause | yes |
| autocfg | 1.5.1 | Apache-2.0 OR MIT | yes |
| base64 | 0.22.1 | MIT OR Apache-2.0 | yes |
| bit-set | 0.11.1 | Apache-2.0 OR MIT | yes |
| bit-vec | 0.10.2 | Apache-2.0 OR MIT | yes |
| bitflags | 2.13.2 | MIT OR Apache-2.0 | yes |
| block-buffer | 0.12.1 | MIT OR Apache-2.0 | yes |
| block-padding | 0.4.2 | MIT OR Apache-2.0 | yes |
| borsh | 1.8.1 | MIT OR Apache-2.0 | yes |
| borsh-derive | 1.8.1 | Apache-2.0 | yes |
| brotli-decompressor | 5.0.3 | BSD-3-Clause/MIT | yes |
| bytemuck | 1.25.2 | Zlib OR Apache-2.0 OR MIT | yes |
| byteorder | 1.5.0 | Unlicense OR MIT | yes |
| byteorder-lite | 0.1.0 | Unlicense OR MIT | yes |
| bytes | 1.12.1 | MIT | yes |
| cbc | 0.2.1 | MIT OR Apache-2.0 | yes |
| cfg_aliases | 0.2.2 | MIT | yes |
| cfg-if | 1.0.5 | MIT OR Apache-2.0 | yes |
| chacha20 | 0.10.2 | MIT OR Apache-2.0 | yes |
| chrono | 0.4.45 | MIT OR Apache-2.0 | yes |
| cipher | 0.5.2 | MIT OR Apache-2.0 | yes |
| color_quant | 1.1.0 | MIT | yes |
| const-oid | 0.10.3 | Apache-2.0 OR MIT | yes |
| core_detect | 1.0.0 | MIT/Apache-2.0 | yes |
| cpubits | 0.1.1 | MIT OR Apache-2.0 | yes |
| cpufeatures | 0.3.1 | MIT OR Apache-2.0 | yes |
| crc32fast | 1.5.5 | MIT OR Apache-2.0 | yes |
| crypto-common | 0.2.2 | MIT OR Apache-2.0 | yes |
| digest | 0.11.3 | MIT OR Apache-2.0 | yes |
| ecb | 0.2.1 | MIT OR Apache-2.0 | yes |
| either | 1.19.0 | MIT OR Apache-2.0 | yes |
| encoding_rs | 0.8.44 | (Apache-2.0 OR MIT) AND BSD-3-Clause | yes |
| equivalent | 1.0.3 | Apache-2.0 OR MIT | yes |
| fastrand | 2.5.0 | Apache-2.0 OR MIT | yes |
| fax | 0.2.7 | MIT | yes |
| fdeflate | 0.3.7 | MIT OR Apache-2.0 | yes |
| flate2 | 1.1.11 | MIT OR Apache-2.0 | yes |
| fnv | 1.0.7 | Apache-2.0 / MIT | yes |
| foldhash | 0.2.0 | Zlib | yes |
| g2gen | 1.2.2 | MIT/Apache-2.0 | yes |
| g2p | 1.2.2 | MIT/Apache-2.0 | yes |
| g2poly | 1.2.2 | MIT/Apache-2.0 | yes |
| getrandom | 0.4.3 | MIT OR Apache-2.0 | yes |
| gif | 0.14.2 | MIT OR Apache-2.0 | yes |
| half | 2.7.1 | MIT OR Apache-2.0 | yes |
| hashbrown | 0.17.1 | MIT OR Apache-2.0 | yes |
| hybrid-array | 0.4.15 | MIT OR Apache-2.0 | yes |
| image | 0.25.10 | MIT OR Apache-2.0 | yes |
| image-webp | 0.2.4 | MIT OR Apache-2.0 | yes |
| img-parts | 0.4.2 | MIT OR Apache-2.0 | yes |
| indexmap | 2.14.2 | Apache-2.0 OR MIT | yes |
| inout | 0.2.6 | MIT OR Apache-2.0 | yes |
| itertools | 0.15.0 | MIT OR Apache-2.0 | yes |
| itoa | 1.0.19 | MIT OR Apache-2.0 | yes |
| kamadak-exif | 0.6.2 | BSD-2-Clause | yes |
| libloading | 0.9.1 | ISC | yes |
| log | 0.4.35 | MIT OR Apache-2.0 | yes |
| lopdf | 0.47.0 | MIT | yes |
| lru | 0.18.5 | MIT | yes |
| maybe-owned | 0.3.4 | MIT OR Apache-2.0 | yes |
| md-5 | 0.11.0 | MIT OR Apache-2.0 | yes |
| memchr | 2.8.3 | Unlicense OR MIT | yes |
| miniz_oxide | 0.8.9 | MIT OR Zlib OR Apache-2.0 | yes |
| miniz_oxide | 0.9.1 | MIT OR Zlib OR Apache-2.0 | yes |
| moxcms | 0.8.1 | BSD-3-Clause OR Apache-2.0 | yes |
| multiversion_no_op | 1.0.0 | Apache-2.0 OR MIT | yes |
| mutate_once | 0.1.2 | BSD-2-Clause | yes |
| nom | 8.0.0 | MIT | yes |
| num-traits | 0.2.19 | MIT OR Apache-2.0 | yes |
| once_cell | 1.21.4 | MIT OR Apache-2.0 | yes |
| pdfium-render | 0.9.5 | MIT OR Apache-2.0 | yes |
| piston-float | 1.0.1 | MIT | yes |
| png | 0.18.1 | MIT OR Apache-2.0 | yes |
| proc-macro-crate | 3.5.0 | MIT OR Apache-2.0 | yes |
| proc-macro2 | 1.0.107 | MIT OR Apache-2.0 | yes |
| proptest | 1.12.0 | MIT OR Apache-2.0 | yes |
| pxfm | 0.1.30 | BSD-3-Clause OR Apache-2.0 | yes |
| qrcode | 0.14.1 | MIT OR Apache-2.0 | yes |
| quick-error | 1.2.3 | MIT/Apache-2.0 | yes |
| quick-error | 2.0.1 | MIT/Apache-2.0 | yes |
| quote | 1.0.47 | MIT OR Apache-2.0 | yes |
| rand | 0.10.4 | MIT OR Apache-2.0 | yes |
| rand_core | 0.10.1 | MIT OR Apache-2.0 | yes |
| rand_xorshift | 0.5.0 | MIT OR Apache-2.0 | yes |
| rangemap | 1.8.0 | MIT/Apache-2.0 | yes |
| regex-syntax | 0.8.11 | MIT OR Apache-2.0 | yes |
| rqrr | 0.11.0 | (MIT OR Apache-2.0) AND ISC | yes |
| rustversion | 1.0.23 | MIT OR Apache-2.0 | yes |
| rusty-fork | 0.3.1 | MIT/Apache-2.0 | yes |
| scopeguard | 1.2.0 | MIT OR Apache-2.0 | yes |
| serde | 1.0.229 | MIT OR Apache-2.0 | yes |
| serde_core | 1.0.229 | MIT OR Apache-2.0 | yes |
| serde_derive | 1.0.229 | MIT OR Apache-2.0 | yes |
| serde_json | 1.0.154 | MIT OR Apache-2.0 | yes |
| sha2 | 0.11.1 | MIT OR Apache-2.0 | yes |
| simd-adler32 | 0.3.10 | MIT | yes |
| simdutf8 | 0.1.5 | MIT OR Apache-2.0 | yes |
| stringprep | 0.1.5 | MIT/Apache-2.0 | yes |
| syn | 2.0.119 | MIT OR Apache-2.0 | yes |
| syn | 3.0.10 | MIT OR Apache-2.0 | yes |
| tempfile | 3.27.0 | MIT OR Apache-2.0 | yes |
| thiserror | 2.0.21 | MIT OR Apache-2.0 | yes |
| thiserror-impl | 2.0.21 | MIT OR Apache-2.0 | yes |
| tiff | 0.11.3 | MIT | yes |
| tinyvec | 1.13.3 | Zlib OR Apache-2.0 OR MIT | yes |
| toml_datetime | 1.1.3+spec-1.1.0 | MIT OR Apache-2.0 | yes |
| toml_edit | 0.25.19+spec-1.1.0 | MIT OR Apache-2.0 | yes |
| toml_parser | 1.1.5+spec-1.1.0 | MIT OR Apache-2.0 | yes |
| typenum | 1.20.1 | MIT OR Apache-2.0 | yes |
| unarray | 0.1.4 | MIT OR Apache-2.0 | yes |
| unicode-bidi | 0.3.18 | MIT OR Apache-2.0 | yes |
| unicode-ident | 1.0.27 | (MIT OR Apache-2.0) AND Unicode-3.0 | yes |
| unicode-normalization | 0.1.26 | (MIT OR Apache-2.0) AND Unicode-3.0 | yes |
| unicode-properties | 0.1.5 | (MIT OR Apache-2.0) AND Unicode-3.0 | yes |
| utf16string | 0.2.0 | MIT OR Apache-2.0 | yes |
| vecmath | 1.0.0 | MIT | yes |
| wait-timeout | 0.2.1 | MIT/Apache-2.0 | yes |
| weezl | 0.1.12 | MIT OR Apache-2.0 | yes |
| weezl | 0.2.1 | MIT OR Apache-2.0 | yes |
| windows | 0.62.2 | MIT OR Apache-2.0 | yes |
| windows-collections | 0.3.2 | MIT OR Apache-2.0 | yes |
| windows-core | 0.62.2 | MIT OR Apache-2.0 | yes |
| windows-future | 0.3.2 | MIT OR Apache-2.0 | yes |
| windows-implement | 0.60.2 | MIT OR Apache-2.0 | yes |
| windows-interface | 0.59.3 | MIT OR Apache-2.0 | yes |
| windows-link | 0.2.1 | MIT OR Apache-2.0 | yes |
| windows-numerics | 0.3.1 | MIT OR Apache-2.0 | yes |
| windows-result | 0.4.1 | MIT OR Apache-2.0 | yes |
| windows-strings | 0.5.1 | MIT OR Apache-2.0 | yes |
| windows-sys | 0.61.2 | MIT OR Apache-2.0 | yes |
| windows-threading | 0.2.1 | MIT OR Apache-2.0 | yes |
| winnow | 1.0.5 | MIT | yes |
| zerocopy | 0.8.63 | BSD-2-Clause OR Apache-2.0 OR MIT | yes |
| zerocopy-derive | 0.8.63 | BSD-2-Clause OR Apache-2.0 OR MIT | yes |
| zlib-rs | 0.6.8 | Zlib | yes |
| zmij | 1.0.23 | MIT | yes |
| zune-core | 0.5.3 | MIT OR Apache-2.0 OR Zlib | yes |
| zune-jpeg | 0.5.15 | MIT OR Apache-2.0 OR Zlib | yes |
<!-- deps:end -->
+111 -106
View File
@@ -1,106 +1,111 @@
# Formats and the worker protocol
What Pictor's core reads and writes, which library does each PDF operation, and how the app talks to
`pictor-worker`. Version 1 (Day 1, core v0.1.0). The `.pictor` document format arrives on Day 3 and gets its own
section here.
## Images (crates/raster, crates/meta)
| Format | Read | Write | Metadata strip |
| :-- | :-- | :-- | :-- |
| PNG | yes | yes | container-level (eXIf, tEXt, zTXt, iTXt, tIME dropped); pixels identical |
| JPEG | yes, EXIF orientation applied | yes (quality 88 default; alpha onto white) | container-level (APP1 Exif/XMP, APP13 IPTC, COM, other APPn dropped; JFIF, ICC, Adobe kept); orientation ≠ 1 kept as a 36-byte EXIF; pixels identical |
| WebP | yes | lossless only (the image crate's encoder) | EXIF and XMP chunks dropped, VP8X flags fixed |
| GIF | yes (first frame for conversion) | single frame | block-level (comments, XMP dropped; every frame and the loop kept) |
| TIFF | yes | yes | re-encoded losslessly (uncompressed; ICC and orientation are lost: a known gap); multi-page refused |
| BMP | yes | yes | (no metadata) |
| ICO | yes | 256/48/32/16 px | — |
| HEIC/HEIF | Windows only, through WIC with the codecs Windows has; never bundled | no | convert to JPG first |
| AVIF | recognised; decoding needs the AV1 extension (reported as missing) | no | — |
Formats are recognised by their content (magic bytes), never by the extension. Caps (`pictor_raster::Limits`):
128 million pixels, 512 MiB input, 1 GiB decoded; the pixel count is checked from the header before decoding.
HEIC needs two Store extensions: "HEIF Image Extensions" (free, `9PMMSR1CGPWG`) and an HEVC decoder ("HEVC Video
Extensions", `9NMZLZ57R3T7`, US$0.99; checked 2026-11-16). `heif_support()` says which one is missing.
## PDF (crates/pdf)
Coordinates between the app and the core are in **view space**: points (1/72 inch) from the top-left corner of the
page as displayed (the crop box, `/Rotate` applied). `geometry::PageFrame` converts to PDF user space.
| Operation | Library | Why |
| :-- | :-- | :-- |
| open, page sizes, render, text, search, outline | pdfium | what Chrome and Edge use: a file Edge opens, Pictor opens |
| reorder, rotate, delete, insert blank, extract, split | lopdf, in place | keeps the form, bookmarks and metadata; deleted pages and their annotations and fields really leave the file (pdfium's save keeps unreferenced objects) |
| merge | pdfium page import | handles inherited resources across files; merged forms keep their look but are no longer fillable; bookmarks are not carried over |
| images → PDF | lopdf | a JPEG is embedded byte for byte (no re-encoding); others are stored losslessly with an alpha mask |
| PDF → PNG/JPG | pdfium | rendering |
| form fill | lopdf (`/V`, `/AS` with each checkbox's own on-state) + `NeedAppearances`, then pdfium builds the appearances while rendering with the form | the appearance comes from the same engine as Edge's, Czech letters included; viewers that ignore the flag show the value too |
| annotations: highlight, underline, strike, note, free text, ink, rectangle, ellipse, line/arrow | lopdf, each with its own appearance stream | looks the same in every viewer; free text uses Helvetica with WinAnsi plus the Central European letters through `/Differences` |
| visual signature (stamp) | lopdf: the image goes into the page content, the old content wrapped in `q … Q` | it is part of the page, not a movable annotation |
| flatten | pdfium `FPDFPage_Flatten`, then lopdf drops the form and orphans | |
| password on | lopdf, AES-256 (V5/R6), no permission restrictions | pdfium cannot write encryption; qpdf was not needed |
| password off | lopdf decrypting load + plain save | |
| true redaction | pdfium render + lopdf rebuild (below) | |
### True redaction
Each redacted page is rendered by pdfium at 200 dpi (annotations and form fields included), the boxes are painted
black into the pixels, and the page is rebuilt as that one JPEG image (same object number, displayed size kept,
`/Rotate 0`). The page's old annotations go, fields that lived only there go, resources inherited from the page
tree are pushed down to the pages that use them, and the document loses `/Info`, every `/Metadata` and
`/PieceInfo`, the struct tree (its ActualText can hold text), bookmarks, attachments, document JavaScript and
non-destination open actions. Hidden layers (`/OCProperties`) go when no remaining page uses them; otherwise they
stay and the result carries a warning naming those pages. Then every unreferenced object is pruned and the file is
written fresh (no incremental history). The other pages' objects are written back byte for byte.
Cost: the text of a redacted page is no longer selectable or searchable. A content-stream rewrite (cutting out only
what is under the box) was not used: it needs a full content-stream interpreter (fonts and glyph positions, form
XObjects, inline images, clipping, shadings, Type 3 fonts), and any gap leaves text behind. The tests
(`crates/pdf/tests/redaction.rs`) check pdfium text extraction, a lopdf scan of every string, name and stream (raw
and decompressed), and a raw byte grep.
## The worker protocol (crates/worker), version 1
`pictor-worker.exe` reads one JSON object per line on stdin and answers one per line on stdout. Its first line is
`{"hello": "pictor-worker", "protocol": 1, "version": "0.1.0"}`; the client refuses another protocol.
```
→ {"id": 7, "op": "pdf.render", "args": {"doc": 1, "page": 0, "width": 1200}}
← {"id": 7, "ok": {"png": "<base64>", "width": 1200, "height": 1553}}
← {"id": 7, "err": {"kind": "needs_password", "message": "This PDF is password-protected. Enter its password to open it."}}
```
Error kinds: `needs_password`, `wrong_password`, `damaged`, `unsupported`, `too_large`, `codec_missing`, `invalid`,
`io`, `exists`, `not_open`, `cannot_reach_target`, `engine_missing`; the client adds `timed_out`,
`out_of_memory`, `crashed` and `spawn`. `message` is a plain sentence for the user.
| Operation | Arguments | Result |
| :-- | :-- | :-- |
| `pdf.open` | `path`, `password?` | `doc` (a session id), `info` (pages with sizes and labels, outline, `has_form`) |
| `pdf.close` | `doc` | — |
| `pdf.render` | `doc`, `page`, `width` (px) | `png` (base64), `width`, `height` |
| `pdf.text` | `doc` | `pages`: text per page |
| `pdf.search` | `doc`, `query` | `hits`: `{page, rects}` in view space (max 2000) |
| `pdf.form` | `doc` | `fields`: name, kind, value, options, page, rect, read_only, multiline |
| `pdf.save` | `doc`, `edits` (see `pictor_pdf::Edits`), `output`, `mode` (`new` / `overwrite`) | `path`, `bytes`, `bak?`, `warnings` |
| `pdf.extract` | `doc`, `pages`, `output` | `path` |
| `pdf.to_images` | `doc`, `pages`, `dpi`, `format`, `output` (with `{n}`) | `paths` |
| `pdf.merge` | `inputs` [{`path`, `password?`}], `output` | `path` |
| `pdf.split` | `path`, `password?`, `ranges` ("1-3, 5, 8-"), `output` (with `{n}`) | `paths` |
| `pdf.from_images` | `inputs`, `output`, `fit` (`image`/`a4`/`letter`), `margin` | `path` |
| `image.probe` | `path` | `format`, `width`, `height`, `has_alpha`, `frames`, `bytes` |
| `image.thumb` | `path`, `max` | `png`, original `width`, `height` |
| `image.convert` | `input`, `output`, `format`, `quality?`, `crop?`, `rotate?`, `resize?`, `preset?`, `target_bytes?`, `overwrite?` | `path`, `bytes`, `format`, `width`, `height` |
| `image.heif_support` | — | `support` |
| `meta.read` | `path` | `report` (items by group), `groups` (with labels) |
| `meta.strip` | `input`, `output`, `overwrite?` | `path`, `removed` |
| `qr.render` | `payload`, `level`, `style`, `logo?` (a path) | `png`, `svg`, `level_used`, `size`, `text` |
Saving: `mode: new` refuses to replace a file (the app picks `<name>-edited.pdf`); `overwrite` writes
`<file>.bak` first, then replaces the file in one rename (`crates/save`).
Caps: files over 1 GB are refused; the client runs the worker in a Job Object (2 GB by default, killed with the
app) and gives each request a time cap; a worker that hangs or dies is replaced on the next request (open documents
must then be opened again).
# Formats and the worker protocol
What Pictor's core reads and writes, which library does each PDF operation, and how the app talks to
`pictor-worker`. Version 1 (Day 1, core v0.1.0). The `.pictor` document format arrives on Day 3 and gets its own
section here.
## Images (crates/raster, crates/meta)
| Format | Read | Write | Metadata strip |
| :-- | :-- | :-- | :-- |
| PNG | yes | yes | container-level (eXIf, tEXt, zTXt, iTXt, tIME dropped); pixels identical |
| JPEG | yes, EXIF orientation applied | yes (quality 88 default; alpha onto white) | container-level (APP1 Exif/XMP, APP13 IPTC, COM, other APPn dropped; JFIF, ICC, Adobe kept); orientation ≠ 1 kept as a 36-byte EXIF; pixels identical |
| WebP | yes | lossless only (the image crate's encoder) | EXIF and XMP chunks dropped, VP8X flags fixed |
| GIF | yes (first frame for conversion) | single frame | block-level (comments, XMP dropped; every frame and the loop kept) |
| TIFF | yes | yes | re-encoded losslessly (uncompressed; ICC and orientation are lost: a known gap); multi-page refused |
| BMP | yes | yes | (no metadata) |
| ICO | yes | 256/48/32/16 px | — |
| HEIC/HEIF | Windows only, through WIC with the codecs Windows has; never bundled | no | convert to JPG first |
| AVIF | recognised; decoding needs the AV1 extension (reported as missing) | no | — |
Formats are recognised by their content (magic bytes), never by the extension. Caps (`pictor_raster::Limits`):
128 million pixels, 512 MiB input, 1 GiB decoded; the pixel count is checked from the header before decoding.
HEIC needs two Store extensions: "HEIF Image Extensions" (free, `9PMMSR1CGPWG`) and an HEVC decoder ("HEVC Video
Extensions", `9NMZLZ57R3T7`, US$0.99; checked 2026-11-16). `heif_support()` says which one is missing.
## PDF (crates/pdf)
Coordinates between the app and the core are in **view space**: points (1/72 inch) from the top-left corner of the
page as displayed (the crop box, `/Rotate` applied). `geometry::PageFrame` converts to PDF user space.
| Operation | Library | Why |
| :-- | :-- | :-- |
| open, page sizes, render, text, search, outline | pdfium | what Chrome and Edge use: a file Edge opens, Pictor opens |
| reorder, rotate, delete, insert blank, extract, split | lopdf, in place | keeps the form, bookmarks and metadata; deleted pages and their annotations and fields really leave the file (pdfium's save keeps unreferenced objects) |
| merge | pdfium page import | handles inherited resources across files; merged forms keep their look but are no longer fillable; bookmarks are not carried over |
| images → PDF | lopdf | a JPEG is embedded byte for byte (no re-encoding); others are stored losslessly with an alpha mask |
| PDF → PNG/JPG | pdfium | rendering |
| form fill | lopdf (`/V`, `/AS` with each checkbox's own on-state) + `NeedAppearances`, then pdfium builds the appearances while rendering with the form | the appearance comes from the same engine as Edge's, Czech letters included; viewers that ignore the flag show the value too |
| annotations: highlight, underline, strike, note, free text, ink, rectangle, ellipse, line/arrow | lopdf, each with its own appearance stream | looks the same in every viewer; free text uses Helvetica with WinAnsi plus the Central European letters through `/Differences` |
| visual signature (stamp) | lopdf: the image goes into the page content, the old content wrapped in `q … Q` | it is part of the page, not a movable annotation |
| flatten | pdfium `FPDFPage_Flatten`, then lopdf drops the form and orphans | |
| password on | lopdf, AES-256 (V5/R6), no permission restrictions | pdfium cannot write encryption; qpdf was not needed |
| password off | lopdf decrypting load + plain save | |
| true redaction | pdfium render + lopdf rebuild (below) | |
| compress presets (Day 2) | lopdf: images capped at the largest page side × the preset's dpi and re-encoded as JPEG (E-mail 120 → 96 → 72 dpi until ≤ 5 MB, Web 150, Print 300); Flate everywhere; object streams | text, fonts and vectors untouched, so text stays extractable; fonts are not subset (gap) |
| PDF to Word (Day 2) | pdfium characters (box, size, weight, slant) → lines, segments, tables, paragraphs, headings; images at their place; docx-rs writes the .docx | "Layout is approximate"; scanned pages are reported, and OCR text from Fundamentum's Lector can be passed in |
### True redaction
Each redacted page is rendered by pdfium at 200 dpi (annotations and form fields included), the boxes are painted
black into the pixels, and the page is rebuilt as that one JPEG image (same object number, displayed size kept,
`/Rotate 0`). The page's old annotations go, fields that lived only there go, resources inherited from the page
tree are pushed down to the pages that use them, and the document loses `/Info`, every `/Metadata` and
`/PieceInfo`, the struct tree (its ActualText can hold text), bookmarks, attachments, document JavaScript and
non-destination open actions. Hidden layers (`/OCProperties`) go when no remaining page uses them; otherwise they
stay and the result carries a warning naming those pages. Then every unreferenced object is pruned and the file is
written fresh (no incremental history). The other pages' objects are written back byte for byte.
Cost: the text of a redacted page is no longer selectable or searchable. A content-stream rewrite (cutting out only
what is under the box) was not used: it needs a full content-stream interpreter (fonts and glyph positions, form
XObjects, inline images, clipping, shadings, Type 3 fonts), and any gap leaves text behind. The tests
(`crates/pdf/tests/redaction.rs`) check pdfium text extraction, a lopdf scan of every string, name and stream (raw
and decompressed), and a raw byte grep.
## The worker protocol (crates/worker), version 1
`pictor-worker.exe` reads one JSON object per line on stdin and answers one per line on stdout. Its first line is
`{"hello": "pictor-worker", "protocol": 1, "version": "0.1.0"}`; the client refuses another protocol.
```
→ {"id": 7, "op": "pdf.render", "args": {"doc": 1, "page": 0, "width": 1200}}
← {"id": 7, "ok": {"png": "<base64>", "width": 1200, "height": 1553}}
← {"id": 7, "err": {"kind": "needs_password", "message": "This PDF is password-protected. Enter its password to open it."}}
```
Error kinds: `needs_password`, `wrong_password`, `damaged`, `unsupported`, `too_large`, `codec_missing`, `invalid`,
`io`, `exists`, `not_open`, `cannot_reach_target`, `engine_missing`; the client adds `timed_out`,
`out_of_memory`, `crashed` and `spawn`. `message` is a plain sentence for the user.
| Operation | Arguments | Result |
| :-- | :-- | :-- |
| `pdf.open` | `path`, `password?` | `doc` (a session id), `info` (pages with sizes and labels, outline, `has_form`) |
| `pdf.close` | `doc` | — |
| `pdf.render` | `doc`, `page`, `width` (px) | `png` (base64), `width`, `height` |
| `pdf.text` | `doc` | `pages`: text per page |
| `pdf.search` | `doc`, `query` | `hits`: `{page, rects}` in view space (max 2000) |
| `pdf.form` | `doc` | `fields`: name, kind, value, options, page, rect, read_only, multiline |
| `pdf.save` | `doc`, `edits` (see `pictor_pdf::Edits`), `output`, `mode` (`new` / `overwrite`) | `path`, `bytes`, `bak?`, `warnings` |
| `pdf.extract` | `doc`, `pages`, `output` | `path` |
| `pdf.compress` | `doc`, `preset` (`email` ≤ 5 MB / `web` / `print`), `output` | `path`, `before`, `after`, `images_changed`, `warnings` |
| `pdf.to_word` | `doc`, `output` (.docx), `ocr?` ({page: text} for scanned pages) | `path`, `pages`, `scanned_pages` |
| `pdf.page_png` | `doc`, `page`, `dpi`, `output` | `path` (a page for OCR) |
| `pdf.to_images` | `doc`, `pages`, `dpi`, `format`, `output` (with `{n}`) | `paths` |
| `pdf.merge` | `inputs` [{`path`, `password?`}], `output` | `path` |
| `pdf.split` | `path`, `password?`, `ranges` ("1-3, 5, 8-"), `output` (with `{n}`) | `paths` |
| `pdf.from_images` | `inputs`, `output`, `fit` (`image`/`a4`/`letter`), `margin` | `path` |
| `image.probe` | `path` | `format`, `width`, `height`, `has_alpha`, `frames`, `bytes` |
| `image.thumb` | `path`, `max` | `png`, original `width`, `height` |
| `image.convert` | `input`, `output`, `format`, `quality?`, `crop?`, `rotate?`, `resize?`, `preset?`, `target_bytes?`, `overwrite?` | `path`, `bytes`, `format`, `width`, `height` |
| `image.heif_support` | — | `support` |
| `meta.read` | `path` | `report` (items by group), `groups` (with labels) |
| `meta.strip` | `input`, `output`, `overwrite?` | `path`, `removed` |
| `qr.render` | `payload`, `level`, `style`, `logo?` (a path) | `png`, `svg`, `level_used`, `size`, `text` |
Saving: `mode: new` refuses to replace a file (the app picks `<name>-edited.pdf`); `overwrite` writes
`<file>.bak` first, then replaces the file in one rename (`crates/save`).
Caps: files over 1 GB are refused; the client runs the worker in a Job Object (2 GB by default, killed with the
app) and gives each request a time cap; a worker that hangs or dies is replaced on the next request (open documents
must then be opened again).