Table of Contents

Class PdfRedactor

Namespace
MiPdf.Redaction
Assembly
MiPdf.dll

True redaction: the content inside the given areas is removed from the page content (text glyphs, image pixels, vector graphics, annotations, form fields, also inside form XObjects) and covered with boxes. The document must then be saved completely (not incrementally), so that the removed content is not kept in older revisions.

public static class PdfRedactor
Inheritance
PdfRedactor
Inherited Members

Examples

using var doc = PdfDocument.Open("contract.pdf");
doc.RedactText("John Smith");
doc.RedactText(new Regex(@"AT\d{2}(?: ?\d{4}){4}"));        // IBANs
doc.GetPage(1).Redact(new[] { new PdfRectangle(72, 700, 300, 720) });
doc.Save("contract-redacted.pdf");

Methods

ApplyRedactions(PdfDocument, RedactionOptions?)

Applies all Redact annotations of the document and removes them. The /OverlayText of an annotation takes precedence over OverlayText; all other settings come from options.

public static RedactionResult ApplyRedactions(PdfDocument document, RedactionOptions? options = null)

Parameters

document PdfDocument
options RedactionOptions

Returns

RedactionResult

MarkForRedaction(PdfPage, PdfRectangle, string?)

Marks an area for redaction with a Redact annotation (reviewable before ApplyRedactions(PdfDocument, RedactionOptions?)).

public static PdfAnnotation MarkForRedaction(PdfPage page, PdfRectangle area, string? overlayText = null)

Parameters

page PdfPage
area PdfRectangle
overlayText string

Returns

PdfAnnotation

Redact(PdfPage, IEnumerable<PdfRectangle>, RedactionOptions?)

Redacts areas (in default user space, i.e. page coordinates) of a page.

public static RedactionResult Redact(PdfPage page, IEnumerable<PdfRectangle> areas, RedactionOptions? options = null)

Parameters

page PdfPage
areas IEnumerable<PdfRectangle>
options RedactionOptions

Returns

RedactionResult

RedactText(PdfDocument, string, StringComparison, RedactionOptions?)

Redacts every occurrence of text in the document.

public static RedactionResult RedactText(PdfDocument document, string text, StringComparison comparison = StringComparison.Ordinal, RedactionOptions? options = null)

Parameters

document PdfDocument
text string
comparison StringComparison
options RedactionOptions

Returns

RedactionResult

RedactText(PdfDocument, Regex, RedactionOptions?)

Redacts every match of pattern (matched per text line).

public static RedactionResult RedactText(PdfDocument document, Regex pattern, RedactionOptions? options = null)

Parameters

document PdfDocument
pattern Regex
options RedactionOptions

Returns

RedactionResult