evo-pdf-redaction-engine
Performs physical redaction of identified content in PDF documents using PyMuPDF's redaction API. Handles exact string redaction, regex-based redaction, hyperlink removal, metadata scrubbing, and secu
SKILL.mdtasks-evolved/paper-anonymizer/environment/skills/evo-pdf-redaction-engine/SKILL.md
GitHubevo-pdf-redaction-engine
Performs physical PDF redaction using PyMuPDF (fitz). Applies redaction annotations, removes hyperlinks, purges metadata, and saves securely with garbage collection.
Key Functions
redact_exact_strings(page, strings)- Add redaction annotations for exact string matchesredact_regex_patterns(page, patterns)- Add redaction annotations for regex matchesredact_page_region(page, rect)- Redact an entire rectangular regionscrub_hyperlinks(page, link_patterns)- Remove identifying hyperlinks and redact their textscrub_metadata(doc)- Purge standard and XMP metadataanonymize_pdf(input_path, output_path, exact_strings, regex_patterns, link_patterns)- Full pipelinesave_redacted_document(doc, output_path)- Save with garbage=4 and deflate=True
Usage
import sys
sys.path.insert(0, '/app/environment/skills/evo-pdf-redaction-engine/scripts')
from redaction import anonymize_pdf
anonymize_pdf(
input_path='/root/paper1.pdf',
output_path='/root/redacted/paper1.pdf',
exact_strings=['Author Name', 'University Name'],
regex_patterns=[r'arXiv:\d{4}\.\d{4,5}'],
link_patterns=['arxiv.org', 'github.com']
)