mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-19 02:26:48 +00:00
34d6706088198af2dc26091a0a243ab628e49ac3
1945
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
d5bcb41099 |
fix(sign): a change to a field a signature locks invalidates it (#6757)
## What this changes Fixes #6757. Validation read only DocMDP references. A signature field's `/Lock` (ISO 32000-2 §12.7.5.5) and the FieldMDP references in its value (§12.8.2.4) were ignored. So changing a locked field after an approval signature read as a permitted form fill, and the signature stayed **Valid**. After this change: - `crates/sign/src/pdf/locks.rs` (new) reads both from the **signed revision**: `All`, `Include` and `Exclude`. A listed name also covers the fields below it, so `address` covers `address.city` but not `addressee`. Both sources count, because signers write one or the other or both. - The locked fields are compared between the signed revision and the document as it is now. That covers each field's dictionary and every dictionary above it (an inherited `/V` is its value too), plus its widgets. Tree links (`/Kids`, `/Parent`, `/P`) are left out of the comparison, and a page is compared by reference only, because adding an annotation rewrites it. - A locked field that changed, disappeared, or gained a second field under its name adds the new change kind `kind::LOCKED_FIELD` ("locked field") to a **Disallowed** modification. The signature is then Invalid, whatever `classify_changes` called the change. - A lock that is present but can't be read (an unknown `/Action`, a FieldMDP reference with no parameters, a non-dictionary `/Lock`), or a form too large to compare within the listing's caps, leaves the signature **Unknown**, never Valid. The detail is the existing "The signature could not be checked ({})." wording. - New fields added under a locked field, and the form's `/NeedAppearances` (plus `/DA`, `/DR` and `/Q` when a locked field has no appearance of its own), count as changes to it. The signature's own field is compared when its lock covers it. - `classify_changes` and `changes.rs` are unchanged. The check is wired in `finish_validation` (`validate.rs`). - `parity`: `sign.field-mdp` moves from `planned` to `partial`, with what's still missing. Related: #4809 makes *filling* refuse locked fields in PdfCraft's own form UI. The `sign` crate can't depend on `forms`, so this PR doesn't share its `signature_locks`. The lock reading follows the same rules (action, prefix matching, both sources) independently, and the two can be merged into one reader later. The two PRs touch different files. ## How you verified it Run locally (Windows), scoped to `pdfcraft-sign`: - [x] `cargo fmt --check -p pdfcraft-sign` - [x] `cargo clippy -p pdfcraft-sign --all-targets -- -D warnings`: clean - [x] `cargo test -p pdfcraft-sign --no-fail-fast`: integration 154 passed. Lib 120 passed, 1 failed: `shared_annotation_arrays_are_judged_in_bounded_time` (20 s limit) took 25 to 34 s. That test calls `classify_changes` directly, which this PR doesn't touch, and it fails the same way on unmodified `origin/main` on this machine (42 s), which was heavily loaded. CI should settle it. - [x] `cargo xtask parity`: ok - [x] Rerun on |
||
|
|
bff4be14c3 |
M10: Recognize text finds small print on large pages (tiled detection)
## What this changes Recognize text now finds small print on large, dense pages (newspapers, small print, blurred photos). The ocrs detection model reads a fixed 600 × 800 pixel input, so ocrs shrinks every page to that size before detecting words. A full page at 300 dpi (2480 × 3508) is shrunk about four times, and small letters disappear. With this change: - **When (size):** an axis is cut in two when the page is at least twice the detector's input along it (width ≥ 1200 px, height ≥ 1600 px for the ocrs models). Any full page at 300 dpi becomes 2 × 2 tiles; a landscape page may become 2 × 1. The input size is read from the detection model when it loads. Pages below that size (72 to 150 dpi renders, screenshots) are read exactly as before and cost nothing extra. - **When (text size):** a page that passes the size rule is tiled only if its text is small once the page is shrunk to the detector's input, decided by a cheap pixel signal, the **line pitch** (`crates/ocr/src/pitch.rs`). The page is box-averaged to a grey copy of at most 1600 px a side and cut into a 6 × 6 grid of blocks. In each block, the ink is summed per pixel row, the slow trend (shading, pictures) is removed with a moving average, and the autocorrelation is taken. The block autocorrelations are averaged, and the first strong peak is the pitch. Lines in columns that don't line up still agree on the period, and blank blocks are skipped. The same runs on pixel columns for sideways pages, and the axis with the stronger peak wins. The pitch is converted to detector pixels (pitch × 800 / page height). The rule: - pitch **under 9 detector pixels**: tile; - ink but **no clear line spacing** (no autocorrelation peak above 0.05): tile, because the measurement showed these pages (blurred, creased, oblique or moiré photos) gain on average; - large print, and blank pages: detect whole, as before. It costs 6.6 ms per page on average (median 5.1 ms, max 45 ms) and reads every pixel once. - **How:** tiles overlap by 4 % of the page on each side of a cut. Words are **detected** tile by tile. A word is kept only by the tile whose core cell (its share of the page without the overlap) holds its centre, so a word in an overlap counts once. The words are moved back to page pixels, and then lines are formed and **recognised on the whole page** as before. Lines that cross a cut stay single lines, and recognition reads the same pixels it read before. - The edge cells reach to infinity, so every finite word centre belongs to exactly one tile, including boxes that stick out past the page. The change is small and lives in `crates/ocr/src/tiles.rs` plus a `detect_words` step in `Ocr::recognize`. While I was there I also made the existing RGBA length check use checked arithmetic (`width * height * 4` was a `u32` product). ### Measured MDPBench de/es/fr (480 pages), official evaluation with CDM off, `en` recogniser. I ran the same harness build with and without the change (the baseline reproduces the earlier one exactly): | | Digital | Photo | All | Time per page | |---|---|---|---|---| | before | 78.9 | 41.5 | 50.8 | 0.39 s (190 s total) | | tiling every large page (this PR's first commit) | 80.4 | 42.8 | 52.2 | 0.58 s (281 s total) | | **tiling only small or unclear print (this PR)** | **81.2** | **42.9** | **52.5** | 0.54 s (259 s total) | | earlier prototype (full OCR per tile, outside the app) | 81.4 | 42.4 | 52.1 | n/a | The three rows of this PR come from one harness binary with the rule switched by an environment variable. Each was timed twice (190/191, 281/281, 259/259 s). Per language, the line-pitch rule against tiling every large page: DE 62.9 vs 62.7, ES 47.9 vs 47.8, FR 46.8 vs 46.1. It tiles **214 of the 457** pages that pass the size rule. **How the rule was chosen.** I measured first, in Python on the per-page scores of the official evaluation (`overall` per page, base vs. tiled). Per-page score gain from tiling, by measured pitch: | pitch (detector px) | pages | mean gain | pages gaining / losing > 0.02 | |---|---|---|---| | < 4 | 40 | +0.018 | 10 / 4 | | 4–6 | 40 | **+0.114** | 24 / 2 | | 6–10 | 82 | +0.004 | 10 / 6 | | 10–14 | 80 | **−0.013** | 5 / 26 | | 14–35 | 144 | −0.003 | 22 / 25 | | no clear line spacing | 82 | +0.029 | – | The gain sits at small pitch, and pitches of 10–14 detector pixels (ordinary body text on a full page) **lose** a little when tiled. Picking tiled or base per page by this rule, and running the official evaluation on that mix, predicted exactly what the Rust build then scored (52.5 / 81.2 / 42.9). Thresholds between 8 and 10 give 52.4–52.5. Treating "no clear spacing" as "don't tile" instead gives 52.0 with only 132 pages tiled. The choice is tuned on these 480 pages, so take the last few tenths with that in mind. **Time.** The saving is smaller than the page count suggests. The pages that stay tiled are the dense ones, where tiling finds many more words, and recognising those words costs more than the three extra detector runs. Tiling every large page cost +91 s. The pitch rule costs +69 s, so it removes about a quarter of the overhead and still scores higher. Word recall in the benchmark's own per-kind table, before → after: de digital 61.9 → 78.5 %, fr digital 17.8 → 24.5 %, de/es/fr photos 38.1/37.7/10.1 → 42.1/43.2/12.6 %. Sideways photos are unchanged; those need rotation, which is a separate PR. Detection runs four times instead of once on a tiled page (machine: Ryzen AI Max+ 395, CPU). ### How it composes with the open OCR PRs - #5157 (reading order) ends `recognize` in `layout::reading_order`. This PR changes only the detection step before `find_text_lines`, so tiles are merged before lines are formed and before reading order runs, which is the order we want. I measured both together: the numbers above come from a harness tree that has #5157's reading order applied. The two diffs touch neighbouring lines in `recognize`, so whichever merges second needs a trivial rebase. - #5171 (layout regions) and #5058 (line padding) work on lines and regions after detection, so they compose the same way. ## How you verified it - [x] `cargo fmt --check` - [x] `cargo clippy -p pdfcraft-ocr --all-targets -- -D warnings` - [x] `cargo test -p pdfcraft-ocr`: 26 passed, **with the OCR models installed** (CI has none, so CI skips the model-backed tests). With the models, I also ran the OCR tests of `pdfcraft-engine` (`ocr`, `recogni` filters) and `pdfcraft-automation` (`ocr`, `scan`) locally, and all pass. - [x] `cargo xtask layers`, `cargo xtask assets`, `cargo xtask parity` **Tests.** - Unit tests, no models (`crates/ocr/src/tiles.rs`): the tile geometry for small pages and for A4 at 300 dpi; every word centre, on cuts, edges and outside the page, belongs to exactly one tile, and NaN or infinity belongs to none; cropping, including out-of-range and overflowing crops, returns `None` without panicking. - Unit tests, no models (`crates/ocr/src/pitch.rs`), on synthetic A4 pages at 300 dpi: a blank page is not tiled; large print (lines every 100 px, 22.8 detector px) is not; small print (every 30 px, 6.8 detector px) is, in grey, RGB and RGBA alike; sideways small print (lines running down the page) is; noise (ink without lines) is; the first strong autocorrelation peak is the pitch, not its multiple; empty, 1-pixel, short or long buffers, 0 or 5 channels, overflowing sizes, a zero-sized detector and slivers give an answer without panicking. - Model-backed test `finds_small_print_on_a_large_page`: an A4 page at 300 dpi with four lines of small print. One sits inside a tile, one crosses the vertical cut, one is half in the overlap, and one crosses the horizontal cut. Each line must come back as exactly two words at the right place in page pixels. - **Seen failing by reverting the fix:** - Detection on the whole page instead of tiles: 5 words instead of 8, unreadable ("FIOWOR", "In3"). - Keeping every tile's words without the centre-in-core rule: 14 instead of 8, because the lines in the overlaps doubled. - Finite edge cells: `every_word_centre_belongs_to_exactly_one_tile` fails. - Never cutting: the geometry tests fail. - Line-pitch rule, each mutation reverted afterwards: tiling every page (the first commit's behaviour) fails `a_blank_page_is_not_tiled` and `large_print_is_not_tiled`. Never tiling on a measured pitch fails `small_print_is_tiled` and `sideways_small_print_is_tiled`. Rows only, without the column profile, fails `sideways_small_print_is_tiled`. Taking the strongest peak instead of the first strong one fails `the_first_strong_peak_is_the_pitch`. Not tiling unclear pages fails `ink_without_lines_is_tiled`. No detrending fails four tests. With the threshold lowered to 5 detector pixels, the model-backed `finds_small_print_on_a_large_page` finds 5 words instead of 8, so it exercises the rule too (its page measures 5.8). ## Never-crash - [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests - [x] No indexing or slicing with input-derived positions: crops use checked arithmetic and `get`; tile bounds are clamped to the page; float-to-int casts are of values clamped to `0..=len`. The pitch measure checks that the buffer matches width × height × channels with checked arithmetic, reads pixels through iterators and `get`, and works on at most 1600 × 1600 values whatever the page size. It divides only by non-zero counts, so it returns an answer for any input. - [x] No `unsafe` - [x] n/a, this fixes no crash ## Provenance - [x] No asset from an Adobe product - [x] No font files - [x] No GPL/AGPL code - [x] Behaviour comes from our own measurements on MDPBench. The approach (overlapping tiles, keep by centre; line pitch from the autocorrelation of a projection profile) is a generic technique, not read from another implementation. - [x] No new assets. One new dependency edge, `rten-imageproc` 0.26 (MIT/Apache-2.0), which was already in the tree through `ocrs`. ## Security - [x] No path handling changed - [x] No MCP or control channel changes - [x] No network access ## Parity and reach - [x] `ocr.recognize-text` notes say when pages are tiled (size and line pitch), and that the model-backed test runs only where the models are installed. The tiling and pitch unit tests are evidence. - [x] Reachable headlessly: this is inside `Ocr::recognize`, so `ocr_recognize` and `ocr_recognize_files` get it unchanged. - [x] No documented behaviour changed ## Anything a reviewer should look at first - **The tiling rule:** an axis is cut only if each half still fills the detector's input, so a tile is never padded. A lower threshold would also tile mid-size pages. I kept it conservative so that small pages cost nothing. The prototype tiled every page; under this rule, 468 of the 481 benchmark images are cut along at least one axis and 337 along both. - **The line-pitch rule (`pitch.rs`).** Its constants (1600 px working size, 6 × 6 blocks, peak floor 0.05, first peak ≥ 60 % of the strongest, 9 detector px) were chosen on MDPBench as described above. "No clear line spacing → tile" is deliberate. My first idea was the opposite, but the measurement favoured tiling. - **Detect per tile, recognise on the whole page**, rather than full OCR per tile like the prototype. This is simpler: there are no lines to stitch back together and no rows to re-sort. It scores about the same as the prototype (all 52.2 vs 52.1, photo 42.8 vs 42.4, digital 80.4 vs 81.4). |
||
|
|
55983f1f92 |
M12: forms show and add pages from page templates (#1429)
## What this changes Part of #1429. The form in that report keeps pages it shows on demand as **page templates**: the name dictionary's `/Templates` tree names pages kept out of the page tree, and `/Pages` names visible ones (ISO 32000-2 §7.7.4). Until now their fields were listed as unplaced, and the form's JavaScript could not reach them, so buttons that add a page or show a section did nothing. - **organize**: `templates`, `spawn_template` and `set_template_hidden`. - A spawned page is a copy of the template page. - With renaming, its fields become fields of their own under `P<page>.<template>.<name>`. - Without renaming, its widgets join the template's fields and share their values. A template field that is its own widget is split into field + widget first. - Hiding a template takes its page out of the tree, keeps what it inherited (MediaBox, Resources, …) and refuses to hide the last page. - **js**: `this.templates`, `getTemplate(name)`, `Template.name`, `Template.hidden` (setting it shows or hides the page), `Template.spawn(nPage, bRename, bOverlay)` and `spawnPageFromTemplate`, with positional or named arguments and the documented defaults (0 / true / true). Non-number pages are clamped. - **engine**: new `Edit::SpawnTemplate` and `Edit::SetTemplateHidden`. - Both are checked against the assemble permission and applied in the same undo step as the script's field changes. - Only a button's or the console's script may change the pages. A field's own scripts (format, keystroke, validate, calculate) are told so on the console. - At most 100 template pages per script run, because each spawn copies the document. A loop that asks for more stops there with one console note. - **automation**: `page_templates` (read-only), `page_template_spawn` and `page_template_set_hidden`. - Undo labels translated in all 34 catalogues. Not in this PR: - `bOverlay` true (laying a template over an existing page). The script is told so on the console once and nothing changes. - `createTemplate` / `removeTemplate`. - An Organize-panel UI for templates. - `numPages` is not updated inside the running script. - Mouse Up actions on radio buttons and checkboxes (the other half of #1429) are in the open #2546. ## How you verified it - [x] `cargo fmt --check` - [x] clippy with `-D warnings` on the crates I changed (organize, js, engine, automation, ui-egui) - [x] tests pass on the crates I changed | Crate | Result | |---|---| | organize | 188 passed | | js | 97 passed | | engine lib | 382 passed | | engine it | 21 passed | | automation | 45 + 282 passed | | ui-egui i18n | 65 passed | - [x] `cargo xtask layers`, `cargo xtask assets` and `cargo xtask parity` **Tests.** - organize has 9 unit tests: listing, renamed and shared spawns, appending past the end, show/hide, the last page and unknown names refused, hostile template trees, repeated unrenamed copies, and inherited attributes kept when hiding. - js has 5 tests: listing, `spawn` defaults, both argument forms, `hidden` read back, and clamping. - engine has 5 integration tests: one undo step, renamed and shared spawns surviving save + reopen, overlay noted, field scripts refused, and the 100-page budget. - automation has 2 tool tests. Each behaviour was seen failing by reverting it: - no renaming - no field sharing - no MediaBox fallback - hidden page dropping inherited attributes - no budget - field scripts allowed to spawn - requests not applied - wrong default flags Under a loaded machine `tests::xfa_model::a_slow_engine_start_does_not_count_against_the_script` (an existing timing test) failed once and passes on its own. It is not touched here. ## Never-crash - [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests, unless it is provably infallible with a comment saying why - [x] No indexing or slicing with input-derived positions; checked or saturating arithmetic; allocations sized by input are capped; recursion is bounded - Name trees are capped at 4096 names. - Field walks are capped at 32 levels and 100 000 nodes, with seen-sets. - Spawns are capped at 100 per script run. - Template names are clipped and charged to the script's output budget. - [x] No `unsafe` - [x] Any crash this fixes has a small synthetic regression test (no crash fixed; the hostile-tree test covers cyclic and malformed `/Templates`) ## Provenance - [x] No asset from an Adobe product, and no Adobe icon recreated, traced or imitated - [x] No font files committed here - [x] No GPL/AGPL code copied in - [x] Behaviour comes from the specification or black-box observation, **not** from reading another implementation's source. The sources are ISO 32000-2 §7.7.4 and §12.7.6 and the public Acrobat JavaScript API reference for `Template`/`spawnPageFromTemplate`. - [x] Every new asset has an `ATTRIBUTION.toml` entry and `cargo xtask assets` passes (no new assets) ## Security - [x] `--root` confinement still holds on every path, including ones reached by nested tool dispatch (the new tools take a document id, no paths) - [x] MCP and the UI control channel stay opt-in, loopback-only and token-authenticated - [x] No new outbound network access ## Parity and reach - [x] `parity/acrobat-features.toml` updated: `organize.page-templates` is now `partial`, with notes on what is still missing - [x] Reachable headlessly through an `automation` tool (`page_templates`, `page_template_spawn`, `page_template_set_hidden`, and `js_run` for scripts) - [x] Docs updated if this changes a documented behaviour (crate doc comments) ## Anything a reviewer should look at first - `share_fields_with_originals` in `crates/organize/src/import/fields.rs`: how an unrenamed copy's widgets are reparented onto the template's fields. When a template field is its own widget, it is split into a field with two widget kids. - The 100-page budget per script run in `crates/engine/src/js.rs`. Each spawn copies the document, so a `for` loop over `spawn` in a hostile form is bounded there. |
||
|
|
0c39992c99 |
Print: make a long printer list easier to browse and search (#4399)
**Update on 2026-11-03 (`db57e7de`).** Merged main `ecdd1e65` and preserved both sets of parity evidence. The picker now uses the public `ComboBox::show_ui` response to track the open menu and clear its search when it closes. All 30 print UI tests passed locally on macOS arm64, including the three printer-picker regressions. Formatting and `cargo xtask parity` passed. [CI](https://github.com/storytold/pdfcraft/actions/runs/41673448570) and [SonarCloud](https://github.com/storytold/pdfcraft/actions/runs/41673448592) track this commit. ## What this changes Fixes #4399. The printer picker opens a wider, taller menu with a name filter. Long device names wrap, while Search and Save as PDF stay visible as the device list scrolls. Search ignores case, trims surrounding spaces and keeps the current destination until a row is chosen. Reopening clears the filter and brings the selected device into view. The large-fleet test now checks that the selected row is between Search and Save as PDF after reopening, without manually scrolling at that point. This catches a broken automatic reveal instead of hiding it with a test-side scroll. ## How you verified it - At `d14aed41`, the [hosted gate](https://github.com/storytold/pdfcraft/actions/runs/40305529036/job/121513571419) passes: 5,194 tests, 21 skipped. All three `printer_picker` tests explicitly pass, including the new reopening visibility assertion. Formatting, strict Clippy, layers, assets, parity and wasm checks pass in that gate. - CodeRabbit's refreshed documentation check passes at 100%; both remaining test helpers are documented. - The three original UI regressions failed against the original production module. They cover a 120-device fleet, Unicode/case matching, selection, reopening, no matches, long names and a 1024×768 window. A separate earlier before/after check caught an initially clipped Save as PDF row by physically clicking it. - Earlier macOS validation inspected headless captures and exercised the real Print dialog through its control channel. Those are earlier-run results, not a new native macOS run on this head. - The current local Windows Cargo 1.95 run cannot resolve the pinned craft-menu manifest and does not reach the UI tests. Runtime validation of this latest test update is the hosted gate above; no local test pass is claimed. ## Safety, provenance and reach - [x] No new panicking shortcuts, unsafe code or input-derived indexing. - [x] No new assets, fonts or dependencies. - [x] Existing printer discovery, properties and print submission paths are used. - [x] Automation remains available through `printers`, `printer_options` and `doc_print`; UI controls remain opt-in. - [x] Printer-selection parity evidence and M10 progress notes are updated. ## Limits of verification Physical printing was not tested. Keyboard injection into the earlier background native macOS window did not enter text; filter typing and selection were verified through egui_kittest. AI assistance: implementation, tests and validation used Codex. |
||
|
|
cc0edc29d1 |
fix(edit): preserve source fonts in mixed-script paragraphs
## Follow-up after #6806 The main mixed-script font change landed in #6806. This PR covers the remaining case where the source font lacks only a variation selector (U+FE00–U+FE0F). A visible letter now selects the fallback face. The regression compares implicit and explicit fallback in two source fonts, including character spacing, alignment, and save/reopen. Verified locally on macOS arm64 with the CI-pinned craft-fonts input: `cargo test --locked -p pdfcraft-edit` and `cargo test --locked -p pdfcraft-automation --test it mixed_script` passed, as did formatting, scoped Clippy, the layer and asset checks, and the UI WebAssembly build. <!-- evening-module-refresh-20261027:start --> **Latest compatibility update (2026-10-27):** [ |
||
|
|
3516508589 |
Edit text: space between paragraphs
## What this changes `edit.line-paragraph-spacing` was partial: line spacing existed, the space between paragraphs did not. Now a line break in the edited text starts a paragraph, and the paragraphs are set apart: - `BlockStyle.paragraph_spacing: Option<f64>` (points, beyond the line spacing). `rewrite_block` splits the text at line breaks, wraps and justifies each paragraph on its own (the last line of each paragraph is never stretched), and steps down by the line spacing plus the gap before a paragraph's first line; underlines follow. `None` is half the font size when the text has several paragraphs, so a plain Enter already reads as a paragraph; a non-finite value is refused. - The row-model rewrite (`text_regions`) keeps the rows a line break started apart from wrapped ones: the gap goes before those, and a row the page already had sits where it was, shifted by the spacing added above it. - Format text panel: a Paragraph spacing field (points) next to the line spacing; the tool `text_edit` takes `paragraph_spacing`. - Rows for the two labels in all 21 languages; `parity/acrobat-features.toml` `edit.line-paragraph-spacing` → shipped (notes: space before and after as separate values are still missing). ## How you verified it Re-run on 2026-10-15 after merging `main` into the branch ( |
||
|
|
bd0a21c2de |
M3: full screen fills the screen or keeps the page display, and Esc closes the find bar before leaving (#576, #4273, #5302) (#5325)
Full screen can fill the screen edge to edge, fixing the fake full screen in #379, or keep the normal page display, via a preference. The forms bar is hidden in full screen. Up-arrow and wheel no longer jump back a page, and Esc closes one thing at a time (the find bar before leaving full screen). Bundles #576, #4273 and #5302. |
||
|
|
f8d8aef6e4 | M5: preserve macOS Minimize alongside Ctrl+M Comments (#3741) | ||
|
|
e191b0ea69 |
M3: select text across pages (view.text-select)
Allow a text selection to run across pages, keeping main's same-page table-row selection (head_x) and the JavaScript link click dispatch from #2081. |
||
|
|
aef22858a9 |
Select a table by rows when a drag crosses its columns (#3669)
## What this changes Fixes #3850. Partly addresses #3682: drags within one column of its two-column page now select that column's text (the tester's harness measured 3/9 → 7/9 on `cols.pdf`). Drags from one column into the next still follow reading order, as on `main`; they need column-correct reading order (#3676). Selecting text in a table selected the wrong things. A table reads column by column, so a plain drag along one row, or down and across a few rows, took the rest of the first column and the top of the next ones between its ends. On some rows the highlight jumped to the column headers and half the table. Copy gave the cells out of order. Preview selects these by rows, and this makes PdfCraft do the same. Rebased on `main` after the module split (#4889): the row selection is in `crates/render/src/text.rs`, the padded-cell join and barcode rows in `text/order.rs` and `text/layout.rs`, the drag's pointer end in `crates/ui-egui/src/canvas/selection.rs` and `canvas.rs`. - **Visual rows** (`PageText::visual_between`, used by `Selection::rects` and `Selection::text`). The drag selects by rows when reading order between its ends would not follow them: the rest of the first row, the rows between, and the start of the last. Copy gives the cells tab-separated, as Column select does. Rows are used when either of these holds: - Reading order strays above or below the rows dragged over. - The drag ends in another column. That means across a gutter that no text of those rows crosses (checked a few lines above and below as well, so a justified line's wide word gap does not count), or with the pointer past the end of both lines. - **Limits on the rows.** Rows never take lines left of everywhere the drag has been, and they stay in the column when the drag does. A drag in the right column of side-by-side text that ends on a hanging list marker does not pull in the left column. Running text keeps reading order whenever it covers the same glyphs, and so does a column of running text beside a sidebar. A drag down one article or table column keeps reading order too. A line's extent for these limits is its ink: spaces padding it out don't count. - **Pointer position.** `Span::Run` records where the drag's pointer ended (`head_x`). It can lie well past the nearest glyph, as in the empty end of a table row. Select all, a clicked word, line or page, and four-click page selection keep reading order. - **Hit testing.** `PageText::nearest` still takes the glyph whose em box holds the point first (#3693). Failing that, it prefers the row level with the pointer, so past the end of a short row a longer row just below no longer captures the drag. Between rows, the old distance rule still applies. - **Padded cells.** Report generators pad each cell of a row with trailing spaces. When a cell's padding stops short of the next cell (more than the 3-height continuation gap), the next cell on its baseline now joins the row, within 8 line heights (`PADDED_FIELD`, `PADDED_REACH`). Without this, the row's last cells were read after the whole table, in selection, copy and `text_extract` alike. - **Barcodes drawn with a font** (new since the last review). Mexican CFDI invoices and receipts print their QR or Aztec code with a barcode font: rows of glyphs stacked flush, 5 pt from the seal's text and on nearly the same baselines. Each code row joined the seal line beside it, so the seal read interleaved with the code, some seal lines came after the whole code, and a drag down the seal jumped through it. Rows of at least 8 glyphs, 4 or more stacked flush with one glyph count and the same edges (`barcode_rows`), now join no other text and read after the page's text. A point beside the code is not taken by the code row level with it. ## How you verified it - [x] `cargo fmt --all --check` - [x] `cargo clippy --workspace --all-targets --locked -- -D warnings` - [x] tests pass on the crates I changed, and on the crates that use text extraction: | Crate or suite | Passed | |---|---| | `pdfcraft-render` (lib + integration) | 476 + 64 | | `pdfcraft-ui-egui --lib` | 696 | | `pdfcraft-ui-egui --test it` (`column_select`, `text_select`, `drag_selects`, `selection_works`) | 33 | | `pdfcraft-automation` | 359 | | `pdfcraft-engine` | 442 | | `pdfcraft-export` | 43 | - [x] `cargo xtask layers`, `cargo xtask assets`, `cargo check -p pdfcraft-render --target wasm32-unknown-unknown`, `cargo xtask parity` **Tests.** I reverted each fix and watched these fail: - `column_select.rs::a_plain_drag_along_one_table_row_selects_only_that_row` (UI, select tool and highlighter). Before the fix it got `"Apple\nPear\nQty\n12"` instead of `"Apple\t12"`. - `column_select.rs::a_drag_ending_between_the_columns_selects_the_rows` (UI). Without `head_x` it got `"Name\nApple\nPear"`. - `column_select.rs::a_drag_down_text_beside_a_barcode_selects_only_the_text` (UI). Without the barcode rows it got `"ABCDEFGHIJKL one two three\nFGHIJKLMNOPQ\n…"`. - `text/tests.rs::a_barcode_drawn_with_a_font_reads_apart_from_the_text_beside_it` - `text/tests.rs::a_point_beside_a_barcode_takes_the_text_not_the_code_row` - `text/tests.rs::a_point_level_with_a_row_takes_that_rows_nearest_glyph` - `text/tests.rs::a_drag_in_the_right_column_takes_nothing_from_the_left` Also new in `text/tests.rs`: `a_drag_along_one_table_row_selects_that_row`, `a_drag_over_table_rows_selects_those_rows`, `a_drag_that_reading_order_already_covers_keeps_it`, `a_pointer_ending_beside_the_column_takes_the_rows`, `a_cell_padded_with_spaces_joins_the_next_cell_of_its_row`, `a_justified_gap_is_not_a_gutter`, and the running-text, sidebar, heading and vertical-text cases from earlier review rounds. In `column_select.rs`: double-click drags, select all and four-click page selection on uneven columns. All fixtures are synthetic. **Corpus.** Before the rebase, text extraction of the pinned pdf.js corpus was byte-identical with and without this PR. The barcode change leaves it identical too: the plain text of the first 60 pages of each of its 989 PDFs (1,525 pages) is the same with and without it. **Real-world files** (private, not attached): - **Text extraction:** on a personal folder of PDFs (bank and hotel reports, payslips, policies, contracts, slide decks), the only files that differed from `main` before the rebase were bank statements whose padded rows now keep their amounts. The barcode change alters one page across 105 files: a statement's CFDI page, whose seal now reads in order. - **Simulated drags:** about 53,700 random drags across those files. Selection takes at most about 145 µs per frame. - **Two-column contract:** on a bilingual two-column contract, 2,649 drags kept inside one column leak into the other column less often than before (1,224 vs 1,591). In no file does the new code leak a two-column drag where the old one did not, except across table rows, where rows running across the page is intended. ## Never-crash - [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests - [x] No indexing with input-derived positions in the new code (`get`). Allocations are bounded by the page's glyphs, and `side_by_side` compares at most `SIDE_BY_SIDE_LINES` lines. Barcode rows are found with one hash map over the page's rows. NaN boxes rank last in `nearest` (`total_cmp`) and are never barcode rows. No recursion. - [x] No `unsafe` - [ ] Any crash this fixes has a small synthetic regression test (n/a, no crash) ## Provenance - [x] No asset from an Adobe product, and no Adobe icon recreated, traced or imitated - [x] No font files committed here - [x] No GPL/AGPL code copied in - [x] Behaviour comes from black-box observation (Preview's selection on the same files), not from reading another implementation's source - [x] No new assets ## Security - [x] `--root` confinement untouched - [x] MCP and the UI control channel untouched - [x] No new outbound network access ## Parity and reach - [x] `parity/acrobat-features.toml`: `view.text-select` gains the new evidence and a note. Selection across pages is still missing, as before. - [x] Reachable headlessly: the padded-cell join and barcode rows change `text_extract` too. Visual-row selection is a pointer interaction, like the rest of plain drag selection. - [x] `ROADMAP.md` progress log line ## Anything a reviewer should look at first 1. **A deliberate behaviour change.** `alt_drag_selects_only_the_text_inside_the_rectangle` asserted that a plain drag from "Name" to "12" selects in reading order: `"Name\nApple\nPear\nQty\n12"`. It now selects the two rows dragged over, `"Name\tQty\nApple\t12"`, and I changed the assertion. Reading order itself is unchanged (`a_column_selection_takes_one_table_column` still asserts it), and so is a drag down one column. 2. **The gutter test is a heuristic.** "Another column" means a vertical strip at least one line height wide that no text in the dragged rows, or 4 line heights around them, crosses. That catches table columns and side-by-side text, and ignores justified word gaps in practice. Thin columns with ragged edges may still fool it. 3. **The padded-cell join changes reading order.** It applies only to a segment whose box runs on at least 2 line heights of trailing spaces past its last visible glyph, and only towards a cell on the same baseline within 8 line heights. 4. **Barcode rows change reading order.** A stack of 4+ flush rows of 8+ glyphs, each with the same glyph count, height and edges, reads after the page's text. Text set solid still has lines of different lengths and counts; a hex dump set solid in a monospaced font would also match, and would then read last. 5. **Overlap with #2431** (narrow article gutters, #2387). The two PRs touch different code paths and should rebase cleanly. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Text drags across table-like layouts now select cells by visual row, with copied cells separated by tabs. Multi-click and Shift-click selections can also follow visual rows where applicable; select-all and other non-row selections retain reading order. * Text selection and pointer placement work more accurately around columns, gutters, and barcode-like text, reducing unintended selection of nearby content. Barcode text is kept separate from adjacent text. * **Documentation** * Updated feature coverage and progress notes to reflect text-selection behavior and regression testing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
358e33a307 |
M7: replacing a line keeps the source font for the words it can show (#2378, re-lands #2955) (#6842)
* M7: replacing a line keeps the source font for the words it can show (#2378) (#2955) * Fit #2955's line edit to #4514's /ActualText spaces Since #4514, source_show wraps a run whose spaces the subset lacks in a /Span /ActualText BDC ... EMC, so the moves standing in for those spaces read back. #2955's two-font /PCEdLine path writes its source runs through source_show, so they now carry that span too. Three of its tests were written against the operator stream from before that: - replacing_a_mixed_font_line_again_replaces_its_sequence counted BMC and EMC as the /PCEdLine sequences alone. It now also counts each edit's own /ActualText spans (BDC, and EMC = sequences + spans), so a sequence that nests or survives a re-edit still fails it. - a_leading_space_does_not_make_a_source_font_run looked for the leading move right after the Tf; it now sits inside the run's span. - a_row_replaced_inside_a_shared_sequence_starts_in_its_own_font put its second row before the first EMC, which is now the span's: the row was read as part of the span's text. It now goes before the EMC that closes /PCEdLine, the case the test describes. A paragraph rewrite drops an /ActualText span with its line (the span's BDC and EMC are among the line's operators), so it never leaves a row inside one. The code needs no change: re-editing drops the spans inside a /PCEdLine sequence with it (BDC/EMC are in the dropped set), and a span's merged run keeps the sequence it is in, so the line still reads back as one. Also drops the same_font import lines.rs no longer uses. * Tests: fit #2955's three line-edit tests to #4514's /ActualText spans * Tests: the replaced sequence's check allows the new text's own /ActualText span --------- Co-authored-by: mtlcl410 <2368091+mtlcl410@users.noreply.github.com> Co-authored-by: FredApps <FredApps@users.noreply.github.com> |
||
|
|
b7ffe8732f | xtask, export: update attribution, parity evidence, and RTF test for craft-libs cutover | ||
|
|
eb2a2eddac |
Merge pull request #7056 from mtlcl410/perf/form-edit-reads-fields-once
M7: a form edit reads the document's fields once (form.fill-text) |
||
|
|
330cde8035 |
Merge pull request #5559 from vangel76/feat/recent-reveal-5452
Reveal recent files in the system file manager from Home (#5452) |
||
|
|
cd1d7160b0 |
Merge upstream/main into perf/form-edit-reads-fields-once
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Pq7HyGTPYerQyLLrnydVDA |
||
|
|
522fa442f5 |
Merge main into port-4751
vendor/README.md conflicted: main took hayro-interpret patch 104 (RGB colours in isolated DeviceCMYK groups). This branch's viewer overrides become patches 105 (annotation_overrides) and 106 (appearance_overrides) in the README, in vendor/hayro-interpret/src/interpret/mod.rs, in the raster test and in docs/acroform-script-workflows.md. |
||
|
|
120c62fb82 |
Auto-tag Apply tags headings by size and weight (#7062) (#7069)
* feat(a11y): auto-tag Apply tags headings by size and weight Apply now chooses H1-H6 or P per text object instead of P for all. The body style is the half-point size showing the most characters (bold when most of those are bold). A short object (at most 3 lines, 200 characters, with a letter) is a heading when it is 1.15x the body, or bold at 0.9x the body over a regular body in at most 2 lines. Heading styles rank across the document, larger and bolder first, capped at H6, and a level never skips past the one before it so heading-nesting passes. Size is Tf x Tm x CTM with q/Q tracked; bold is Metrics.bold. Text in render mode 3 (an OCR layer) is not counted. Font metrics are measured once per font object per document, at most 256 fonts. AutoTagResult gains a headings count. Parity, gaps, roadmap and the apply tool's note say headings are tagged. Fixes #7062. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(a11y): rank heading styles by map and skip clip-only text Look up each heading style's rank in a map built once after sorting, so ranking is linear in the number of text objects. Text in render mode 7 (clip only) paints nothing, so it is excluded from heading evidence like mode 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: KenM76 <KenM76> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
490287fc9d |
prc: rebuild compressed tessellations whose normals are recalculated (#1297) (#7034)
* prc: rebuild compressed tessellations whose normals are recalculated A TESS_3D_Compressed (WD 7.8.9.7) was read to its end but never rebuilt, so prc-render drew nothing for it. Rebuild the form whose normals are recalculated, with three edge statuses per triangle, into a Mesh grouped by face and styled by each face's line attribute. The walk (tess/compressed.rs) takes a seed, then one apex per triangle, from a reference or the next point in the frame of the edge it continues across (WD 7.8.9.2), with the WD 12.3 Length, Unitize and MakeOrthoRep arithmetic bit for bit. Arrays that do not fit, or an edge shared by more than two triangles, leave the tessellation Compressed. Every triangle, style and face range is charged to the element allowance first. Stored-normals meshes, the one-status-per-triangle form, the planar bend check, the best-fit search and partial salvage are later PRs. Adapted from pdfcer (MIT, same author) at 0a249a73. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * prc: charge rebuilt compressed meshes after they fit; model_render test The rebuilt triangles, their styles and the face ranges are now charged to the element allowance once the arrays fit and before the face ranges are made. Arrays the walk cannot fit stay Compressed and spend nothing, so they no longer fail the file over a face count they never use. Tests: - a_rebuilt_compressed_mesh_is_charged_its_triangles_and_faces pins the exact charge (4 triangles x 3 elements + 2 faces); - arrays_that_do_not_fit_spend_no_triangles_or_faces; - rebuilt_triangles_are_grouped_by_face_with_their_styles, a direct by_face test with out-of-order faces, empty faces and styles; - model_render's a_compressed_prc_model_is_rebuilt_and_drawn, end to end from a PDF, cited in misc.3d-view; its hex fixture is the prc-render builder's output, kept so by the_automation_fixture_is_the_compressed_triangle. The walk's working tables are documented as bounded by the triangle count rather than charged. The module docs now say the arithmetic matches the WD pseudocode as read and that the traversal rules are inferred, not WD text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * prc: charge compressed styles and face ranges before making them A rebuilt compressed mesh's per-triangle styles were built before the budget was charged, and also when the normals were stored and the mesh was read past. The face attributes are now kept as read, and the styles are built only for a rebuilt mesh, after the charge. Each face range is a Range<usize>, two budget elements on 64-bit targets, so it is charged at its size, not as one element. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * prc: bound the compressed rebuild walk by the allowance left The walk's vertices, triangles, edge counts, edge log and stack were allocated before anything was charged, and could hold several times the decoded arrays. The walk now gets the elements the reader has left and stops once its arrays, by length, would hold more; the tessellation then stays compressed, as when its arrays do not fit the walk. A face whose line attribute is 0 but whose behaviour is not now styles its triangles, so the behaviour bits are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * prc: say the rebuild walk is bounded by the allowance Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * prc: cap the rebuild walk's first reservation by its limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: KenM76 <KenM76> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
d749fd8062 |
Print colour management: the app converts printed pictures into a printer profile (#6269) (#6853)
* Print: app-managed colour converts printed pictures into a printer profile (#6269) doc_print takes color_management (printer, the default, or app). With app, color_profile (an ICC file or an installed profile's name), rendering_intent and black_point_compensation convert each rendered page picture from sRGB into the printer's RGB or grey profile before it is sent. app prints the pages as pictures; CMYK and non-destination profiles are refused. print_color_profiles lists the installed RGB and grey profiles. The conversion is craft-cms at craft-print's rev, in pdfcraft_print::colour, hooked into print_raster::rasterize. Raster carries the colour and is Clone rather than Copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Print colour: look for installed profiles inside the read root when confined With automation roots, print_color_profiles and doc_print's color_profile name lookup read the system's colour folders, outside the roots. They now look in the read root instead (as text_font_files does), check each file against it before reading it, and are refused without read authority. Under --root they look in the root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * automation: keep colour profile discovery inside --root, links followed Under --root alone, print_color_profiles and the color_profile name lookup listed the root's .icc files without checking each against the root, so a link inside it could read a profile outside. Each discovered file now goes through the same --root resolution as any other read (links followed) before it is opened. colour_profile_links_out_of_the_root_are_not_read makes such a link and checks it is neither listed nor found by name; it fails without the check (the link is listed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * print: as_chunks for the grey fill; area print keeps managed colour Clippy 1.99 (`chunks_exact_to_as_chunks`) flags the constant-width `chunks_exact_mut(4)` in the grey conversion; use `as_chunks_mut::<4>()`. main's print-area path built `Raster` without the new `colour` field; build it through `PrintDraft::raster()` so a printed area is colour managed like a printed page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Lock craft-cms at the craft-libs commit craft-print now uses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(print): read only regular files as printer profiles, and no more than the cap A FIFO or device named `.icc`/`.icm` in a profile folder was listed and read, and opening a FIFO for reading waits for a writer. The listing now keeps regular files only (links followed), `PrinterProfile::read` refuses anything else before opening it, and the read goes through a limit one byte past `MAX_PROFILE_BYTES`, so a file that grew after it was measured is refused rather than read whole. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: KenM76 <KenM76> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
503a19467f |
M7: a form edit reads the document's fields once (form.fill-text)
The fields of a document are kept with the state they were read from (pdfcraft_cos::ReadState), and a document that still reads as that state gets a copy instead of a new walk. One value edit read them four times on an AcroForm (fill, recalculate, refresh, display) and seven on a laid-out XFA form (plus the data sync twice and the scripts), mostly with nothing changed in between; it now walks them once, and twice on an XFA form (once more after its data is written). |
||
|
|
08bf6ec278 |
Merge upstream/main into feat/recent-reveal-5452
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
2c39b1d625 |
Merge pull request #6882 from Piohrun/fix/redact-unparsed-bytes
M8: redaction refuses a page whose content it can't fully parse |
||
|
|
96590430d4 |
Merge pull request #6935 from Piohrun/feat/optimize-mono-past-80-megapixels
M11: Optimize stores one-bit images and masks past 80 million pixels as monochrome images |
||
|
|
b363f7a717 |
Merge pull request #6825 from Piohrun/feat/optimize-mono-masks
M11: Optimize stores a picture's one-bit masks as monochrome images |
||
|
|
c0f5f92b57 |
Merge remote-tracking branch 'origin/main' into port-4751
# Conflicts: # crates/automation/src/dispatch.rs # crates/automation/src/tools.rs # crates/forms/src/lib.rs # crates/js/src/tests.rs # crates/ui-egui/src/workflows/js_ui.rs # parity/acrobat-features.toml |
||
|
|
059dbd6e00 |
feat(forms): open, Will Save and Will Print actions, widget pointer/focus scripts, setItems/setAction/toSource (port of #344) (#6969)
* feat(js, forms): field setItems, setAction and a bounded toSource (#269) Ported from #344 by @DWAA1660 onto the per-document script session. - `field.setItems(items)` replaces a combo or list box's items (text, or [text, export] pairs). The value stays when an item still has it, and otherwise becomes the first item's. Written as the field's /Opt (pairs only where the export value differs), /I dropped, field redrawn. - `field.setAction(trigger, script)` installs a JavaScript action for one trigger (MouseUp/Down/Enter/Exit, OnFocus/OnBlur, Keystroke, Validate, Calculate, Format), replacing only that trigger's action. - `Object.prototype.toSource()` writes plain data (strings, numbers, booleans, null, undefined, arrays, objects) that eval reads back. It refuses functions, cycles, more than 64 levels, 10,000 values or 1 MiB with an error the script can catch. Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * feat(engine): run a form's open, Will Save and Will Print actions and its widgets' pointer and focus scripts (#269) Ported from #344 by @DWAA1660 onto the per-document script session: each runs in the document's retained realm, so state the document scripts and earlier events left is kept. - The catalog /OpenAction's JavaScript (and its /Next chain, bounded and cycle-safe; other action types skipped) runs once on opening, after the document scripts, for background opens and reloads too, and again on Revert in a fresh realm. Event Doc/Open. - `Session::run_document_actions` runs /AA /WS (Will Save) or /AA /WP (Will Print). A failing action is reported and never stops the save or print. doc_save and doc_print run them first and report what they said (`will_save`, `will_print`). - Scripts that run unasked (open, Will Save, Will Print, pointer over, focus) may only ask for highlight, zoom, focus or a page; a click's Mouse Down / Mouse Up keep their requests. - `Session::field_trigger` runs a widget's Mouse Enter, Mouse Exit, Mouse Down, Mouse Up, Focus or Blur JavaScript (one undoable edit), reading only that widget's dictionary. `field_focus` now runs an AcroForm widget's On Focus / On Blur as well as XFA enter/exit. - New tool `js_event`; form_focus's description says AcroForm focus scripts run too. Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * feat(ui): Will Save before saving, Will Print before printing, and widget pointer scripts in the app (#269, #247) Ported from #344 by @DWAA1660. - Save (both paths) runs the document's Will Save actions first, and Print its Will Print actions; what they change is saved or printed, and what they say is shown. - The pointer moving onto or off a form widget queues its Mouse Enter / Mouse Exit script, a press its Mouse Down. A click on a check box or radio button queues its Mouse Up after the toggle, so the script reads the value the click stored (#247). The queue runs after the frame's edit. Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * docs(parity): document actions and widget triggers are partly supported (#269) Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * test: check toSource's text (scripts can't eval it) and the trigger event names (#269) Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * test: a check box's Mouse Up reads its new value; keep the fixtures on screen and the realm across an in-place save (#247, #269) Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * fix(engine, forms, js, ui): review fixes for document actions and field triggers - widget trigger actions follow /Next, each action its own edit; errors don't stop the chain - setAction installs on the field the object stands for when names repeat - toSource refuses non-plain objects and a __proto__ key - doc_print checks the destination before Will Print; js_event returns only its own output - combo/list clicks run Mouse Up; a refused click's Mouse Up doesn't run - label crops are re-read when Will Print changed the document Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * forms: run a pointer trigger on the field it hit and refresh the edited field's draft A trigger now carries the field's object, so of fields sharing a name the one under the pointer runs its own script (Session::field_trigger_target); js_event passes the field it resolved. A trigger script changing the field being edited shows in its editor unless the user already typed there, as focus scripts do. Co-authored-by: DWAA1660 <dwatnip123@gmail.com> * forms: carry the field's identity through focus scripts and js_event Focus transitions now track the field object, so moving between fields sharing a name is a move and the field that gained or lost focus runs its own script (Session::field_focus_target). js_event takes an optional field_id from form_fields to pick one of fields sharing a name. Co-authored-by: DWAA1660 <dwatnip123@gmail.com> --------- Co-authored-by: DWAA1660 <dwatnip123@gmail.com> |
||
|
|
96bcdfec1a |
feat(automation): js_page and js_advance; parity and docs for page actions and timers (#169)
Co-authored-by: Peter Yatsyshin <p.yatsyshin@googlemail.com> |
||
|
|
3a117c3c0e |
M10: open Word, Excel and PowerPoint files through LibreOffice
## What this changes
**File ▸ Open opens Word, Excel, PowerPoint, OpenDocument and RTF files** as new, unsaved PDFs (`Report.docx` → `Report.pdf`), the "LibreOffice sidecar" that `docs/gaps.md` (gap 8) and `docs/file-format-parity.md` planned for `create.from-office`.
- **Conversion** (`crates/create/src/office.rs`): an installed LibreOffice runs headless as a separate process, in a private temporary folder (the input is always `document.<ext>`, so the user's file name never reaches its command line). It gets a fresh profile with `DisableMacrosExecution`, `MacroSecurityLevel` 3 and `BlockUntrustedRefererLinks` set, and Writer's and Calc's `Content/Update/Link` set to *Never* (2 for Writer and 1 for Calc: the two number their values differently), no console window on Windows (`CREATE_NO_WINDOW`), and is killed after 120 s. The output is size-capped (512 MB), must start `%PDF-`, and must open as a PDF before it is used. LibreOffice is found through `PDFCRAFT_SOFFICE`, the `PATH`, then the usual install folders per OS. Without it, the user is told it's needed rather than "not a readable PDF".
- **Off the frame thread:** File ▸ Open converts on the existing open worker (`ResultKind::Converted`); the frame thread only opens the result.
- **Detection:** `SourceKind::Office` requires an Office extension *and* an OLE, ZIP or RTF signature, so `photos.zip`, or a PDF saved with a `.docx` name, are not misread.
- **Open dialog:** PDF (still the default), Images, Office documents, Text, All files. All files is left out on macOS, where rfd merges every filter into one allowed-types list, and on the web; Office documents are left out on the web. The extension lists are now shared constants in `pdfcraft-create` (`IMAGE_EXTENSIONS`, `TEXT_EXTENSIONS`, `OFFICE_EXTENSIONS`), used by both detection and the picker. The duplicate filter list in `open_dialog` is gone. The two new labels are in all 22 catalogues, with their `ATTRIBUTION.toml` hashes updated.
- **Automation:** `doc_create_multiple`, `doc_combine` and batch `convert` go through `convert_to_pdf`, so they take Office documents too; their descriptions say so.
**Deliberately not in this PR:** Insert pages, Combine files and Create ▸ Multiple files convert on the frame thread, so they now refuse Office documents with a pointer to File ▸ Open (`convert_to_pdf_inline` / `as_pdf_inline`) rather than freezing the window for seconds. Moving them onto a worker is the follow-up. `create.from-office` goes planned → **partial**, with that and the rest listed in its notes.
## How you verified it
On Windows 11 Pro with LibreOffice 26.8.1 installed, per crate:
- [x] `cargo fmt --check`
- [x] `cargo clippy -p pdfcraft-create -p pdfcraft-engine -p pdfcraft-ui-egui -p pdfcraft-automation -j 2 --all-targets -- -D warnings`
- [x] `cargo test -p pdfcraft-create -p pdfcraft-engine --lib` (42 and 276 pass); `-p pdfcraft-automation --test automation` (the combine/create tests); `-p pdfcraft-ui-egui --lib open_worker` and `--test editing --test create`
- [x] `cargo xtask layers`, `cargo xtask assets`, `cargo xtask parity --partial`
- [ ] wasm check: the `wasm32-unknown-unknown` target isn't installed here, so I'm leaving it to CI. The web paths are `cfg`'d and were reviewed by eye.
**Tests seen failing before the fix**, by reverting each part:
- Detection off → `office_documents_are_their_own_kind`, `source_kind_tells_pdfs_images_and_text_apart`, and both engine Office tests fail.
- Worker conversion off → `file_open_converts_an_office_document_on_the_worker` fails with the old user-facing message, *"the file is not a readable PDF: no readable page tree or cross-reference data was found"*.
New tests also cover a converter that hangs (it's stopped; the test binary stands in for LibreOffice), one that writes no PDF, a missing converter, temp-folder cleanup, `file://` URL escaping (spaces, drive letters, UTF-8), and the search order.
**Real conversions, end to end:** `crates/automation/tests/it/office.rs` builds a minimal DOCX, an XLSX (with a formula, `=6*7`), a PPTX and an RTF inside the test, so no binary fixtures are committed. It runs them through `doc_create_multiple` in `separate` mode (each output reopened and its text checked, including `42`) and in `combine` mode (page order and bookmarks), and through `doc_combine` beside a PDF, with a page range on one file. These tests, `libreoffice_converts_a_document_when_installed` and the process-tree cleanup test (5 out of 5 reruns) pass with LibreOffice 26.8.1. The Office tests skip where LibreOffice isn't installed, which includes CI.
Three existing tests used a 4-byte `report.docx` as their "file that can't be converted" example. That's no longer true, so they now use `archive.zip`, which keeps what they test.
## Never-crash
- [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests
- [x] No input-derived indexing or slicing (`rsplit_once` for the extension); the PDF read back is size-capped
- [x] No `unsafe`. The Windows flag uses `std::os::windows::process::CommandExt`
- [x] A crashing, hanging or misbehaving LibreOffice is an error, never a panic or a stuck app: the worker's `catch_unwind`, a 120 s kill, and output checks
## Provenance
- [x] No Adobe assets; no fonts; no copied code
- [x] LibreOffice (MPL-2.0) is only *run* as an external process, as the docs planned; nothing of it is linked or copied. Its command-line options and the profile keys come from LibreOffice's public documentation.
- [x] The translations are contributor-original, written from the plain meaning of "Office documents" and "All files" ("Office" kept as a product name); hashes updated, `cargo xtask assets` passes
## Security
- [x] `--root` confinement unchanged: automation still resolves and reads paths before converting; only the private temp folder is written outside it
- [x] MCP and the control channel untouched
- [ ] **No new outbound network: please decide.** PdfCraft itself opens no connection. The profile blocks untrusted referer links and sets Writer and Calc never to update linked content on load. I converted eight synthetic files that link to a listener on 127.0.0.1: RTF `INCLUDETEXT` and `INCLUDEPICTURE`, a DOCX external picture, an ODT linked section and linked picture, an ODS table source and an external cell reference, and an ODP linked picture. None made a connection, with or without the link settings. Two things remain open: Impress has no link-update setting, and the process's network access isn't sandboxed (documented in `crates/create/README.md` and `docs/gaps.md`).
## Parity and reach
- [x] `create.from-office` planned → partial, with the evidence tests and what's still missing
- [x] Reachable headlessly (`doc_create_multiple`, `doc_combine`, batch `convert`)
- [x] Docs: `docs/file-format-parity.md` (Word/Excel/PowerPoint and RTF rows), `docs/gaps.md` gap 8, `docs/target-app-parity.md` row J (numbers not re-measured), `docs/roadmap.md` M10, the `ROADMAP.md` log, and the `crates/create` README
## Anything a reviewer should look at first
1. **The network question** above. It's the owner's call.
2. **The frame-thread restraint:** Insert, Combine and Create Multiple refuse Office documents rather than block. Is a worker for those wanted in this PR, or as a follow-up?
|
||
|
|
4efcfa6ea3 |
fix(crypt, engine): refuse page extraction when Protect allows any change except extracting pages (#5081)
## What this changes Adds `Permissions::extract_pages()`: `assemble()` **and** copying (bit 5), as #5081 asks, since extracted pages carry their text and graphics into a file without the source's protection. It is used for Extract, Split, Split by size and every Combine/Insert/Replace/paste source check (`sources::source_document`). Changes within the document (rotate, delete, move, insert) keep `assemble()`. Since this PR was opened, #6309 made `assemble()` revision-aware on `main`: bit 11 alone at revision 3 and later, bit 4 at revision 2. That already refuses "Any except extracting pages" at revision 3+. This PR builds on it: - At revision 2, `assemble()` reads bit 4, which "Any except extracting pages" sets, so such a file could still be extracted and split into unprotected copies. Requiring copying closes that. - New `Needs::PageExtraction` greys out Extract and Split up front. It reuses the existing security-refusal string, so no catalogue changes. - `Document::allows_page_extraction()`, and an `extract_pages` key in the automation security JSON. - `page_extract` with `separate: true` extracts and writes one page at a time (`extract_separate`), so it no longer buffers every page. The first page is extracted before `out_dir` is created, so a refused extraction leaves no empty directory. If a later page fails, the files this call wrote are removed, and `out_dir` too if this call created it (review on this PR). - Insert Pages checks a PDF through the same path as the insert itself: new `Session::insert_source(dest, name, bytes)`, which the UI's insert now calls (review on this PR). - The `organize.combine` parity notes now say "page extraction". Fixes #5081 ## How you verified it `cargo fmt --all` is clean. Regression tests (adopted from Harrison-Booth's review patch, plus CodeRabbit's follow-ups): - `crates/crypt/src/tests.rs::page_extraction_needs_assembly_and_copying`: unit test for `extract_pages()`. - `crates/engine/src/tests.rs::extraction_permissions_cover_revision_three_to_six_and_leave_no_partial_output`: AnyExceptExtract on RC4-128, AES-128 and AES-256 refuses Extract, Split, Split by size and Combine/Insert/Replace sources without the permissions password, leaves source and destination untouched, and the owner can do everything. The authorized combine output has 2 pages, and a differently encrypted or unprotected destination is refused. - `crates/engine/src/tests.rs::page_extraction_needs_the_copy_permission_on_every_revision`: a file that withholds only copying (R2 RC4-40 and AES-256) refuses extraction; the owner password lifts it. - `crates/engine/src/tests.rs::pages_under_the_same_protection_are_inserted_without_page_extraction`: a separately built file under matching protection is inserted, and the result stays restricted. - `crates/automation/tests/it/automation.rs::refused_extraction_writes_no_split_or_page_output`, and the `extract_pages` checks in `protecting_through_tools`, which now cover three presets, including a user (not the owner) for whom extraction is allowed. **Only the crypt unit test has been run locally, and it passes.** The engine and automation tests timed out while compiling on this machine and have not been run, nor seen failing without the fix. The one `pdfcraft-ui-egui` call-site change has not been compiled. CI is the first place these build. - [x] `cargo fmt --check` - [ ] clippy with `-D warnings` on the crates I changed (not re-run after the rebase) - [ ] tests pass on the crates I changed (crypt only) ## Anything a reviewer should look at first - **Rebased onto #6309.** The tests no longer expect "Any except extracting pages" to allow assembly at revision 3+. The same-protection paste tests now use the "Inserting, deleting and rotating pages" preset without copying. - **Copy (bit 5) is now required**, as the issue suggests. `crates/ui-egui/tests/it/editing.rs::protected_files_that_can_be_combined_are_flagged` used a copy-withheld file as "protected but combinable"; it now uses a print-withheld file, since a no-copy file is no longer a Combine source without the permissions password. - **Same-document paste**: Paste re-opens the document's own bytes as an Insert source, which the new check would refuse. `sources::open_source_into` accepts a source that withholds extraction but allows assembly only when the destination will be saved under exactly the same protection (file key and `/Encrypt` values), so cut/copy and paste within one protected document still works. Pasting into an unprotected or differently protected document is refused. One limit: after changing security in the same session without saving, a cut can't be pasted back until you save. - **Not in this PR:** CodeRabbit's `disabled_reason` suggestion for read-only documents predates this change and covers other commands too, so it belongs in a separate UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit - **New Features** - Page extraction and splitting now follow a dedicated permission check, distinct from page assembly. - Pages can be inserted from certain protected PDFs when their protection settings match the destination document. - **Bug Fixes** - Separate-page extraction now cleans up files created during a failed operation and avoids creating an output directory when the first page cannot be extracted. - Security details now report whether page extraction is permitted. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
f6c59c0b93 |
fix: integrate persistent AcroForm script workflows with native prompts and appearance writeback (#5699)
* AcroForm: integrate persistent timesheet script workflows * AcroForm: address review caching, worker stacks and live metadata * M6: address second review of AcroForm script workflows * M6: handle top-level ASI boundaries and verify cyclic calculation results * M6: bound script workers and isolate pending completions across edits * M6: make form resets visible before subsequent script reads * M6: include calculated dependents in reset comparison baselines * M6: bound reset writeback work before native completion * M6: charge expanded reset selections and field name bytes * M6: bound string conversion bytes and charge reset widgets * M6: preserve unread defaults and bound prompt text conversion * M6: bound reset calls early and preserve calculated field identity * AcroForm: address grouped calculations, field identity and widget ownership * AcroForm: retire field instances and address native review edge cases * AcroForm: route comparison Save As and Print to the source document * M6: dispatch text widget mouse-up scripts * M6: honor fit bounds for form button icons * AcroForm: bound calculation work and preserve reset and save integrity * Harden AcroForm script requests and worker recovery * Keep form callbacks and focus consistent across edits * AcroForm: preserve reset ordering and bound edit callbacks * Fix reset appearance ordering and XFA focus after row removal * Keep XFA focus indexes and stopped reset appearances consistent * Document form script execution and reset helpers * Keep script workers bounded and reject partial callback edits * Keep form events available after a document script reaches VM limits * Keep main's first-value Simple calculation and restore the calculateNow helper test AFSimple_Calculate (JavaScript) and the native Simple calculation count each field's first value again, as #5304 landed them; summing every selection of a multiple-selection list is a separate behaviour change. Restores the document-helper calculateNow test and the AFSimple_Calculate doc comment, and adds native and JavaScript multiple-selection cases. * Patch the callback field snapshot in place instead of rebuilding it Each field callback rebuilt all field states (3,129 on the benchmark form), and the retained realm held the previous snapshot, so stamping instance tokens copied it again. The runner now keeps its last snapshot and patches only the values and flags that changed; ScriptSession::stamp_fields stamps it before dispatch, the worker copies only when a token changes, and the realm drops the job's snapshot when the job ends (field identity is checked against the cached keys instead). * An oversized job script is that script's error, not a refused edit Realm::run refused a script too long or too deep to run as an execution refusal, which made the engine reject the whole edit (setting a 300 KiB calculation script failed). As on main it is now a plain script error that keeps the value; the realm is not touched. * Read a leading #! line as a comment in the chain scan; follow main's refusal and conditional limits in tests The nesting guard from #5079 now checks brackets, prefixes and conditionals; the document worker's preflight still bounds arrow-function and right-associative chains and skips a leading #! line as the guard does. A refused script is an error, not a refused edit, so the preflight test now checks the edit goes through with the error reported. --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
e317ccae44 |
Print: the printer's own paper sizes in the Paper list, named as the job's media (#2672)
* Print: the printer's own paper sizes in the Paper list, named as the job's media The work of #2672 on current main as one commit (its earlier four commits are on MaxFairwinds/pdfcraft `feat/printer-paper-sizes-pre-squash`), moved to the split Print dialog (workflows/print_ui/{draft,body}.rs) and the single integration-test binaries. - spool::printer_papers: on CUPS the queue PPD's *PaperDimension entries (named by their labels, the *DefaultPageSize one marked), read with the same queue checks and capped PPD read as printer_options; paper_of_size finds one by size, as the driver feeds it. - The Paper list offers the printer's sizes after the standard ones, read each time the dialog opens and when the printer changes. It starts on the printer's default size (the standard entry when that is a standard size as the driver feeds it), unless a paper was chosen, in the dialog or remembered from the last session (#2156), and the printer lists it. - The job names the chosen sheet as its media by the printer's own keyword, also for a standard size the printer has, else by main's media_option. - printer_papers tool; doc_print takes one of the printer's sizes as paper (paper_choice), and with none named uses the printer's default, for "default" the default queue's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Print: name the driver's default keyword for a size it offers twice; fix a parity evidence path A standard size chosen in the Paper list is sent as the printer's own keyword for it. When the driver offers that size under two keywords (Letter and Letter.Fullbleed), the job now names the driver's default one rather than the first. The printer_papers_are_read_from_the_queue_ppd evidence entry named a module path that xtask parity cannot resolve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Print: a chosen printer paper keeps its keyword when the sizes are read again When the chosen paper was one of the printer's own entries and its size is a standard one (Letter.Fullbleed), reading the printer's sizes again (the dialog reopened) matched it by size alone: it became the standard Letter and the job named the driver's default keyword for that size. The entry is now kept by its keyword when the printer still lists it at that size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Print: test that a PPD keyword that would break a CUPS option is not offered as a paper A paper's keyword becomes the job's `media` option. parse_ppd_papers already leaves out keywords with a space, `=` or a quote; the PPD test now has lines with each, and fails when that check is loosened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Print: on CUPS a job on a standard size names the PPD keyword of that size PdfCraft's 4 x 6 in preset goes out as w288h432, which a driver with its own keyword for that stock (a 102 x 152 mm label) didn't get mapped. A cups_media name, a w<w>h<h> name or a PWG self-describing name now maps to the nearest PPD paper within 5 pt a side, the epsilon CUPS's _ppdCacheGetPageSize uses. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
6b53325f28 |
M11: Optimize stores one-bit images and masks past 80 million pixels as monochrome images
The image steps leave an image over 80 million pixels alone, for memory: decoded at eight bits a pixel or more, it would hold 80 MB a component and more. An image already of one bit a pixel holds a byte for each 8 samples of a row, so a large black-and-white scan (an A0 page at 600 ppi has about 560 million pixels) was left as stored though its samples would take less than 80 MB. The monochrome step now takes an image of one bit a pixel as stored (an image mask, or one bit in one colour component), a picture's one-bit mask included, while its rows hold no more bytes than 80 million pixels of eight bits (`one_bit_bytes`): up to 640 million pixels when it is wide, and a strip one sample wide no taller than before. One it would pack from eight bits keeps the 80 million limit, as it is decoded at eight bits first. A fax image's code is allowed no more than 80 MB for its pixels however large the page, and four bytes a row, where it was allowed about a byte a pixel (`fax_code_allowance`). When planning how many pictures run at once, a one-bit image counts as the bytes its rows hold and one more a row, as decoding allows each row's end a few bytes besides its samples. The optimize README and the parity note say which images the monochrome step now takes, and the note states JBIG2's limit of 2^28 pixels in all, as the README does. `group_4_takes_images_of_one_bit_a_pixel_up_to_the_pixel_limit` now expects its one-bit image of 10,000 by 8,001 stored again, where it was left alone. The packing path counts what it decodes, for the tests, as the one-bit path does. Tests: `one_bit_images_past_80_million_pixels_are_stored_as_group_4` (a one-bit image, a picture's stencil mask and a picture's one-bit soft mask of 9,000 by 8,900), `a_one_bit_image_past_80_million_pixels_is_averaged_with_the_default_settings`, `an_image_too_large_for_the_jbig2_decoder_stays_as_it_is` (2^28 pixels stored as JBIG2, a row more left alone, and averaged), and the unit tests `one_bit_images_are_decoded_up_to_their_own_limit` and `a_one_bit_picture_counts_as_the_bytes_of_its_rows` (each with a strip one sample wide, at its limit and past it) and `a_fax_images_code_is_allowed_80_million_bytes_and_four_a_row` and `a_zero_wide_image_is_not_decoded`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY |
||
|
|
832a51e6d7 |
Fix #5211: persist JavaScript field colours (#5499)
* Fix #5211: persist JavaScript field colours * Read current document state in field scripts * Redraw form fields after validation changes * Format validation redraw regression test * Keep field list alive in redraw test * Refresh fields only after same-field scripts * Format conditional field refresh * Borrow accepted field value for storage * Redraw calculated fields from current appearance * Format JavaScript field state merge * Restore JavaScript runner document state * Group JavaScript runner form inputs * Read current field display state in scripts --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
d0b17ef95f |
Add JavaScript push-button caption methods (#5505)
* Add push-button caption script methods * Apply scripted caption with other field changes * Complete caption field property initializers * Apply scripted captions to every button widget * Format caption regression test * Cover caption getter errors and redo state * Assert button caption undo state * Reject button caption writes during format events * Test empty push-button captions * Validate push-button caption updates * Keep no-widget caption test data alive * Check caption clipping marker --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
9f96a6f222 |
Merge upstream/main into feat/recent-reveal-5452
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
c73a53705b |
Fix #5211: make calculateNow synchronous (#5304)
* Fix #5211: make calculateNow synchronous * Bound and cache calculation execution * fix(engine): invalidate field calculation cache * perf(js): build calculation scripts lazily * Refresh calculation cache after page insertion * Load calculations for document script helpers * Assert imported calculation result * Initialize formatted field-change state * Update formatted calculation test expectations * Include the referenced field in calculation test --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
3df6be4eff |
feat(js): expose document page boxes (#5501)
* feat(js): expose document page boxes * Normalize page boxes for getPageBox * Correct page box test expectations and formatting * Use local page helper in box test --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
d47adeff89 |
M4: bind property drafts with edit-session and replay UI scenarios (#4594)
Binds Properties dialog drafts to the vendored edit-session crate (byte-identical to PerchAnton/edit-session@033f7c3a, ledger in vendor/README) and adds replayable UI scenarios. Includes a merge of main and a test covering the clean Properties inspection-tab live refresh. |
||
|
|
92b965dba3 |
M10: preserve annotation layers in vector print output (#5019)
* M10: preserve annotation layers in vector printing (#5005) * #5019 test: a Popup is the annotation that never prints; a Link prints since #5028 --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
1c1a5d746e | Merge main and retain grayscale spooler conversion | ||
|
|
919db9bd51 |
M10: preserve NoRotate appearance geometry in vector printing (#5036)
* M10: preserve annotation placement precision (#4995) * M10: preserve NoRotate and implicit Text print orientation (#5029) Keep existing printable appearances upright on rotated source pages, including Text annotations whose NoRotate flag is clear. Preserve original flags and appearance streams, print eligibility and outer page transforms. * M10: clarify NoRotate verification docs --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
eaff44e4d7 | Merge main and retain one printer for paper and duplex discovery | ||
|
|
6cded6a5a3 |
M10: a booklet's both sides follow a driver that keeps its own two-sided setting (#5772) (#5903)
* M10: a booklet's both sides follow a driver that keeps its own two-sided setting (#5772) Booklet ▸ Both sides always asked for two-sided printing on the short edge (#2707). A driver that doesn't take two-sided settings from other programs (no two-sided printing, manual two-sided only in its Properties, Microsoft Print to PDF) then made craft-print refuse the whole job. The reporter's Epson ET-2870 offers only OneSided, and its manual two-sided setting is what prints their normal two-sided jobs. print::booklet_job_duplex asks such a driver for nothing on both sides, so its own setting applies, as for ordinary printing (#2422) and as Acrobat enables two-sided for a booklet only "if available". Unknown support still asks for the short edge; one side on its own stays one-sided. The Print dialog takes the chosen printer's support from the printer list (PrintDraft::printer_two_sided, also behind its "its own setting applies" note), and doc_print reads it only for a booklet's both sides. The dialog's booklet test used the machine's printers, and on Windows the default, Microsoft Print to PDF, now gives the other answer: it sets its own printers and checks the note too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * M10: doc_print's lookup of a booklet printer's two-sided support is tested (#5772) The booklet test fed job_duplex the printer's answer directly, so a lookup that missed the default printer or matched the wrong one would have gone unnoticed. The search over the printer list is now its own function, two_sided_in, tested with a list of named, default and unknown printers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * M10: a booklet printed to "default" goes to the printer whose driver was asked (#5772) doc_print decides a booklet's both sides from the printer's two-sided support. For "default", the job named no printer, so the spooler picked whichever printer was the default when the job was submitted, after the document was rendered. The printer found in the list is now the job's printer, by name, and the lookup test covers a one-sided default. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * #5903: the booklet test lists its printers through a stand-in source It set the dialog's printer list by hand while the real list was still loading. On a machine with no printers (CI's Linux runner) the list that arrived replaced them and reset the printer, so the dialog the test clicked through was not the one it set up. The printers now come from the dialog's own source, drivers unasked as #3554 lists them, with each driver's two-sided answer in the map. --------- Co-authored-by: austin62jake <340374338+austin62jake@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
afca38ad71 |
M10: retain printed artwork with indirect annotation metadata (lands #4668) (#6855)
* M10: retain printed artwork with indirect annotation rectangles * M10: resolve indirect annotation appearance states when printing * M10: follow bounded annotation reference chains when printing --------- Co-authored-by: Kyle Kassen <85040622+KyleKassen@users.noreply.github.com> |
||
|
|
a7f0074381 |
M8: doc_hidden_info and the parity note say what the refusal covers
Review of the refusal. `doc_hidden_info` said it lists what Remove Hidden Information would remove. A page that can't be read in full is counted as one item of hidden text and of hidden layers, so that the removal runs and refuses it: since the refusal before this, that includes a page holding bytes the parser can't read or an inline image whose end is a guess, not only content streams that don't decode. The description now says so, and that with form fields removed too, a field's appearance is read the same way though it isn't counted. The parity note on Apply Redactions lists the new refusal beside the inline image's. Removing hidden layers alone refuses such a page in a document without `/OCProperties` too, which a review asked to narrow: a membership dictionary there (`/AllOff` of a layer that is on) still hides what it marks, for the walk and for the app's renderer. The comment at the refusal in `sanitize.rs` says only what the bytes are shown to hide: text in a broken `TJ`. Tests: `bytes_the_parser_cannot_read_refuse_removing_hidden_layers_alone`; `hidden_text_beside_bytes_the_parser_cannot_read_in_a_field_appearance_is_refused` (removing form fields with hidden text, and Sanitize Document, which went on and left it); and `hidden_text_beside_bytes_the_parser_cannot_read_is_refused` gains hidden text in a broken `TJ` inside a form. The form-away test's doc says the check after the walk would still refuse a form without resources. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY |
||
|
|
905e9abf6f |
fix(forms): ignore print requests from automatic field scripts (#4166)
* fix(forms): ignore print requests from automatic field scripts * docs(contributors): opt in to GitHub profile name sync --------- Co-authored-by: enriquemelzer-bit <319226743+enriquemelzer-bit@users.noreply.github.com> Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
de24a4ddba | Merge branch 'storytold:main' into fix/paper-size-driver-5861 | ||
|
|
debb826f29 |
M10: preserve annotation placement precision (#4995) (#5002)
Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> |
||
|
|
1427a114e5 | Merge remote-tracking branch 'upstream/main' into fix/paper-size-driver-5861 | ||
|
|
ebc9de101b | Merge remote-tracking branch 'upstream/main' into fix/paper-size-driver-5861 |