True PDF redaction that permanently removes content from the content stream — not just the visible layer.
use pdfluent::{Sdk, redaction::{RedactionOptions, RedactionPattern}};
let sdk = Sdk::init_with_license("license.json")?;
let doc = sdk.open("contract.pdf")?;
let patterns = vec![
RedactionPattern::regex(r"\d{9}") // Dutch BSN
.with_replacement("[BSN REDACTED]"),
RedactionPattern::regex(r"account-nr: \d+")
.with_replacement("account-nr: [REDACTED]"),
RedactionPattern::metadata_key("Author")
.with_replacement("[REDACTED]"),
];
let opts = RedactionOptions::builder()
.patterns(patterns)
.remove_embedded_images(true)
.strip_metadata(true)
.generate_report(true)
.build();
let redacted = doc.redact(opts)?;
redacted.save("contract_redacted.pdf")?;
let report = redacted.redaction_report();
println!("Removed {} items", report.redacted_count());Run cargo add pdfluent@1.0.0-beta.5 to get started.
Redaction burns through to the content stream. Text, images, and metadata are permanently removed — not just visually hidden.
Strips author, creator, modification date, and PDF comments. XMP metadata, embedded files, and thumbnail images are fully removed.
Preview redactions before applying. Overlay shows exactly what will be removed, including content in hidden layers.
Define regex patterns for account numbers, SSNs, emails, or custom formats. Batch-apply across thousands of documents.
Generate a redaction report listing all removed content, page numbers, and redaction reasons for compliance.
Some tools only redact the visible layer. PDFluent operates on the content stream — embedded images and hidden text are caught.