diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 68fc076b97..fefa778afa 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -3945,6 +3945,11 @@ impl Session { // Signed documents are only ever saved incrementally: an edit that needs a full rewrite // (applying redactions, changing security, sanitizing) would invalidate the signatures. // So does any edit to a file rebuilt from object headers: it has no chain to append to. + // Deleted pages are freed, but an incremental save keeps them (and their text) in the + // earlier revision and the file does not shrink (#3407): rewrite an unsigned file in full. + if !signed && matches!(edit, Edit::DeletePages { .. }) { + next.require_full_save(); + } let rewrites = |c: &pdfcraft_cos::Document| c.full_save_required() || c.encryption_changed(); if signed && ((rewrites(&next) && !rewrites(&editor.cos)) || (next.is_modified() && next.revisions().is_empty())) { return Err(EditError::SignedRewrite(edit.label().to_string()));