RedactRegion

Page manipulation

Description

Truly removes text, vector paths, and image XObjects whose painted area intersects the rectangle, by editing the page content stream so the underlying glyphs, vectors, and image bytes are gone and cannot be recovered. This is fundamentally different from MaskRect, which only paints an opaque rectangle on top of the content (the original bytes remain and can be extracted).

For each content layer the method parses the stream, tracks the CTM (honouring cm/q/Q), identifies instructions whose transformed bounding box intersects the region, and deletes them. Optional behaviours controlled by Options: stamp a black fill box over the region, and emit a standard /Subtype /Redact annotation.

Limitations: CTM tracking is approximate for sheared/rotated transforms (linear scales and the identity baseline are handled exactly). Text width is estimated from glyph count and font size since the content stream alone carries no metrics. Image XObject placement is approximated as the unit square transformed by the CTM.

Syntax

Delphi

Function TPDFlib.RedactRegion(Page: Integer; Left, Top, Width, Height: Double; Options: Integer): Integer;

Parameters

PageThe 1-based page number
Left, TopTop-left corner of the region in current measurement units (top-left origin)
Width, HeightRegion size in current measurement units
Options0 = remove + black fill + Redact annotation; 1 = remove only; 2 = remove + Redact annotation (no fill)

Return values

>= 0The number of instruction ranges removed across all content layers (0 means nothing intersected)