mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-06 10:47:27 +00:00
fix(edit): backdrop copies keep no reference that outlives a redaction
The tag on a page's backdrop copy, `/PCBackdrop << /Original ref /At /Len >>`, kept the page's original content stream reachable. After Add background, then Redact (or Remove Hidden Information, or Edit text) and a full save, the text taken off the page was still in the file, in the original stream the tag pointed at. Text extraction didn't show it; reading the file's bytes did. Restore also gave up after any edit, so the fill stayed off without a word. The tag is now `/PCBackdrop << /Index n /Op (f) /Before <SHA-256> /Was [num gen] >>`: how many of the copy's operators come before the `n`, the fill it stands in for, a hash of those operators by value (redaction writes the stream out again with other spacing), and the original's number as two integers, which keep nothing alive. Remove background turns the fill back on in the copy when the operators before it still hash the same and a scan with the fill restored finds it painted first, covering the page. Edits and redactions after the fill are kept. When the original stream is still there with the same bytes, the page points at it again. Otherwise the copy stays as it is, and Remove background says which pages keep their own backdrop off: `EditNotice::BackdropsLeftOff` (engine), a toast in the app, `warnings` from `doc_remove_marks`. `edit_notices` holds `EditNotice` now, with the undrawn-text notice as one of its kinds. The two new UI strings are in all 33 catalogues. `sha2` (already in the lock file) becomes a dependency of `pdfcraft-edit`. Tests, each seen failing with its piece of the fix reverted: - `the_tag_holds_no_reference_and_a_full_save_keeps_no_second_copy_of_the_page` and `removed_text_leaves_the_file_when_a_background_replaced_the_pages_backdrop` (automation, redaction and Remove Hidden Information through a full save): fail with `/Original` back. - `a_fill_that_would_cover_content_painted_before_it_stays_off`: fails without the re-scan. - `a_copy_written_out_again_with_other_spacing_still_comes_back` and the automation test: fail when the raw bytes are hashed instead of the operators. - `an_edit_after_the_fill_is_kept_and_the_backdrop_still_comes_back`: fails under the old rule (only an unchanged copy comes back). - `remove_background_names_the_pages_whose_own_backdrop_stays_off` (engine), `remove_background_warns_about_pages_whose_own_backdrop_stays_off` (automation), `remove_background_says_which_pages_keep_their_own_backdrop_off` (UI): fail without the notice. - `a_change_before_the_fill_leaves_it_off_and_names_the_page`, `a_tag_that_does_not_add_up_is_left_alone` (hostile and old-format tags, never a panic), `operators_hash_by_value_not_by_spelling`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
47 files changed
+739
-79
No files matched your search
@@ -2509,7 +2509,7 @@ status = "shipped"
|
||||
commands = ["edit.background"]
|
||||
tools = ["doc_background", "doc_backdrops"]
|
||||
evidence = ["crates/ui-egui/tests/it/marks.rs::watermark_and_background_dialogs", "crates/engine/src/tests.rs::headers_footers_watermarks_and_backgrounds_show_update_and_remove", "crates/engine/src/tests.rs::backgrounds_and_watermarks_from_files", "crates/ui-egui/tests/it/marks.rs::backgrounds_and_watermarks_from_a_file", "crates/organize/src/tests.rs::a_page_becomes_a_form_xobject_upright", "crates/automation/tests/it/backdrop.rs::a_background_shows_on_a_page_that_paints_its_own_white_backdrop", "crates/ui-egui/tests/it/marks.rs::the_background_dialog_offers_to_replace_a_white_backdrop_and_warns_about_scans", "crates/edit/src/backdrop_tests.rs::content_that_is_not_a_page_backdrop_is_left_alone"]
|
||||
notes = "colour, or a picture from a file (an image or a page of a PDF) scaled relative to the page. A page that paints its own opaque white backdrop (browsers' Save as PDF, print drivers) used to hide the background entirely; the dialog now offers to replace that fill (on by default; Remove puts it back unless the content was edited since). Our own choice: Acrobat's behaviour on such pages has not been observed. Still hidden: scanned pages (warned), backdrops drawn inside a form XObject, by a non-rectangular path, or in a named colour space; the dialog preview is a schematic, not the page"
|
||||
notes = "colour, or a picture from a file (an image or a page of a PDF) scaled relative to the page. A page that paints its own opaque white backdrop (browsers' Save as PDF, print drivers) used to hide the background entirely; the dialog now offers to replace that fill (on by default; Remove turns it back on, after edits and redactions too, unless the operators before it changed or it would no longer be painted first, and then says which pages keep it off). The replaced copy's tag holds no page content or reference, so text a redaction or Remove Hidden Information takes off such a page leaves the file. Our own choice: Acrobat's behaviour on such pages has not been observed. Still hidden: scanned pages (warned), backdrops drawn inside a form XObject, by a non-rectangular path, or in a named colour space; the dialog preview is a schematic, not the page"
|
||||
|
||||
[[feature]]
|
||||
id = "edit.background-update-remove"
|
||||
@@ -2520,8 +2520,8 @@ milestone = "M7"
|
||||
status = "shipped"
|
||||
commands = ["edit.background.update", "edit.background.remove"]
|
||||
tools = ["doc_background", "doc_remove_marks"]
|
||||
evidence = ["crates/edit/src/tests.rs::replace_and_remove_restore_the_original_content", "crates/engine/src/tests.rs::headers_footers_watermarks_and_backgrounds_show_update_and_remove", "crates/edit/src/backdrop_tests.rs::a_white_fill_backdrop_is_replaced_and_put_back_when_the_background_goes", "crates/edit/src/backdrop_tests.rs::a_backdrop_copy_edited_since_is_kept_when_the_background_goes"]
|
||||
notes = "Remove also restores a page backdrop Add replaced"
|
||||
evidence = ["crates/edit/src/tests.rs::replace_and_remove_restore_the_original_content", "crates/engine/src/tests.rs::headers_footers_watermarks_and_backgrounds_show_update_and_remove", "crates/edit/src/backdrop_tests.rs::a_white_fill_backdrop_is_replaced_and_put_back_when_the_background_goes", "crates/edit/src/backdrop_tests.rs::an_edit_after_the_fill_is_kept_and_the_backdrop_still_comes_back", "crates/edit/src/backdrop_tests.rs::a_copy_written_out_again_with_other_spacing_still_comes_back", "crates/edit/src/backdrop_tests.rs::a_change_before_the_fill_leaves_it_off_and_names_the_page", "crates/edit/src/backdrop_tests.rs::a_fill_that_would_cover_content_painted_before_it_stays_off", "crates/engine/src/tests.rs::remove_background_names_the_pages_whose_own_backdrop_stays_off", "crates/automation/tests/it/backdrop.rs::removed_text_leaves_the_file_when_a_background_replaced_the_pages_backdrop"]
|
||||
notes = "Remove also turns back on a page backdrop Add replaced, keeping edits made after it; where that isn't safe it says which pages keep it off"
|
||||
|
||||
[[feature]]
|
||||
id = "edit.decoration-profiles"
|
||||
|
||||
Reference in new issue
Block a user