Skip to content

M7: Header & footer: shrink the page content out of their way (#2140) - #2832

Open
switch87 wants to merge 3 commits into
storytold:mainfrom
switch87:shrink-header-footer-2140
Open

switch87 wants to merge 3 commits into
storytold:mainfrom
switch87:shrink-header-footer-2140

Conversation

@switch87

@switch87 switch87 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2140

What

Acrobat's Header & Footer dialog can shrink the page so the header, footer or Bates number doesn't land on the page's own text and graphics. PdfCraft only drew on top of the page. This PR adds that option, in the engine, the automation tool and the dialog. Bates numbering opens the same dialog, so it gets the option too.

  • HeaderFooter::shrink (crates/edit): the page's original content is scaled down evenly into the band the header and footer leave free (HeaderFooter::bands: the margin, the lines of the tallest box, and half the font size of clearance), centred across the page. A side with no text keeps its space. The scaling happens in display space, so a rotated page shrinks the way it is shown.
  • The scale is one small content stream placed first inside the existing q/Q wrapper and tagged as part of the header and footer. Remove and Update take it away again, Update never shrinks twice, and a background behind the page stays full size.
  • If the margins leave no room on any selected page, the request is refused before anything is drawn or replaced.
  • doc_header_footer takes shrink: true.
  • Dialog: a "Shrink the page content to make room for the header and footer" checkbox. The schematic preview shows the band the content shrinks into. The label is translated in all 22 catalogs, and their checksums in ATTRIBUTION.toml are updated.
  • Parity: edit.header-footer-shrink goes from planned to shipped, with its limits in the notes. ROADMAP progress log line added.

Not done yet (also in the parity notes): annotations (links, comments, form fields) and PdfCraft's own added text and images stay where they are. They are not moved with the content.

Rendered with pdfcraft-cli (synthetic page; header ACME Corp. - Confidential, Bates ACME-000001, 12 pt), before and after:

before / after

The dialog:

dialog

Tests

  • crates/edit: the exact scale and placement on an upright page, a rotated page (display space), Remove/Update undoing the shrink without stacking it (back to the exact original content), and the no-room refusal leaving the document unmodified. I checked that all four fail with the shrink disabled.
  • crates/automation: end to end. The moved text is read back from a saved copy (scale and centring), the no-room refusal is checked, and Remove brings the text back to its original box. This test fails without the tool argument.
  • crates/ui-egui (ui_group/marks.rs): Bates numbering opens the dialog, the checkbox turns on the shrink, and OK applies it. This test fails without the checkbox.

Run locally: cargo fmt --all --check, cargo clippy -p pdfcraft-edit -p pdfcraft-automation -p pdfcraft-ui-egui -p pdfcraft-engine --all-targets -D warnings, the tests of pdfcraft-edit, pdfcraft-automation, pdfcraft-ui-egui (lib, including the catalog-coverage tests, and ui_group) and the header/marks tests of pdfcraft-engine, plus cargo xtask layers, assets and parity. I couldn't run the wasm check locally, so CI covers that.

…torytold#2140)

HeaderFooter::shrink scales the original page content evenly into the
band the header and footer leave free, centred across the page, in
display space so rotated pages shrink the way they are shown. The scale
is a content stream first inside the q/Q wrapper, tagged as part of the
header and footer, so Remove and Update take it away again and
backgrounds behind the page stay full size. Margins that leave no room
are refused before anything is drawn.
The tool passes shrink through to the header and footer, with an end-to-end
test that reads the moved text back from a saved copy, refuses margins that
leave no room and checks that Remove brings the content back to full size.
…ld#2140)

The Header and Footer dialog (also opened by Bates numbering) gets a
checkbox that turns on the shrink, and its preview shows the band the
page content shrinks into. The label is translated in every catalog (the
catalog checksums in ATTRIBUTION.toml follow). The parity entry for the
shrink is shipped, with its limits: annotations and added text and images
are not moved yet.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] [PdfCraft] Shrinking pages when Bates numbering

1 participant