Commit Graph

1451 Commits

Author SHA1 Message Date
komo1iddin 36d239d2b1 M7: fold repeated group moves of a cropped image into one clip cm (#2476)
Moving an image whose crop is its own (`q re W n cm Do Q`) as part of a
group put a fresh `cm` before the clip path on every move, so twenty
moves left twenty `cm` operators in front of one `re`. It never nested
deeper, but the content stream grew with every drag.

When a `cm` already sits right before that clip (one an earlier move
added, or the file's own), `translate_images` now replaces it with the
product of the new and old matrices. The CTM at the clip is
`c · prev · outer` either way (ISO 32000-1 8.3.4, 8.4.4). A previous
`cm` that is not finite, or a product larger than 1e12, keeps the old
behaviour and inserts a separate `cm`.

The new test moves an image cropped smaller than itself twenty times and
checks that the image and its visible crop both moved by the full offset,
that the operator count stays at its value after the first move, and that
the caption after it is untouched. It fails without this change
(32 operators against 13).

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 03:47:08 -04:00
komo1iddin 7c8ca0bde8 M7: keep the text blocks cache after the document is edited (#2504)
The engine caches a page's text blocks for opening a paragraph and
applying its edit, but only while the document is unmodified: it was
keyed by the source identity, which edits keep. After the first edit the
cache never hit again, and the page was grouped again on every call (the
inline editor and the panel each call it after an apply).

pdfcraft_cos::Document::read_state() returns what the document reads as:
its source identity, its trailer and every changed object, compared as
allocations that the state keeps alive. A clone or a snapshot restored by
undo has the same state; any set, add, free or trailer change makes a
different one. The cache is keyed by it, so it hits after edits and never
returns another state's blocks.

On a page of 120 rows, text_blocks after an edit took 0.215 ms per call
and now 0.006 ms (release build, best of three; a throwaway timing test).

Tests: a read state matches a clone and not a document changed by set,
free or a trailer change, nor another document; after an edit the engine
groups the page once and undo and redo get their own blocks. The engine
test fails without this change.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Brandon Thomas <echelon@gmail.com>
2026-10-18 03:46:56 -04:00
Marco Arnulfo 946c6fdfc4 Comments: an attachment comment's menu saves or opens its file (fixes #2565) (#2585) 2026-10-18 03:46:10 -04:00
Marco Arnulfo cef2255da5 Edit text: a loaded font is applied to the paragraph being edited (part of #2591) (#2599) 2026-10-18 03:45:58 -04:00
mtlcl410 2c4b84f6af M8: redaction removes the replies of the annotations it removes (#2659) (#2697)
* M8: redaction removes the replies of the annotations it removes (#2659)

A reply (/IRT) placed away from the mark survived, and its /IRT kept the
removed annotation - its comment text and the QuadPoints of the redacted
words - in the saved file. Replies to a removed annotation, and replies to
those, now go with it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz

* M8: test replies listed before their parent, with a pop-up on a reply (#2659)

Review of #2697: the replies precede the annotation they answer in
/Annots, deepest first, and a reply has a pop-up. A single pass in
/Annots order would keep them; the test fails with the loop cut to one
pass, which the first test does not notice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 03:45:46 -04:00
NetterSilver 5377a223e9 Extract RTL lines with numbers and punctuation in logical order (#2736)
Fixes #2667

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-18 03:14:51 -04:00
mtlcl410 e827a2a17c M6: a box drawn with points along its sides is detected as a box (#2942) (#2947)
Field detection read a path as a rectangle only when it had exactly four
corners, and gave up on a subpath once it reached five points. The French
income tax form 2042 draws its letter cells with a midpoint on each
vertical side (six points), so most of its cells were not found.

A subpath now keeps up to 16 points, and a point lying on a straight side
between its neighbours is dropped before the four-corner test. A point
that turns back along a side is not between its neighbours and stays, so
a path that doubles back is still not a box.


Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 03:14:36 -04:00
NetterSilver 43f8ddf264 Apply JPEG EXIF orientation when creating PDFs from images (#2951)
Fixes #2944

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-18 03:14:25 -04:00
NetterSilver 17ddc8707d Fix overflow panic for i64::MIN index in content_update/delete (#2979)
Found while testing crates/automation/src/content.rs:141

Co-authored-by: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-18 03:14:13 -04:00
Kurtulus Gemici 70d7df548e fix(i18n): the web build's Auto language follows the browser (#2954) (#2998)
On wasm, detect_system_lang() always returned English, so Auto showed
English whatever the browser's language. It now reads
navigator.languages in order, then navigator.language, and takes the
first tag with a catalog, as the desktop builds do with the system
languages and as VectorCraft and FilmCraft do in their browser builds.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 03:14:01 -04:00
Guillem Hermida 233767d181 fix(ui): the Hand tool moves the page with the pointer (#924) (#3017)
The Hand tool scrolled by the page widget's drag delta from inside the
page view's ScrollArea. egui applies that delta when the area ends, after
the frame's pages are laid out and drawn, so the page showed each move a
frame late and trailed behind the pointer. (Until the page view stopped
animating its scrolls, the delta was also eased in over several frames,
which is the stutter #924 and #1992 describe.) On top of that, the points
the pointer moved before egui tells a drag from a click were dropped, so
the page never caught up with the grab point.

Pan before the area lays the pages out instead: when the page widget is
being dragged with the Hand tool, set the scroll offset from the last
offset minus this frame's pointer delta, or minus everything moved since
the press on the frame the drag is recognised. The page now moves point
for point with the pointer in the frame it moves, and still stops where
it is let go (no fling). Other scrolls (go to page, links, zoom anchors,
compare sync) are untouched and still win when asked for in the same
frame.
2026-10-18 03:13:49 -04:00
skylar taylor-barrick 7cce65917d Control channel: don't lose the refusal reply to a TCP reset (fixes deadline test flake) (#3165)
* Control channel: don't lose the refusal reply to a TCP reset

When the control channel refused an unauthenticated connection (deadline
passed, overlong line, bad first request) it wrote the error line and
closed the socket at once. If the client had sent input the server had
not read, Linux answers that close with a reset instead of a FIN, and the
reset can discard the reply before the client reads it. That is the
flake in an_unauthenticated_connection_is_closed_at_the_deadline: the
dripping client's bytes were still unread when the server closed.

Now the server shuts down its write side after the reply and reads and
discards input until the client closes or a 1 s linger passes, and only
then closes. The new test a_client_refused_with_input_unread_gets_the_reason
pins it deterministically.

* Control channel: refused connections linger outside the auth places

A connection refused before auth used to keep its place among
max_unauthenticated while it lingered (up to 1 s), so refusals could
keep real clients out. Now `refuse` gives that place back and takes one
of a separate, smaller set of lingering places (Limits::max_lingering,
8) before the reply is written. When none is free the connection is
closed right after the FIN instead of lingering, so threads stay
bounded as #1806 intended.

Tests: a_lingering_connection_holds_no_place_to_authenticate and
only_so_many_refused_connections_linger.

* Control channel tests: a 5 s linger for the two linger tests

Their timing checks (the auth round trips finishing within the linger,
and a non-lingering connection failing a write within half of it) had
only 1 s and 500 ms of margin with TEST_LIMITS. Each now serves with its
own Limits and a 5 s linger; the assertions are unchanged and neither
test waits for the linger on its passing path.
2026-10-18 03:13:07 -04:00
mtlcl410 15af2860f1 fix(ocr): the text layer restores the rendering mode it sets (#3029) (#3033)
text_layer wrote '/OCR BMC BT 3 Tr /PCHelv 1 Tf ... ET EMC'. Tr and the
font are graphics state, and ET doesn't reset them, so every content
stream after the layer on the page inherited 3 Tr: a header or footer
added after OCR was in the file but drew invisibly, in PdfCraft and in
MuPDF. The layer is now wrapped in q ... Q inside its marked content.


Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 03:12:37 -04:00
mtlcl410 4ff53a8d8e fix(engine): printing keeps layers hidden in the Layers panel hidden (#3046) (#3050)
The print-ready PDF copied the document's /OCProperties as they are, so it
printed the layers in their default state: a layer hidden in the Layers
panel disappeared on screen and came back on paper. Print as image already
used the view's layer choices (it renders with the document's config).

Once the layers have been changed, the copy imposed for printing now has
its default configuration (/D) set to them: /BaseState /ON, /ON the
visible layers, /OFF the hidden ones, its other entries kept. With the
layers untouched, the document's own configuration prints as before.


Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-18 03:12:26 -04:00
ogzhnklvz 13c86b40e8 i18n: Turkish section titles and in-sentence labels keep İ and ı (#3114)
Section titles are drawn upper case through to_uppercase(), and tool names
inside sentences lowercased through to_lowercase(). Rust's case mapping knows
no language, so in Turkish "Gelişmiş" became "GELIŞMIŞ" and "İmza" became
"i̇mza" (i plus a combining dot). Turkish maps i ↔ İ and ı ↔ I.

upper_label() translates and upper-cases a title with the Turkish rule when
the label has a Turkish row (an untranslated label is still English and keeps
the English rule); in_sentence() lowercases with it. Other languages are
unchanged. The test failed before the fix ("GELIŞMIŞ").
2026-10-18 03:12:05 -04:00
PerchenkoAnton f8d7eb1352 M3: prevent oversized page textures after replacement (#3149) (#3182) 2026-10-18 03:11:54 -04:00
Jules Kreuer d8b2705825 Clear replacement text (#1350)
* M8: Clear marked-content replacement text

* M8: Move roadmap note

* M8: Keep inherited resource guard clean under Rust 1.96

---------

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: skylar taylor-barrick <hi@skylar.cc>
2026-10-17 22:10:22 -06:00
Guillem Hermida 12fcc64115 Tests: make timing-dependent render and UI tests deterministic (#2812)
Seven tests failed at random on slow or busy machines, main included
(FreeBSD run 38834256439 at 5fdd820b). They now count the work or wait
for the state they check; no assertion is loosened and nothing retries.

- spot_colour_images_run_their_tint_transform_once_per_sample_value
  counts tint-transform runs (exactly 256, not one per pixel) through
  vendored hayro-interpret patch (34), color::tint_transform_runs, a
  thread-local counter, instead of a 10 s deadline.
- shadings_with_large_sampled_functions_paint_quickly: no counter tells
  the flat table from the hash map (both read every sample per build),
  so the build each paint does is timed against reading its samples on
  the same thread, fastest of 8 rounds each, and must stay under 10x
  (flat table 1.1x, hash map 109x), instead of a 10 s deadline.
- page_contents_and_nested_forms_share_one_budget: the budget is
  checked by its warnings; the deadline is only a hang guard, now 600 s.
- The pen-stroke tests hold finished renders back from the view
  (DocView::hold_rasters, for tests) while they look at the settling
  stroke, then wait by state for its raster.
- files_and_quit_from_the_operating_system waits for the tab before
  deleting the file the open worker reads.
- image_pixels_follow_the_frame_while_a_corner_is_dragged waits for the
  page raster on screen before each drag.

Product fix (#1858): a released drawing stayed painted only until any
raster of its page arrived. In full screen its edit is applied a frame
later, so a raster already under way could end the preview first. A
settling drawing is now marked committed when its AddAnnotation lands,
only rasters after that end its preview, and a failed edit drops it.
2026-10-17 20:53:39 -06:00
jonathanwxh-cell 958914e72b fix(edit): merge main into paragraph background repair 2026-10-18 10:41:08 +08:00
Brandon Thomas 645016addc Release 0.9.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v0.9.0
2026-10-17 21:43:00 -04:00
skylar taylor-barrick 3f5a784c2c Merge pull request #3102 from skylartaylor/fix/content-boundaries-and-mark-isolation
Read stream-boundary comments as the renderer does, and isolate new marks from appended graphics state
2026-10-17 18:03:38 -06:00
skylar taylor-barrick 4f6d16380a Merge pull request #2267 from MMexicann/fix/flate-fallback-output-limit
fix(filters): preserve output-limit errors in raw Flate fallback
2026-10-17 17:11:26 -06:00
skylar taylor-barrick 9b4af15b21 fix(edit): read marked content that spans content streams in one pass (#3081)
reading_lines grouped the joined operators by the stream their first token
is in and walked each group on its own. A marked-content sequence opened in
one stream (its /ActualText dictionary, or the whole BDC) and closed in the
next lost its replacement text: the export read "Glyphs" where every reader
of the joined streams reads "Replacement text".

The page's operators are now walked once. Each shown text still counts as
the stream its operator starts in, and text from another stream still starts
a new line, as before.
2026-10-18 00:27:50 +02:00
skylar taylor-barrick 7b39552ff1 Merge remote-tracking branch 'origin/main' into pr2267
# Conflicts:
#	ROADMAP.md
#	docs/roadmap.md
2026-10-17 15:58:13 -06:00
skylar taylor-barrick 0ac9b8403b Merge pull request #1917 from MMexicann/fix/xfdf-preserve-attribute-whitespace
M6: preserve whitespace in XML and XFDF attributes
2026-10-17 15:45:36 -06:00
skylar taylor-barrick 046ca7b947 Merge remote-tracking branch 'origin/main' into pr1917
# Conflicts:
#	ROADMAP.md
#	crates/xfdf/README.md
#	docs/roadmap.md
#	parity/acrobat-features.toml
2026-10-17 14:38:13 -06:00
skylar taylor-barrick 6d087c2d19 Merge remote-tracking branch 'origin/main' into pr2267
# Conflicts:
#	ROADMAP.md
#	docs/roadmap.md
2026-10-17 14:37:12 -06:00
skylar taylor-barrick be0254d708 Merge pull request #3091 from skylartaylor/deny-zbus-advisories
deny: acknowledge the new zbus unmaintained advisories
2026-10-17 14:26:40 -06:00
skylar taylor-barrick 54a45422c9 Merge pull request #2686 from MMexicann/fix/xml-form-text-nodes
M6: preserve complete plain XML form values
2026-10-17 14:19:05 -06:00
skylar taylor-barrick 43bb98eb88 fix(edit): isolate new marks from state left by content after an earlier wrapper (#3084)
place_tagged wrapped the page's content in q/Q only when no Wrap stream
existed yet. Content appended after an earlier wrapper (by another tool, or
an older OCR layer) that left a cm, a clip or text state set then moved,
hid or distorted every later header, Bates number, watermark, added text,
flattened annotation and redaction cover.

Placing a mark on top now reads the page's actual operators instead of the
/PCMark tags. When the content parses cleanly with balanced q/Q and closed
text objects and paths, the stretch from the first stream that leaves state
set is wrapped, once, at a stream boundary no comment runs into. Content
that is already self-contained gets no new wrapper, so repeated marks don't
pile up.

Content that can't be read that precisely (stray bytes, unbalanced q/Q, an
unfinished text object or path, too large) is wrapped whole as before,
rather than refusing: redaction stamps its covers after removing the text
and can't back out. A q that content leaves open is closed after it, where
closing it changes nothing already drawn.

The wrapper's close now starts with a newline, so a comment at the end of
the content before it can't swallow the Q. Removing marks strips only
wrapper pairs that end the list, keeping one that later content still
relies on, and recognises the older close bytes too.
2026-10-17 21:50:58 +02:00
skylar taylor-barrick 392406eb4a fix(content): read a comment at the end of a content stream as the renderer does (#3081)
Pieces::join separated a page's content streams with a newline, which ended
a comment left open at the end of one stream. hayro, MuPDF and Poppler join
them with a space, so the comment runs on into the next stream and hides its
first line. Edit text, object_list, the redaction audit, redaction and the
Office/HTML export therefore saw text and boxes that nothing draws, and
redacting unrelated text on the page made the hidden content visible: the
rewritten stream dropped the comment.

- Pieces::join uses a space, so every reader of the joined streams agrees
  with rendering.
- The parser records, per piece, whether a top-level comment runs into it
  and out of it (boundaries only, not every comment). A redaction rewrite
  of a piece ends an incoming comment before its first operator and leaves
  an outgoing one open, so hidden content stays hidden.
- Reading for export parses the streams joined, instead of one by one.
- The redaction tag check compares the joined streams the same way.
- Pieces::piece_of uses a binary search.
2026-10-17 21:50:58 +02:00
skylar taylor-barrick cee48385b7 deny: acknowledge the new zbus unmaintained advisories
RUSTSEC-2026-0370/0371/0372 were published today for zvariant, zbus_names and
zvariant_derive. All three are unmaintained notices rather than vulnerabilities,
and none has a fixed release to move to. They reach the tree as the D-Bus stack
behind accesskit_unix -> atspi (Linux accessibility) and as a dev-dependency of
pdfcraft-platform, so nothing ships in the other targets' binaries.

This is why main went red today; no dependency version changed.
2026-10-17 12:57:57 -06:00
skylar taylor-barrick bc7a12b94a Merge pull request #3083 from skylartaylor/linked-path-checks
Resolve remote links and document-supplied output names safely
2026-10-17 12:14:17 -06:00
skylar taylor-barrick 5cf11e9b8d Build: take craft-docpath from the merged craft-libs rev
craft-libs#169 is merged, so the fork pin is no longer needed. Pinned to
storytold/craft-libs 82a24b006eefa036b43c09a67fb9a3fbd17ffe63 (main after the merge) rather than the older 12281d07,
which predates resolve_absolute and the Windows colon refusal.
2026-10-17 12:03:16 -06:00
aiongg 0b3b63b22a Integration: #2717 the header-relative retry keeps its flag after the merge with the new head 2026-10-17 12:23:05 +00:00
aiongg 67686082a8 Merge PR #2532 (new head f5a2376c8)
# Conflicts:
#	ROADMAP.md
#	crates/redact/src/sanitize.rs
#	crates/redact/src/tags.rs
#	crates/redact/src/tests.rs
2026-10-17 12:22:17 +00:00
aiongg cc809ae2ed Merge PR #2717 (new head aea1d3d12)
# Conflicts:
#	crates/cos/src/document.rs
2026-10-17 12:18:46 +00:00
Mex 2f532ea68d Merge branch 'main' into fix/xfdf-preserve-attribute-whitespace 2026-10-17 13:42:05 +02:00
Mex a9d7774bbc Merge branch 'main' into fix/xml-form-text-nodes 2026-10-17 13:37:34 +02:00
Mex f98ee80953 Merge branch 'main' into fix/flate-fallback-output-limit 2026-10-17 13:31:43 +02:00
hcchung1 db1102185a docs: record how Acrobat prints a page area that is not relevant for print (#2574)
Observed in Acrobat Pro on the public ISCIII form: the once-only page keeps
its place when printing (7 pages with nothing typed) but is printed blank.
PdfCraft draws its content, and has no relevant attribute or print-off
layer yet; the note says so.
2026-10-17 16:01:39 +08:00
hcchung1 c5708e1cc6 fix(xfa): a page area's occur min gets its pages after the body (#2574)
A page area with <occur min="1" max="1"> that the body never reached was
never laid out, so the public ISCIII form lost the page that holds its
finishing instructions and the TERMINAR MEMORIA button once the repeated
copies over the body pages were removed.

PageArea records occur min (0 without an <occur>). When the body has been
laid out, an area used fewer times than its minimum gets the pages it still
needs, in template order, after the body's pages. The form is 7 pages with
the once-only page last, which is what Acrobat Pro shows.
2026-10-17 11:58:50 +08:00
aiongg 77776ca2c6 Build: use craft-docpath from craft-libs 2026-10-17 02:21:34 +00:00
aiongg ed1ab63cd0 Merge upstream main 924c4da4a into next 2026-10-17 01:59:44 +00:00
skylar taylor-barrick 924c4da4ac Merge pull request #2698 from mtlcl410/fix/audit-one-word-2662
M8: the redaction audit finds a cover over one word of a long line (#2662)
2026-10-16 16:05:39 -06:00
aiongg c7a6feb393 i18n: translate the new link and file-name messages 2026-10-16 21:02:39 +00:00
aiongg 265403813b fix(links): resolve remote document paths with the shared path check
GoToR file specifications go through craft-docpath: network, device and
object-manager paths (\??\, /??/) are refused without touching the
filesystem, relative targets resolve against the source document's
folder, and a result that is not absolute is refused rather than read
against the working directory. Files named on the command line open
under their absolute path, so their relative links keep resolving.
2026-10-16 18:16:50 +00:00
aiongg 08b44e858b fix(ui): keep output file names taken from documents inside the chosen folder
An attachment opened as a tab is named with the same plain file name as
its Save suggestion, and Export certificate names the file the same way
from the certificate subject. Writing files into a chosen folder refuses
any name with a separator, a drive, or that is . or .., so no caller can
write outside the folder.
2026-10-16 18:03:46 +00:00
mtlcl410 f5a2376c86 fix(redact): a structure tree too large to walk goes whole (#2447)
Review follow-up on #2532: drop_object_refs stopped visiting at 2,000,000
references and still reported success, so a reference beyond that could
keep a removed annotation reachable. A tree the walk can't finish is now
removed whole, with /MarkInfo: fail-closed, at the cost of the tags. The
limit is a parameter of drop_object_refs_within so the test can reach it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz
2026-10-17 02:02:23 +08:00
mtlcl410 4d6812503d fix(redact): flattened widgets and far pop-ups leave the structure tree too (#2447)
Review follow-up on #2532:
- the structure-tree references dropped are those of every annotation no
  page lists any more after Sanitize, so widgets flattened with "form
  fields" go too, with their field value;
- the annotations to remove are collected on every page first, so a
  pop-up listed on another page than its parent goes with it;
- an element left with nothing to tag drops /Alt, /ActualText, /T and /E,
  which can repeat the URL or comment;
- the test's byte search saves without object streams, so it can see the
  strings it looks for.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RUNQSPVXx3dDBabRZHAnjz
2026-10-17 02:02:23 +08:00