NAME
PDF::Make::Redaction - Mark and apply content redactions
SYNOPSIS
use PDF::Make::Document;
use PDF::Make::Canvas;
use PDF::Make::Page qw(:fonts);
use PDF::Make::Redaction;
my $doc = PDF::Make::Document->new;
$doc->title('Sensitive Report');
$doc->author('Internal');
my $page = $doc->add_page(612, 792);
$page->add_std14_font('F1', HELVETICA);
my $c = PDF::Make::Canvas->new;
$c->BT->Tf('F1', 12)->Td(72, 700)->Tj('SSN: 123-45-6789')->ET;
$page->set_content($c->to_bytes);
# Mark areas for redaction
PDF::Make::Redaction->mark($page,
rect => [100, 695, 280, 712],
overlay_color => [0, 0, 0],
overlay_text => 'REDACTED',
);
# Or use individual coordinates
PDF::Make::Redaction->mark($page,
x0 => 100, y0 => 650, x1 => 280, y1 => 670,
);
# Check count
my $n = PDF::Make::Redaction->count($page); # 2
# Apply redactions (burns overlays into content)
PDF::Make::Redaction->apply_page($page); # single page
PDF::Make::Redaction->apply_doc($doc); # all pages
# Remove metadata (author, title, etc.)
PDF::Make::Redaction->sanitize($doc);
$doc->to_file('redacted.pdf');
DESCRIPTION
PDF::Make::Redaction provides a two-step redaction workflow following PDF specification conventions:
- 1. Mark - Define rectangular areas to be redacted, with optional overlay text and color.
- 2. Apply - Burn the redaction overlays into the content stream, permanently removing the underlying content.
A separate sanitize step removes document-level metadata (title, author, subject, etc.) from the Info dictionary.
CLASS METHODS
All methods are class methods called on PDF::Make::Redaction.
mark($page, %args)
PDF::Make::Redaction->mark($page,
rect => [x0, y0, x1, y1], # or use x0/y0/x1/y1
overlay_color => [0, 0, 0], # RGB, default black
overlay_text => 'REDACTED', # optional text overlay
overlay_font_size => 10, # default 10pt
);
Mark a rectangular area on $page for redaction.
rect- ArrayRef of [x0, y0, x1, y1] in PDF coordinatesx0, y0, x1, y1- Alternative: specify corners individuallyoverlay_color- RGB color array for the redaction box (default [0,0,0])overlay_text- Text to display over the redacted areaoverlay_font_size- Font size for overlay text (default 10)
count($page)
my $n = PDF::Make::Redaction->count($page);
Returns the number of redaction marks on the given page.
apply_page($page)
PDF::Make::Redaction->apply_page($page);
Apply all redaction marks on a single page, burning overlays into the content stream. Croaks on failure.
apply_doc($doc)
PDF::Make::Redaction->apply_doc($doc);
Apply all redaction marks across every page in the document. Croaks on failure.
sanitize($doc)
PDF::Make::Redaction->sanitize($doc);
Remove all metadata from the document's Info dictionary (title, author, subject, keywords, creator, producer). This is typically called after applying redactions to ensure no sensitive metadata remains. Croaks on failure.