mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-03 12:36:23 -05:00
f4e722029ff910a442003fc052d462e5c7e79579
998
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
333b287a8b |
Production merge skeleton: upstream/main 9b3e6d6f3 into area/app-1 6cfe35235, conflict markers left in (42 files; 4 modify/delete keep the port's deletion)
|
||
|
|
888135baec | mcp: add protocol transcript tests for initialize, cancel, and batch (#7969) | ||
|
|
c05499f707 |
Merge pull request #2923 from regendorf-ux/pr/tab-rename
Rename the open file from its tab (Rename… and double-click), with names that work on every system (#2102, #2867) |
||
|
|
3f3b3e634a |
Adopt the shared AGENTS.md (RFC-0072) (#7937)
* Adopt the shared AGENTS.md (RFC-0072) and test rules (RFC-0071) * Point removed AGENTS.md section references at the shared standards |
||
|
|
d7f4c6a668 | mcp: delegate stdio framing and JSON-RPC envelopes to craft-mcp-server and craft-jsonrpc (#7910) | ||
|
|
f0bbce5b30 |
Issue #2385: audit finds thick strokes, black highlights and white boxes over text (#2408)
* Issue #2385: audit finds thick strokes, black highlights and white boxes over text Three ways of hiding text that a reader sees as redacted were reported clean while the text stayed extractable: - a thick stroke along the text (`0 G 20 w 70 705 m 400 705 l S`, marker style): the walker now tracks the stroking color, the line width and `/CA`, and a single axis-aligned `m`/`l` segment stroked opaquely counts as the rectangle it paints (half the width each side); - an opaque `/Highlight` annotation dark enough to hide the text (`/C [0 0 0]`): the annotation pass now reads highlights too (color from `/C`, `/CA`, Hidden/NoView skipped) and reports them as `covered-text`; - an opaque white rectangle after dark text (`1 g 70 695 330 20 re f`): its own kind, `hidden-under-white` (relative luminance of the paint >= 0.9; the `0.9 g` table shading stays unflagged), so callers can decide. The `doc_audit_redactions` tool description lists the new covers and kind; the module docs state the limits (slanted or bent strokes, other filled paths, shadings and patterns are still out of scope). Tests: thick_stroke_over_text_is_a_cover, black_highlight_annotation_over_ text_is_a_cover, white_rectangle_over_text_is_reported_as_hidden_under_white (the report's three cases, with the hairline, yellow, translucent, hidden and outlined negatives); graphics_state_carries_across_streams now expects the white kind for its white rectangle. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011K1peyrh5MdZ6ttHkVq8Gh * audit: ExtGState /LW and omitted alphas, stroke width across the CTM, white first, highlight quads (#2385 review) - gs sets /LW as the line width, and a /ca or /CA the dictionary leaves out keeps its earlier value (ISO 32000-2 8.4.5) instead of resetting to opaque. - A stroke's width is measured across the segment after the CTM, so a non-uniform scale no longer widens horizontal and vertical strokes alike. - A white cover is hidden-under-white even over white text, which the contrast check had classified as covered-text. - An opaque Highlight hides what its /QuadPoints paint, not its /Rect; the /Rect stays the fallback when there are no usable quads. Tests: ext_gstate_sets_line_width_and_keeps_omitted_alphas, stroke_width_follows_a_non_uniform_ctm_across_the_segment, white_cover_over_white_text_is_hidden_under_white, highlight_covers_its_quad_points_not_its_rect * audit: document that a Highlight is judged by its dictionary, not its /AP Developed with AI assistance (Claude Code). * audit: a white Square is hidden-under-white; a hidden Redact mark is still unapplied (#2385 review) An opaque /Square with a white interior went through the dark-cover contrast test and was passed over, although it hides the text as a white rectangle in the content does: it is reported as HiddenUnderWhite, like that rectangle. The Hidden/NoView skip applied to every annotation, so an unapplied /Redact mark with either flag was no longer reported, which main reports: the flags hide the mark, not the text, so the skip is for the cover annotations only. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011K1peyrh5MdZ6ttHkVq8Gh * audit: a stroke's round or square caps are part of the cover (#2385 review) `stroked_rect` left the caps out, so a `1 J` / `2 J` marker line (or `/LC` in an ExtGState) painted half a line width past each end that the audit did not count: text under a cap stayed extractable and unreported. The cap is tracked like the width (`J`, `/LC`, cumulative, saved by `q`), and an axis-aligned stroke is lengthened by the pen's extent along it, `w/2 · |Mᵀ d̂|` after the CTM (the across-width is `w/2 · |Mᵀ n̂|`, the same rule). A round cap counts by its box. Butt caps, the default, add nothing. Test `stroke_caps_lengthen_the_cover`: butt, round, square, back to butt, vertical, a 4× scale along the stroke, a shear (√2), `/LC` with `/LW`, `Q` restoring it, and a stroke that reaches `IBAN` only by its cap. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011K1peyrh5MdZ6ttHkVq8Gh * audit: charge a highlight's quads against the comparison bound A highlight is compared with every line of its page once per quad, but was charged for one cover: a /Highlight with many /QuadPoints did page_cost x quads work for the price of page_cost. hidden_text now spends page_cost per area. QuadPoints is read only for highlights, and its length is checked before the numbers are collected. Developed with AI assistance (Claude Code). --------- Co-authored-by: Claude Fable 5.1 <[email protected]> |
||
|
|
1620fd1a6c |
pdf-shell-w14: net change of 4 commits
- pdf-shell-w14: written by an agent - pdf-shell-w14: finished by an agent - pdf-shell-w14: finished by an agent - pdf-shell-w14: review fixes (review-1) |
||
|
|
894904616d |
Form-data import says when the form refused every value
Importing form data whose only value the form refuses now fails and names the field, instead of reporting success. Fixes #7409 <details><summary>Details for review</summary> **Cause:** the issue's analysis is right. `pdfcraft_xfdf::apply_values` records refused fields in `Report::rejected` and the library deliberately returns `Ok(report)`. The engine's `ImportData` handler (`crates/engine/src/edit/run.rs`) only looked at skipped comment appearances and dropped `rejected`, so the edit committed as an ordinary Import step: dirty, an Undo entry, and Redo cleared. **Fix:** - If the file gave values for known fields and the form refused all of them (no field and no comment taken), the import returns a new `DataError::Refused` (shown as "the form refused every value in the file, so nothing was imported: "Choice""). Nothing is committed, so Undo, Redo and the dirty state stay as they were, like the existing "nothing matches this document" case. The tools and the UI already show the edit error. - If some values took and others were refused, the import still applies the valid ones, as the issue allows, and the repair log names the refused fields (first five, then a count). - `doc_import_data` (CLI/MCP) returns the repair entries that import appended in `import_repairs` (empty when everything was taken), so a caller sees a refused value without calling `doc_info`. - The library's own behaviour is unchanged. **Tests** (`crates/engine/src/tests.rs`; and `crates/automation/tests/it/automation.rs`: `form_data_import_response_names_the_fields_the_form_refused`, which checks the response of a full, a mixed and an all-refused import): `form_data_the_form_refuses_is_reported_and_leaves_the_document_alone`. A combo with options A and B, Undo leaves Redo available, then importing `Choice=INVALID` must fail naming "Choice" with Undo/Redo and the value unchanged; a second import with `Choice=INVALID` plus `Notes=hello` applies Notes and names only Choice in the repair log. It fails without the fix (I checked this). Checked: `cargo test -p pdfcraft-engine -p pdfcraft-xfdf -p pdfcraft-automation`: xfdf 130 pass, engine 779 pass, automation 451 pass. The 7 engine failures and 10 automation failures (OCR models, plus `file_processing_keeps_javascript_off_for_xfa_open_scripts` and `copy_restricted_text_stays_in_the_document`) fail the same way without my change. Clippy `-D warnings --all-targets` is clean for engine and automation; `pdfcraft-xfdf` has one existing `collapsible_match` finding at `xfdf.rs:326` on current upstream/main that I did not touch. rustfmt is clean. I did not run the CLI/MCP end to end. </details> |
||
|
|
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. |
||
|
|
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 ( |
||
|
|
df3f58d8b8 |
Set Page Boxes crops the margin you type on UserUnit pages (#7445)
* Convert Set Page Boxes margins by the page UserUnit The dialog's margins are physical (pt, in, mm, cm) but were written as user-space units, so a UserUnit 2 page cropped twice the requested margin. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * Say that page_set_box margins are user-space units Co-Authored-By: Claude Sonnet 5.5 <[email protected]> * Print readiness reads page boxes in points; Set Page Boxes batch keeps its wording Co-Authored-By: Claude Sonnet 5.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 5.5 <[email protected]> |
||
|
|
f8d8aef6e4 | M5: preserve macOS Minimize alongside Ctrl+M Comments (#3741) | ||
|
|
df267834ba |
Merge remote-tracking branch 'upstream/main' into pr-fix/tab-rename
# Conflicts: # Cargo.lock |
||
|
|
b7ffe8732f | xtask, export: update attribution, parity evidence, and RTF test for craft-libs cutover | ||
|
|
937c3fc7e1 | print: initialize driver_settings on craft-print Job | ||
|
|
524d9f6b64 | prc: remove crates/prc and cut over to craft-prc (#778) | ||
|
|
feec1853c0 |
Merge main into port-2081
Main now has page actions, timers and layers (#6985) and shared text allowances for inspection (#6015). Conflicts: - render/inspect/annotations.rs: main's collect_link (which notes JavaScript even when the link isn't listed) takes this branch's link script budget and its once-only warning; push_link is gone. - automation form_tools.rs, js tests.rs, docs/acroform-script-workflows.md: both sides added at the same place; both kept. Adapted to main: the link runner's Job gets `timer: None`, and, as a button's script does, the document's layers and the fields as page actions and timers show them (live_state). |
||
|
|
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 <[email protected]> * 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 <[email protected]> --------- Co-authored-by: KenM76 <KenM76> Co-authored-by: Claude Opus 5.5 <[email protected]> |
||
|
|
224b29701e | Merge remote-tracking branch 'upstream/main' into pr-fix/tab-rename | ||
|
|
c4e5748b4a |
Automation doc_rename: on Linux the move is made below the write root with no link followed (openat O_NOFOLLOW, renameat2 NOREPLACE)
A parent swapped for a link between the path checks and the rename could carry the file outside the root. macOS and Windows keep the check-then-rename model. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> |
||
|
|
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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * Lock craft-cms at the craft-libs commit craft-print now uses Co-Authored-By: Claude Opus 5.5 <[email protected]> * 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 <[email protected]> --------- Co-authored-by: KenM76 <KenM76> Co-authored-by: Claude Opus 5.5 <[email protected]> |
||
|
|
223c1f02d4 |
fix(scripts): review fixes for page actions and timers
- A page action or timer whose edits are refused shows nothing it did: view changes go in only after apply_script_outcome accepts them. - js_advance runs at most its 6,000-run cap; the last call only moves the clock (Session::run_timers_at_most). - Field callbacks see the document's layers (getOCGs), also after a batch rebuilds the runner. - The viewer's hit test uses what scripts show (shown_by_scripts): a frame they showed takes presses, one they hid doesn't. - Print previews draw without the live annotation and appearance overrides. - An appearance override naming no form (a cleared icon) draws nothing instead of the button's own face (hayro patch 105). - Page actions and timers wait while a dialog or prompt is open. - A timer editing the focused field refreshes its untouched draft. |
||
|
|
2c39b1d625 |
Merge pull request #6882 from Piohrun/fix/redact-unparsed-bytes
M8: redaction refuses a page whose content it can't fully parse |
||
|
|
b363f7a717 |
Merge pull request #6825 from Piohrun/feat/optimize-mono-masks
M11: Optimize stores a picture's one-bit masks as monochrome images |
||
|
|
43e3eb62bd |
Merge remote-tracking branch 'origin/main' into port-2081
# Conflicts: # crates/automation/src/a11y/form_tools.rs # crates/engine/src/lib.rs # crates/js/src/tests.rs |
||
|
|
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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * docs(parity): document actions and widget triggers are partly supported (#269) Co-authored-by: DWAA1660 <[email protected]> * test: check toSource's text (scripts can't eval it) and the trigger event names (#269) Co-authored-by: DWAA1660 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> --------- Co-authored-by: DWAA1660 <[email protected]> |
||
|
|
e47e9fbc5e |
automation: link_run_javascript, open_doc requests, links' JavaScript in doc_info
Ported from #2081 on main's ScriptSession: link_run_javascript runs a link's action with ordered answers (as js_run takes them) and reports its requests without carrying them out. Co-authored-by: LMatt08 <[email protected]> |
||
|
|
96bcdfec1a |
feat(automation): js_page and js_advance; parity and docs for page actions and timers (#169)
Co-authored-by: Peter Yatsyshin <[email protected]> |
||
|
|
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 <[email protected]> |
||
|
|
235ede4896 |
Print: flatten transparent sheets for GDI (v3) printer drivers (#6155, #5838, #5940) (#6955)
* Print: flatten transparent sheets for GDI (v3) printer drivers Windows sends a job for a GDI (v3) driver through its XPS-to-GDI conversion, which fails on soft masks (#6155), prints halos around them (#5838) or prints transparency as black boxes (#5940). XPS (v4) drivers print the same pages correctly. spooler_copy takes a flatten_transparency flag. With it, after greying and before tiling, each sheet that uses transparency is replaced by an opaque picture of itself (spooler::flattened): rendered at 300 dpi, lower for a sheet past 80 MP or 16000 px a side, in tiles of at most 2000 x 2000 px, each an RGB Flate image over white, so no tile reaches Windows' 2^22 px image cap and tiling leaves them alone. The sheet keeps its boxes and rotation; its group and annotations go. Sheets without transparency stay vector. pdfcraft-preflight gets page_uses_transparency, the PDF/A transparency search without counting a transparency group on its own, which Word puts on every page. Both callers pass false until the GDI-driver check lands. * Print: flatten transparent sheets only for a GDI (v3) printer driver spool::xps_driver / spool::gdi_driver read whether the printer's driver renders XPS itself, through craft-print's new xps_driver (storytold/craft-libs#804, winprint storytold/winprint.rs#21). The Print dialog and doc_print pass gdi_driver to spooler_copy's flatten_transparency, so XPS (v4) drivers, PDF printers among them, keep vector sheets. craft-print pinned to the craft-libs#804 branch, winprint to #21's, until they merge. * craft-print 60ede99985ef1e5df87a2aca66ed538eb23dec99: craft-libs main with #804 (xps_driver), winprint bc06a7c4 (#21) * Cargo.lock: the two winprint entries in Cargo's order (by source, after the re-pin) |
||
|
|
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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> |
||
|
|
3be126f9bb |
fix(engine, automation): Action Wizard and doc_batch honour JavaScript being off (#5080)
## What this changes Batch processing now keeps the caller's "Enable JavaScript" setting. Before, each file was processed in a fresh `Session::new()`, where JavaScript is on, so open-time XFA scripts and "Run a JavaScript" steps ran and their results were saved. - `actions::run_on` and `ocr::recognize_file` take a `javascript: bool` and call `set_javascript` before opening the file. In `recognize_file` the open now goes through a small private helper, `ocr::open_file`, so the open path can be tested without the recognition models. - `doc_batch`'s `Recipe` carries the setting into its per-file session and its OCR step. - Callers pass their own `session.javascript()`: the desktop Action Wizard, desktop multi-file OCR, `action_run`, `ocr_recognize_files` and `doc_batch`. Also relevant to #5054: an administrator's `DisableJavaScript` policy now reaches these sessions. Fixes #5080 ## How you verified it Regression tests, adopted from the reviewers' patches, plus one for the OCR open path: - `crates/engine/src/tests.rs::an_action_runs_a_javascript_step_only_when_javascript_is_on` (croquete1): a "Run a JavaScript" step writes its field with JavaScript on, and `run_on(.., false, ..)` refuses it instead of saving a scripted value. croquete1 reported it failing with the `set_javascript` call in `run_on` removed. - `crates/automation/tests/it/automation.rs::file_processing_keeps_javascript_off_for_xfa_open_scripts` (Harrison-Booth): with `js_enabled` off, an XFA initialize script that sets `qty` to 42 doesn't reach the output of `action_run`, `doc_batch` or (only when its models are installed) `ocr_recognize_files`. The contributor reported that each propagation removed on its own makes it fail. - `crates/engine/src/ocr.rs::tests::files_open_for_recognition_with_the_callers_javascript_preference`: opens the scripted XFA fixture through `recognize_file`'s open path with JavaScript off (the initialize script leaves `qty` empty) and on (it sets `qty` to 2). This covers the OCR propagation in runs without the OCR models. What was run locally, and what wasn't: - `cargo fmt --check` and `cargo clippy --all-targets -- -D warnings` were clean on `pdfcraft-engine`, `pdfcraft-automation` and `pdfcraft-ui-egui` at the earlier heads. On the latest commit only `cargo fmt --all` was run; clippy was not re-run. - No tests were run locally, including the new `ocr::tests` one: test builds time out on this machine, and the run was stopped before it compiled. The new test has not been seen failing either. If `set_javascript` is removed, the session keeps its JavaScript-on default, so the off case would read `qty` = 2 like the on case, and the first assertion would fail. Seeing that happen is still owed. - The tests are left to the maintainers' CI. No CI result is claimed for this PR. - [x] `cargo fmt --check` - [ ] clippy with `-D warnings` on the crates I changed (clean at the earlier heads; not re-run on the latest commit) - [ ] tests pass on the crates I changed (not run locally) - [x] `cargo xtask layers` and `cargo xtask assets`: N/A. No crate boundaries, dependencies or assets change. ## Never-crash - [x] No new `unwrap`/`expect`/`panic!`/`unreachable!`/`todo!` outside tests. The new non-test code only passes a `bool` and propagates errors with `?`. - [x] No indexing or slicing with input-derived positions, no new arithmetic, allocations or recursion. - [x] No `unsafe` - [x] Any crash this fixes has a regression test: N/A, this fixes no crash. ## Provenance - [x] No asset from an Adobe product, and no Adobe icon recreated, traced or imitated (no assets change) - [x] No font files committed here - [x] No GPL/AGPL code copied in - [x] Behaviour comes from the project's own JavaScript preference (`Session::set_javascript`) and issue #5080, not from another implementation's source - [x] Every new asset has an `ATTRIBUTION.toml` entry: N/A, no new assets ## Security - [x] `--root` confinement still holds: `action_run` and `ocr_recognize_files` still resolve every input and output through `resolve`, and `doc_batch`'s path handling is unchanged. No new paths are read or written. - [x] MCP and the UI control channel are untouched. - [x] No new outbound network access. - This narrows script execution: with JavaScript off, the per-file sessions of the Action Wizard, multi-file OCR, `action_run`, `ocr_recognize_files` and `doc_batch` no longer run document or step scripts. ## Parity and reach - [ ] `parity/acrobat-features.toml` not updated: this is a bug fix, and the `misc.batch-processing` entry's status (`partial`) and notes stay true. - [x] Reachable headlessly: `action_run`, `ocr_recognize_files` and `doc_batch` take the setting from the session, which `js_enabled` sets. - [x] Docs: N/A. No documented behaviour changes (`docs/cli-batch.md` doesn't describe JavaScript handling). ## Anything a reviewer should look at first - The existing `run_on` tests pass `true` to keep their behaviour; the tests above cover the JavaScript-off path. - `recognize_file` now has 7 parameters, the `too_many_arguments` limit. - The OCR branch of the end-to-end test runs only where the OCR models are installed. The engine unit test covers the OCR open path without them. Provisioning the models in CI is left as a separate decision. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * File actions, batch processing, and OCR now honor the JavaScript setting from your current session for each file. * When JavaScript is disabled, document scripts—including scripts that run when a document opens—won’t execute during processing. When enabled, JavaScript steps can run as expected. * This behavior applies across automated and in-app workflows. Per-file results and OCR output handling remain unchanged. <!-- end of auto-generated comment: release notes by coderabbit.ai --> |
||
|
|
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 <[email protected]> |
||
|
|
b10f85262c |
Test: the non-UTF-8 output-name probe test doesn't run on macOS (#6913)
output_probe_paths_preserve_non_utf8_names creates files named with bytes that aren't UTF-8. APFS keeps only UTF-8 file names, so on macOS creating the probe fails before the check runs and the test fails; no output can have such a name there. It runs on the other unix systems as before. Found running the automation tests on hosted macOS. |
||
|
|
1c1a5d746e | Merge main and retain grayscale spooler conversion | ||
|
|
fe70ecce73 |
Print in grayscale prints on a Windows driver with no grey option (#5806) (#6863)
* Print in grayscale prints on a Windows driver with no grey option (#5806) Windows refused Print in grayscale ("the printer's driver did not retain the requested grayscale; nothing was sent") on drivers that list no grey option the ticket can name: Microsoft Print to PDF, and an HP Photosmart driver whose grey is its own vendor setting. - On Windows, a grayscale job's copy for the spooler is made grey first with Convert colours (all pages, comments and form fields, black kept black, pictures re-encoded where they can be), and the job says so (Job::grey_pages). The driver is still asked for grey where it has it; one without prints the grey pages instead of refusing them. A copy that can't be read goes as it is and asks the driver strictly, as before. - craft-print 970644b7 (storytold/craft-libs#774) adds Job::grey_pages and asks a driver that lists only psk:Grayscale for that, not psk:Monochrome. - Both the Print dialog and doc_print go through spooler_copy, which now takes the job. * craft-print 1146cdc4: craft-libs main with #774 (grey pages) and #773 (the CUPS printer list waits at most 15 s, storytold/pdfcraft#6761) |
||
|
|
eaff44e4d7 | Merge main and retain one printer for paper and duplex discovery | ||
|
|
257c026c8a | fix(print): guard paper discovery and retain explicit custom stock | ||
|
|
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 <[email protected]> * 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 <[email protected]> * 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 <[email protected]> * #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 <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: FredApps <[email protected]> |
||
|
|
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 <[email protected]> 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 <[email protected]> Co-authored-by: FredApps <[email protected]> |
||
|
|
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 | ||
|
|
956935bf0b | Merge main into #6820: the area's sheet uses the chosen paper's size, custom papers included (#6830) | ||
|
|
e243022792 |
Print: custom paper sizes in the Print dialog, kept per printer with its setup (re-lands #2381) (#6830)
Brings back #2381 (by regendorf-ux), which #6706 reverted before v0.20.0 because its page-setup rows made the Print dialog as tall as Preferences and failed the dialog-height test. - Custom… beside Paper adds a named size in the preferences' unit (1 to 200 inches a side), kept with the settings; Remove takes it off the list. doc_print takes sizes such as 8.5x14in. - #2381's "Remember this paper for <printer>" box and its separate printer-to-paper map are left out: since #6779 every printer keeps its paper, sizing and two-sided choice on its own (#2001). That setup now keeps the paper by name, so a custom paper is found again however the list changes, and one removed since leaves the paper as it is. - The dialog scrolls within the screen since #6223, so the Custom… row no longer grows it. - The Print part of the settings restore is its own function (clippy's complexity limit). Co-authored-by: regendorf-ux <[email protected]> Co-authored-by: regendorf-ux <[email protected]> |
||
|
|
4bff30cf62 |
M10: Windows prints a large image whole: drawn as tiles under Windows.Data.Pdf's cap (#5131) (#5897)
* M10: Windows prints a large image whole: drawn as tiles under Windows.Data.Pdf's cap (#5131) Windows prints each page through Windows.Data.Pdf, which draws any image of more than 2^22 pixels from a copy shrunk to that size. With the page at the printer's resolution (craft-libs#396, #5023), a 6000 x 6000 scan still printed as 2048 x 2048, its one-pixel detail gone. pdfcraft_optimize::tile_large_images replaces each such image XObject with a form XObject of the same object number that draws it as tiles of at most 2000 pixels a side, so whatever drew the image draws the tiles. Samples are copied as stored (any bit depth and colour space, decode array, interpolation, colour key); a grey or RGB JPEG is decoded and stored with Flate; a soft or stencil mask of the image's size is cut into the same tiles. Tiles overlap by a pixel against drivers that soften image edges, except under a soft mask, where the overlap would blend see-through pixels twice. JPEG 2000, CMYK or ambiguous JPEGs, masks of another size, more than 80 million pixels, short data and images past the decode allowance are left whole. pdfcraft_engine::spooler::spooler_copy applies it to the copy that goes to the spooler on Windows, from the Print dialog's worker and doc_print; elsewhere, or when the copy can't be read or written, the bytes go as they are. The saved print-ready PDF is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * M10: a test that the spooler gets the tiles on Windows; tiles are up to 2001 px (#5131) spooler_copy was only tested with prints that pass through unchanged, so one that skipped tiling on Windows would have passed. A test now checks that on Windows it sends the tiled copy and elsewhere the bytes as they are. The optimize README said tiles have at most 2000 pixels a side; with the overlap they have 2001. Co-Authored-By: Claude Opus 5.5 <[email protected]> * M10: the tiles' samples are StoredSamples, apart from the crate's Samples (#5131) main has since added a public `Samples` (8-bit grey or RGB, for tools that repaint an image), so two different things in one crate shared a name. The tiles keep an image's samples as stored, in its own colour space and depth, so each tile redraws exactly what it replaces; the type now says so in its name and doc comment. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: austin62jake <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: FredApps <[email protected]> |