TextRedactor
in package
FinalYes
Redact text or areas from PDF pages by drawing filled rectangles.
Note: This is visual redaction (Phase 1). The underlying text bytes remain in the PDF. For full content removal, a future Phase 2 will rewrite content streams to strip text operators.
Usage: TextRedactor::open('contract.pdf') ->redactArea(1, 72, 700, 200, 20) ->apply() ->save('redacted.pdf');
Table of Contents
Methods
- apply() : self
- Apply all marked redactions. Must be called before save/toBytes.
- getPageCount() : int
- getReader() : PdfReader
- getRedactionCount() : int
- getVersionWarnings() : array<int, string>
- open() : self
- openString() : self
- redactArea() : self
- Mark a specific area for redaction.
- redactPattern() : self
- redactText() : self
- Mark a text string for redaction across pages.
- save() : void
- setRedactionColor() : self
- toBytes() : string
Methods
apply()
Apply all marked redactions. Must be called before save/toBytes.
public
apply() : self
Return values
selfgetPageCount()
public
getPageCount() : int
Return values
intgetReader()
public
getReader() : PdfReader
Return values
PdfReadergetRedactionCount()
public
getRedactionCount() : int
Return values
intgetVersionWarnings()
public
getVersionWarnings() : array<int, string>
Return values
array<int, string>open()
public
static open(string $path[, string $password = '' ]) : self
Parameters
- $path : string
- $password : string = ''
Return values
selfopenString()
public
static openString(string $pdfBytes[, string $password = '' ]) : self
Parameters
- $pdfBytes : string
- $password : string = ''
Return values
selfredactArea()
Mark a specific area for redaction.
public
redactArea(int $pageNumber, float $x, float $y, float $width, float $height) : self
Parameters
- $pageNumber : int
-
1-based page number
- $x : float
-
Left edge in points
- $y : float
-
Bottom edge in points
- $width : float
-
Width in points
- $height : float
-
Height in points
Return values
selfredactPattern()
public
redactPattern(string $regex[, PageSelector|null $pages = null ]) : self
Parameters
- $regex : string
- $pages : PageSelector|null = null
Return values
selfredactText()
Mark a text string for redaction across pages.
public
redactText(string $text[, PageSelector|null $pages = null ]) : self
Text positions are approximated — redaction rectangles cover the approximate line area where the text was found.
Parameters
- $text : string
- $pages : PageSelector|null = null
Return values
selfsave()
public
save(string $path) : void
Parameters
- $path : string
setRedactionColor()
public
setRedactionColor(float $r, float $g, float $b) : self
Parameters
- $r : float
- $g : float
- $b : float
Return values
selftoBytes()
public
toBytes() : string