All tests run on an 8-year-old MacBook Air.
Drawing a black rectangle over text is not redaction.
The text is still there. Select all, copy, paste into Notepad β it appears. This has leaked classified documents from actual government agencies. Multiple times.
Real redaction destroys the underlying data. Here's how I implemented it.
What fake redaction looks like
PDF structure (fake redaction): Page content stream: "Salary: $120,000" β still here Annotation layer: [black rectangle] β just covering it
Enter fullscreen mode
Exit fullscreen mode
The content stream is untouched. Any PDF parser can read it.
What real redaction requires
Find the target text in the content stream
Remove it from the stream entirely
Replace with a filled black rectangle drawn directly into the content
Re-serialize the page β no original data survives
pub fn redact_text ( doc : & mut Document , page_id : ObjectId , target : & str , ) -> Result < (), lopdf :: Error > { let page = doc .get_object_mut ( page_id ) ?β¦