RedactRegion

Page manipulation

Requires the Enterprise edition. In Delphi, C++Builder and Lazarus code create the library as TPDFlibEnterprise (unit PDFlibEnterprise); the Enterprise DLL and ActiveX builds provide it unchanged. Other editions keep the method, which returns 0, an empty string or False and sets LastErrorCode to 900 (PDFLIB_ERROR_ENTERPRISE_REQUIRED)

Description

Truly removes text, vector paths, shadings and images 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)

After a redaction the document is always saved in full: the save drops the objects the redaction left unreferenced, and an incremental save is refused, because it would keep the earlier revision, and the removed data with it, in the file

For each content layer and nested Form XObject the method parses the stream and tracks the graphics state. Optional behaviours controlled by Options: stamp a black fill box over the region, and emit a standard /Subtype /Redact annotation

Limitations: path and image bounds use the bounding box of the transformed geometry, which is conservative for rotated or sheared transforms

Syntax

Delphi

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

ActiveX

Function PDFlib::RedactRegion(Page As Long, Left As Double, Top As Double, Width As Double, Height As Double, Options As Long) As Long

DLL

int DLRedactRegion(int InstanceID, int Page, double Left, double Top, double Width, double Height, int Options);

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)