A nested /Order array may start with a text string label (ISO 32000-2
Table 99). One indirect string can head any number of direct arrays, and
each row decoded the whole string before cutting it to 256 characters, so
the work grew with rows times string length. Keep each indirect label
decoded once, by object number.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A print preview (a request carrying the print tag, with or without the
canvas's scale and grayscale bits) rendered with the document's on-screen
settings, so a layer the View auto state turns off was hidden in the
preview but printed. Printing is not the View event (ISO 32000-2
8.11.4.4), so the preview now leaves the auto state off like the print.
Also add a tool-level test of doc_info's layer_order rows for a /Order
with a group, a labelled nested array and an unlisted group (1-based
layer index, name, label and depth).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
The panel listed every group in /OCGs, flat. Table 99 says only the groups
/Order lists are presented, nested arrays as a tree, and a leading text
string in a nested array as a non-selectable label; in the default
configuration /Order defaults to the empty array.
- render: DocInfo::layer_order, rows of LayerRow { depth, item } where an
item is a layer (index into DocInfo::layers) or a label. A nested array's
entries are one level deeper than the layer or label before them. At most
4096 rows, 32 levels and 256 characters a label; an indirect array is read
once, so cycles end. DocInfo::layers is unchanged: unlisted groups keep
their state, draw, print and answer layer_set and set-layer actions.
- ui-egui: the Layers panel draws the rows, indented 16 points a level, a
label as a heading that can't be toggled; the count is the layers shown.
A document whose /Order lists none says so.
- automation: doc_info reports layer_order.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
The default configuration's /AS array (usage application dictionaries) was
never read, so a group whose /Usage /View /ViewState is OFF and that a
/View usage application manages still drew on screen.
- hayro-interpret patch (67): OcgState::from_catalog applies the View
event's auto state after /BaseState, /ON and /OFF and before
ocg_overrides. Each application with /Event /View and /View in
/Category recommends each listed group's /ViewState; a group is ON only
if every recommendation is ON. /Zoom, /User and /Language give no
recommendation. At most 256 applications, 4096 /OCGs entries and 16
categories each are read. InterpreterSettings::view_auto_state (on by
default) switches it.
- render: RenderConfig::for_print turns it off; print as image sets it,
since printing is not the View event.
- inspect: a layer's initial and visible state apply the same auto state,
so the Layers panel and doc_info match the page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A radio group with one /Opt export value per button and on states named
by position (/0, /1, ...; ISO 32000-2 Table 230) took the export value
"1" as the state /1, so it turned on the second button. Static XFA forms
build every exclusion group this way, with items 1, 2, 3. Asking for
option 1 selected option 2, 2 selected 3, and only the last option came
out right. Clicks wrote the button's position (0, 1) into the XFA data
instead of its item (1, 2), and XFA 3.3 ch. 4 and 17 say that data holds
the member's "on" item.
- Field::state_for_export resolves an export value: the per-widget /Opt
first, then the on-state names. state_for, which callers holding a
state (a click) use, is unchanged.
- form_fill resolves a radio option (the export value form_fields lists)
with it, and so does opening a static XFA form for the data's item. The
pre-strip comparison against the data compares export values.
- radio_dataset_value writes the selected button's /PCOn, else its /Opt
entry, else its state name.
On 24 public XFA forms (benefit, disability, pension and visa
applications) a fill test flipped 329 radio groups on main and none with
this change.
Tests (each fails with the fix reverted): a forms unit test, an
automation form_fill test on a pure AcroForm group, and an engine test on
a synthetic static XFA exclusion group (open from data, click, save and
reopen).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
- A same-name twin gets the copied /I mapped to its own options by export
value and text, so options listed in another order keep the option picked;
one with no match there leaves the twin selecting from /V, never part of /I.
- A position picked twice is written once in /V and /I, so they still match
item for item.
- Shift-click extends from the row clicked last, kept in the view: with rows
sharing an export value the value can't say which came last.
- A single-select list loaded from an array /V writes one value when its
shown row is clicked again.
(review)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Options are tracked by position as well as export value, so two options
sharing an export value (ISO 32000-2 Table 234, /I) show and pick the right
row; a single-select list given several values holds and shows the first;
/I matches /V item for item, repeats included; values match options in
linear time.
Rebased onto main as one commit: main split the forms crate's lib.rs into
read.rs and values.rs and moved forms_ui.rs into tools/. Folds the branch's
four commits.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
form_fill reads a name as an on state before an /Opt export, so an export
that equals another kid's on state would tick that kid instead
(ISO 32000-2 §12.7.5.2.3, Table 230). Fall back to the on-state names then.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
form_fields listed a check box's options by /Opt export, so kids sharing
the on state Yes with exports x and y showed as two options, though
filling either ticks both (ISO 32000-2 §12.7.5.2.3, EXAMPLE 2). It now
lists one option per distinct on state, named by its export unless two
states share one (Table 230 allows that), then by the state.
`checked` came from /V. It now follows the kid whose /AS is its on
state, which §12.7.5.2.3 makes decide where /AS and /V differ, so it
matches what the page shows.
Test: automation form_fields on shared-state, /AS-over-/V and
shared-export fixtures. Each assertion fails with its fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
A check box field with kids whose on states are A and B could only ever
tick A. With A ticked, clicking B cleared the field, so B's tick flashed
and vanished, and with nothing ticked, clicking B ticked A. The click sent a
field-wide Check(!on), and write_value always turned on the first kid's on
state, even for a value naming B.
§12.7.5.2.3 makes the field's /V the on state of the kid that is on (/AS
deciding where they differ), and Table 230 lets kids be checked
independently.
- A click on a kid that is off sends its on-state name: it (and any kid
sharing that state) turns on and the others off. A click on a kid that is
on clears the field. "On" is the kid's /AS (Field::widget_on).
- write_value: a named state or /Opt export ticks the kids with that state.
Check(true) keeps the kid that is on, else takes the first.
- Field::check_box_value maps a stored value to the state it names. Reset to
/DV, script value changes and FDF/XFDF import use it.
- The display-only fallback ticks only the kids that are on.
- form_fields lists a check box's options and the checked one when its kids
have more than one on state. form_fill takes the name.
Kids sharing an on state still tick together (EXAMPLE 2).
Tests: forms unit, ui-egui end-to-end clicks, automation form_fill and
xfdf import. Each fails with its fix reverted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0175FWj4xFhMhSH3UpMU8DSC
resetData resolved its targets through the generated fields, so a field of
a row an opening script added, with no widget until the form is laid out
again, kept the value a later script gave it, and the final layout saved
it. The reset now also walks the live form and puts the template's default
back in the data of every matching field with no widget yet (review).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Resets in a row are applied together; the names were deduplicated by
scanning the kept list for each new one, quadratic in the names a script
passes (its effects may carry hundreds of thousands within the payload
cap). The run now keeps a set beside the ordered list, and a reset of the
whole form still takes in the rest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
On a large dynamic XFA form, every script of an event copied the whole form
twice before it ran (the engine's live form to the script engine's tree, then
that tree to the flattened form the host works on), and every resetData call
rewrote and rescanned the whole document. On a 1,300-script form opening spent
its 3 s budget on these copies and on twenty resets, and skipped the last 850
initialize and calculate scripts.
The engine now sends the scripts of an event one shared tree (Arc) until the
live form changes in any way, and the script thread keeps the flattened form
it built from that tree; each script starts from a copy whose text is shared
(Arc<str>), so it costs a fraction of a flatten. Each script still gets its
own copy: nothing one script changes reaches the next except through the
engine. Resets in a row in one script's effects are applied as one reset of
the names together.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
On opening, the engine laid the form out again after every initialize or
calculate script that changed presence, access or instances. On a large form
one layout takes about the whole 3 s open budget, so the remaining initialize
scripts were skipped, and that half-initialized form was what saving kept: each
later opening hid more of it, and a page shown at the first opening, filled in,
was hidden and its data reset by the next one.
The scripts read the live form (template, data and overrides), not the pages,
and XFA 3.3 fires initialize after data binding, before layout (pp. 388, 390,
407). On opening, a needed layout is now recorded and done once in finish().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CBVyQEwtmEw3mS1MoAiwrK
Review follow-up on #2701: the test no longer requires the DLLs in the
host's System32 (the trimmed installations this supports lack them).
Instead a test-only override points the lookup at an empty folder and
submit, submit_with_progress and printers are called through: printing
is refused naming the DLL and no printers are listed, before any call
into the delay-loaded DLLs. The job names a printer that doesn't exist
and the bytes aren't a PDF, so a missing guard can't reach a real one.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pdfcraft.exe and pdfcraft-cli.exe imported windows.data.pdf.dll and
prntvpt.dll at load time (through craft-print's printing), so a trimmed
Windows installation without them refused to start the program at all.
The executables now delay-load the two DLLs, and the spool adapters
check that they exist before calling in: without them the printer list
is empty and a print job fails with a message pointing to Save as PDF.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review on #5316:
- Full screen started a page's /Dur (ISO 32000-2 §12.4.4.1) when the page
became current, so a slow render could use up its display time while the
page still said Rendering…. The time now starts once the page's raster has
arrived, or at once for a page the renderer can't draw.
Test: a_display_time_starts_once_the_page_has_rendered, which fails with the
fix reverted. a_display_time_on_the_last_spread_does_not_redraw_every_frame
now gives its page a raster, so it still reaches the display time.
- full_screen_plays_a_page_transition_and_honours_the_display_time also checks
the Wipe's painted output: a textured strip of page 2 as tall as the page and
only part of its width. It fails when the presenter stops painting the
incoming page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
- A click on a link, form field or comment turns no page in full screen:
the pointer stays active to click links and open notes (Adobe Acrobat
Help, 2019, p. 65).
- Shift+Ctrl+Page Up / Up Arrow go to the first page and Shift+Ctrl+Page
Down / Down Arrow to the last, as Home and End (p. 83).
- A transition waiting for its incoming page looks again every 50 ms
rather than asking for every frame; the render cache wakes the window.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
- Replacing the document clears the presenter: no transition, page or
timer of the old document carries over.
- A transition into a page that failed to render ends at once instead of
waiting for a texture that never comes.
- A display time that expires on the last spread asks for a redraw only
when the page actually moved, so the last spread doesn't redraw every
frame.
- A still pointer hides through a cursor claim on the top layer, which
every tool reaches, so it hides over a link too, and its tip with it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
A left click goes forward a page in full screen; a right-click now goes
back one, and full screen shows no context menu, as it shows no tools
(Adobe Acrobat Help, 2019, "Full Screen preferences", p. 69: "Left Click
To Go Forward One Page; Right Click To Go Back One Page").
Enter goes forward a page and Shift+Enter now goes back; it went forward
too (Adobe Acrobat Help, 2019, "Read a document in Full Screen mode",
p. 66: "To go to the previous page, press Shift+Enter").
parity: view.full-screen and view.full-screen-presentation cite the new
tests and say what is still missing; organize.page-transitions is now
played. docs/ui-parity.md row and revision history updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
In full screen, a page's transition (/Trans, ISO 32000-2 §12.4.4, Table
164) plays when the page comes into view, from the outgoing page's raster
to the incoming one's (render::transition geometry), and a page's display
time (/Dur) advances to the next page once it is up. A still pointer
hides after three seconds and shows again when it moves.
- Transitions play in single-page view without view rotation, once the
incoming page has rendered; spreads, a rotated view and the Animation
effects preference set to off change pages at once.
- Display times count from the end of the transition and stop at the
last page; the reader can turn the page sooner. The document's
durations are bounded (a transition at most 10 s).
The logic lives in canvas/presenter.rs; canvas.rs keeps its state on
DocView and calls it after drawing the pages, and the Animation effects
preference reaches it through PageEnv.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
The test sent a 500-character line, past the schema's maxLength of 200,
and only checked an upper bound on the page text, which also passes when
the line is missing. It now sends a 198-character template whose filled-in
line runs to 264 characters, and checks the saved /PCByLine holds exactly
200.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
On a page turned 90 or 270 degrees the stamp's rectangle has its sides
swapped in user space, and the appearance is counter-rotated so viewers fit
its turned bounding box to /Rect (ISO 32000-2 12.5.5). The lined layout was
computed in user-space axes, so that fit scaled the two displayed axes
differently: the picture came out squashed and the band stretched.
The layout is now made in the displayed box (the rectangle with its sides
swapped) and the stamp records the page's turn in /PCPictureRotate, so the
appearance carries the counter-rotation itself and a later restyle rebuilds
it the same way.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv
Review on #2345 (gabglus): the line was filled by chained replaces, so a
placeholder inside the author's name ("Ada {date}") was filled in too.
stamp_line now walks the template once and expands only the {name},
{date} and {time} it finds there; the author's text is kept as written.
Trimming and the MAX_STAMP_LINE cut are unchanged. The loop advances by
whole characters (strip_prefix, or get() past the next char), so it
cannot panic.
stamp_lines_fill_in_the_name_date_and_time gains the review's case and
a name made only of a placeholder; both fail with the chained replaces.
The UI test checks the saved /PCByLine has no placeholder left (from
gabglus's commit f6760b37).
Co-Authored-By: gabglus <gabglus@hotmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Catalan, Sorani, Finnish, Hindi, Indonesian, Korean, Lao, Norwegian Bokmål, Romanian, Albanian and Thai joined main after this branch was written. AI-assisted, as noted in each catalogue.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Create Custom Stamp offers an optional line under the picture, a
template with {name}, {date} and {time} filled in when the stamp is
placed, in the built-in dynamic stamps' format, and kept with the stamp
library. The picture keeps its shape above the line and the stamp widens
to fit the line. stamp_custom takes the same line.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An Undo of Apply redactions while the dialog that proposed the _Redacted
name was open saved the unredacted content under that name. Save now asks
again whenever an Apply redactions or an Undo of one changes what the
dialog's proposed name was based on.
The Save dialog proposes its name when it opens, and the document's bytes
are taken once the user chooses. An Undo past a saved Apply redactions in
between wrote the restored content to the redacted copy the dialog had
proposed. Save now asks again, proposing the name for the restored content.
After Undo past a saved Apply redactions, Save asks where but proposed the
redacted copy's own name, so the dialog's default was the redacted file.
It now proposes the name without _Redacted.
In the web build Save kept sending Save As to the host after the redacted
file was delivered, because the delivered steps stay counted for the
_Redacted name. Save now asks where only for steps applied since the last
delivery.
In the web build a delivered save keeps Apply redactions steps counted, so
Undo of a delivered step left Save writing to the host in place. Save now
asks where while fewer steps are in effect than were delivered, and a new
Apply after such an Undo marks the delivered steps as cut off.
A link annotation listed twice in one page's /Annots, or by two pages, kept its later references after the first one stripped its external action, leaving inert links on the page. Every reference to a link that ends up with no action and no /Dest is now removed. A shared link counts once in external_links.
Each JBIG2 bitmap is bounded, but nothing bounded how many a stream asks for, so a few hundred
bytes could tie up a render worker for minutes, and CodeRabbit raised the same on #5461. Measured
through pdfcraft-cli, before and after:
- one halftone segment, a 795-byte PDF: 265 s, now refused at once;
- 66 halftones over patterns 1 wide, a 3,894-byte PDF: about 330 s, now refused at once;
- about 226,000 generic regions behind nested Flate, a 923-byte PDF: unfinished at 40 s, some
88 hours by extrapolation, now 4.8 s;
- 8 dictionaries of symbols of no width, a 983-byte PDF: 81 s, now 0.7 s;
- about 1,048,000 generic regions of no width, a 34 KB PDF: unfinished at 90 s, now 2.6 s;
- an aggregated dictionary over 2^20 symbols, a 713-byte PDF: unfinished at 90 s, now 9.1 s;
- 10,000 instances of an 8192 × 8192 symbol, an 18 KB PDF: 64 s, now 3.2 s;
- 30 generic regions of no data: 48 s, now 4.7 s.
A stream may now ask for 2^30 units of work: four of the largest pages, about 6 s on data the
decoder predicts and about 17 s on data it can't, inside the viewer's 20 s watchdog. Decoding a
bitmap costs a unit a pixel and 4 a row, since a row costs time at any width. Copying one costs a
unit a word and 1 a row, so a tall thin bitmap costs its rows. Each item is charged before it is
decoded, apart from what is known only as it goes: new symbols and text instances are charged in
their loops. An aggregated symbol is charged for the symbol table it rebuilds. Past the bound the
image isn't drawn, as with the other caps, and the rest of the page is.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmsdeUCdTaD72jkDw2pJKY