mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-29 17:54:59 +01:00
f4e722029ff910a442003fc052d462e5c7e79579
1224
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) | ||
|
|
b50a17f717 |
Merge pull request #7180 from rezaprama/fix/redact-unreadable-annotations
fix(redact): refuse annotations with unreadable bounds |
||
|
|
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 |
||
|
|
20830d092c |
Route PDF parsing and rendering through shared craft-pdf (#2068)
* refactor(render): route PDF reading and rendering through shared craft-pdf (storytold/craft-libs#778) * fix(render): convert u32 raster dimensions to usize for Pixels::zeroed * fix(render): remove unused hayro_syntax imports in inspect * fix(render): let shared raster dimensions reject rounded over-budget sizes before allocation * chore(pdf): repin craft-libs to #2497 and align tests with shared contract * fix(render): align remaining 8 tests and OutputLimit error with craft-libs contract * docs(attribution): update ATTRIBUTION.md for shared hayro* dependencies * docs(attribution): include adobe_data suffix for hayro-cmap in ATTRIBUTION.md * docs(attribution): sync ATTRIBUTION.md with cargo xtask assets --write * docs(licenses): update NOTICE hash and hayro-interpret asset licences in LICENSES.toml --------- Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com> |
||
|
|
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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> 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 <noreply@anthropic.com> |
||
|
|
da17275b5e | lead: tests through the codemods (L-171 873 moves, L-219 ctx, E0615 method calls), standalone test crates build their own app, main/app_creator keep their signatures, automation's craft dependency, canvas borrow order | ||
|
|
d03b99ea54 |
Export: Word through craft-docx, from the shared word model (rebased #7592) (#7814)
* export: write RTF through craft-rtf's full writer, from the word model The pages are mapped onto a craft_wordmodel::Document (as_word.rs, the mapping the DOCX export will share), and craft_rtf::doc::export writes it. Over the small writer this keeps, in RTF: - pictures, inline (the engine no longer leaves them out for RTF); - each page's size, as a section per page (blank pages kept); - Heading 1 and 2 styles; - the title; - hard line breaks inside a paragraph or cell (storytold/pdfcraft#4723). It also fixes two bugs: \cellx was the absolute page x, so every column edge sat one left margin too far right, and tables that touched became one (NIST CSF 2.0 came out with 28 tables instead of 68). craft-rtf, craft-wordmodel, craft-docx and craft-mime are pinned together at one craft-libs commit: doc::export takes its own revision's Document. * export: pin craft-libs main with push_text, the header-row fix and the RTF generator name craft-rtf, craft-wordmodel, craft-docx and craft-mime move to craft-libs b8eaa8e2, which has storytold/craft-libs#1946, #1947 and #1950. The mapping appends through Paragraph::push_text/push_object, tables keep the default look, and the RTF names PdfCraft as its generator. * export: write Word through craft-docx, from the shared word model as_docx.rs no longer writes WordprocessingML itself: as_word::word_doc maps the pages onto a craft_wordmodel::Document and craft_docx::write writes it. The decisions stay the same: a page with rotated text or overlapping text keeps its layout as positioned text boxes and pictures (watermark-sized text behind, pictures over it, other text on top), the other pages flow, each page is a section of its own size, a shared page colour is the document's, the PDF's language goes in the slot Word keeps for its script, and the media limits are unchanged. Over the hand-written package this gains: - a VML fallback for every text box, so Word 2007 opens positioned pages; - rotated text as a turned text box Word draws as a line; - the body font named (Arial), with a font table saying it is a sans; - PdfCraft as the application in docProps/app.xml; - a picture drawn many times stored once. The tests that matched XML read the package back through craft-docx. * parity: the Word export through craft-docx, checked in Word 16, Word 2007 and LibreOffice * chore: update Cargo.lock after rebasing #7592 --------- Co-authored-by: kiwi4boy <kiwi4boy@gmail.com> |
||
|
|
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) |
||
|
|
cb94bfbaa0 |
pdf-shell-w12: net change of 2 commits
- pdf-shell-w12: written by an agent - pdf-shell-w12: finished by an agent |
||
|
|
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 <noreply@anthropic.com> * Say that page_set_box margins are user-space units Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> * Print readiness reads page boxes in points; Set Page Boxes batch keeps its wording Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> |
||
|
|
f8d8aef6e4 | M5: preserve macOS Minimize alongside Ctrl+M Comments (#3741) | ||
|
|
b81d150fc6 | Merge remote-tracking branch 'upstream/main' into pr-fix/tab-rename | ||
|
|
c480038d69 | chore: sync latest upstream for review | ||
|
|
7d44e65412 |
fix(xfa): resolve clippy lints on main (#7354)
* fix(xfa): resolve clippy needless_update and field_reassign_with_default * fix(create,xfdf): resolve remaining clippy lints * fix(export): remove needless borrow in pptx and as_docx * fix(engine): resolve clippy lints in signature_image * fix(automation): resolve clippy lints in tests * fix(create): avoid clippy::unreachable in tests * chore(deny): allow IJG license for jpeg-encoder via craft-image-codecs |
||
|
|
df267834ba |
Merge remote-tracking branch 'upstream/main' into pr-fix/tab-rename
# Conflicts: # Cargo.lock |
||
|
|
eead454105 |
Cut over remaining codecs, xfa XML, and export packaging to craft-libs (#7326)
* chore: cut over image, png, tiff, and zune-jpeg to craft-image-codecs * chore: cut over xfa XML parsing from roxmltree to craft-xml * chore: cut over export DOCX and PPTX packaging to craft-opc and craft-xml * style: cargo fmt |
||
|
|
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) | ||
|
|
fab2f6ea36 | test(redact): cover tool refusal and recovery | ||
|
|
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 <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> |
||
|
|
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 <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> |
||
|
|
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 <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> |
||
|
|
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 <245691047+LMatt08@users.noreply.github.com> |
||
|
|
65ea96da4c |
style: fmt and a type alias for clippy
Co-authored-by: Peter Yatsyshin <p.yatsyshin@googlemail.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> |
||
|
|
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 <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> |
||
|
|
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 <153173854+FredApps@users.noreply.github.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> |