PdfCraft: An open-source PDF reader and editor written by scratch in pure Rust
Merge PR #3728: Refuse redaction marks with no readable area instead of skipping them
aionggee0b147a6157
diff --cc crates/redact/src/lib.rsindex c59343c69,51afc85d9..6df5102af--- a/crates/redact/src/lib.rs+++ b/crates/redact/src/lib.rs@@@ -154,15 -159,15 +160,21 @@@ pub(crate) fn annots_of(doc: &Documentpage.get(b"Annots").map(|a| doc.resolve(a)).and_then(|a| a.as_array().cloned()).unwrap_or_default()}+/// Every annotation the pages list. Compared before and after a removal, what is no longer listed+/// leaves the structure tree too ([`tags::drop_object_refs`]).+pub(crate) fn listed_annotations(doc: &Document) -> HashSet<ObjRef> {+ pdfcraft_model::pages(doc).iter().flat_map(|p| annots_of(doc, &p.dict)).filter_map(|a| a.as_ref()).collect()+}+/// Every redaction mark in the document, page by page.pub fn marks(doc: &Document) -> Vec<Mark> {- let mut out = Vec::new();+ marks_checked(doc).0+ }++ /// [`marks`], and the 0-based page of each Redact annotation that has no readable area, which+ /// [`apply`] refuses rather than skipping.+ pub(crate) fn marks_checked(doc: &Document) -> (Vec<Mark>, Vec<usize>) {+ let (mut out, mut unreadable) = (Vec::new(), Vec::new());for (pi, p) in pdfcraft_model::pages(doc).iter().enumerate() {for a in annots_of(doc, &p.dict) {let Some(r) = a.as_ref() else { continue };