Repository navigation
Conversation
Add Background draws behind the page content, so on a page that first fills itself with opaque white (browsers' Save as PDF, print drivers) the background was hidden completely and the tool looked broken. - pdfcraft-edit: new `backdrop` module. A strictly detected backdrop (one axis-aligned `re`, opaque white in a device colour space, painted before anything else and covering the crop box) is replaced by turning that one fill into `n` in a per-page copy of its stream; the original stream is left untouched for other pages. Remove background restores it, unless the copy was edited since. Page-sized pictures (scans) are reported only. - Background gains `replace_backdrop` (default on); the default colour is a visible light yellow instead of near-white. - Dialog: offers to replace the backdrop, warns about scanned pages, checks pages a few per frame, preview draws text over the colour. - Automation: `doc_background` takes `replace_backdrop`; new read-only `doc_backdrops` lists pages with a backdrop. Acrobat's behaviour on such pages is unobserved; recorded as our choice in parity/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The six new dialog strings (the backdrop offer, its note, the scan
warning and "Checking pages…") were missing from every catalogue, which
the *_covers_ui_literals tests require. Languages with several plural
forms use the "label: {n}" pattern so any count reads correctly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 22 interface catalogues are registered assets; adding the Add Background strings changed their SHA-256. Provenance is unchanged (contributor-original translations). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
A YouTube review showed Add Background "not working". It works on plain pages, but on a page that first fills itself with opaque white (browsers' Save as PDF, print drivers, many generators), the background is drawn behind that fill and is completely hidden. A near-white default colour (
[1, 1, 0.85]) made it look broken even where it did work.pdfcraft-edit: newbackdropmodule. Strict detection: onere, axis-aligned, opaque white in DeviceGray/RGB/CMYK, painted before anything else, covering the crop box (clip and ExtGState honoured). To replace it, that one fill operator becomesnin a per-page copy of its content stream, and the original stream object is left untouched for other pages that share it. The copy carries/PCBackdrop << /Original ref /At /Len >>, so Remove background restores the original, but only if the copy is still exactly what we wrote. An edit made since is kept. A page-sized picture (a scan) is reported only, never touched.Backgroundgainsreplace_backdrop(default on). The default colour is a light yellow that is visible on screen.doc_backgroundtakesreplace_backdrop. New read-onlydoc_backdropslistsfill/imagepages.How you verified it
cargo fmt --check-D warningsonpdfcraft-edit,-engine,-automation,-ui-egui(--all-targets)cargo test -p pdfcraft-edit(166),-p pdfcraft-automation(all suites),-p pdfcraft-ui-egui --test ui_group marks::,--test commands, enginebackground/markscargo xtask layers,cargo xtask assets,cargo xtask parityTests, all seen failing with the fix reverted:
crates/edit/src/backdrop_tests.rs): replace and exact restore; a split across content streams; update-then-remove; a shared stream copied for one page only; an edited copy kept on remove; 19 not-a-backdrop cases left byte-identical (partial, clipped, grey, translucent, unknown gs, pattern, default black, painted-after, holes, non-rect paths, rotated, fill+stroke,Qunderflow, short operands,1e400); writer variants recognised (flipped Chrome-style CTM with clip, CMYK,sc, quarter turn).crates/automation/tests/backdrop.rs): rendered pixels are white withreplace_backdrop: false(the old bug) and red with it, through save/reopen; the scan page stays covered; Remove brings the backdrop back.ui_group/marks.rs): the offer and scan warning appear, unticking keeps the backdrop, ticking replaces it, and the offer is gone afterwards.Never-crash
unwrap/expect/panic!outside testsget()and checked conversions throughout. The scan is capped at 64 KiB and 4096 operators,qnesting at 64, and non-finite operands are rejected.unsafeProvenance
n) and black-box testing of our own output. Acrobat's behaviour on such pages has not been observed, so the parity notes record this as our own choice.Security
doc_backdropsreads none), no network, MCP unchangedParity and reach
edit.background-add/-update-removeevidence and notes updated, including what is still hidden: scans, backdrops inside a form XObject, non-rectangular or named-colour-space fills, and a preview that is still a schematicdoc_background replace_backdrop,doc_backdropsAnything a reviewer should look at first
walkinbackdrop.rs). I chose to miss backdrops rather than ever neutralise real content. Backdrops inside a form XObject are the most likely real-world miss.[1, 1, 0.85]to[1, 0.95, 0.7].🤖 Generated with Claude Code