PdfRedactor Class

Removes text, images and graphics from areas of the pages of a PDF document. The content of an area is removed from the document, not only covered: text found in an area can no longer be selected, copied or extracted and the pixels of images inside the area are replaced. Areas are given as rectangles or whole pages, found by searching the text or the personal data of the document, or read from the redaction annotations of the document. Each area can be covered with a color, an image and an overlay text. The metadata and the hidden content of the document can be removed too

Definition

Namespace: EvoPdf.Next
Assembly: EvoPdf.Next (in EvoPdf.Next.dll) Version: 15.0.0
C#
public class PdfRedactor : IDisposable
Inheritance
Object    PdfRedactor
Implements
IDisposable

Constructors

PdfRedactor(Byte, String) Loads the PDF document to redact from a memory buffer
PdfRedactor(String, String) Loads the PDF document to redact from a file

Properties

FillColor The color that covers the redacted areas. The default is black; null leaves the areas empty
OverlayFontSize The font size of the overlay text in points. The default 0 fits the text in each area
OverlayText The text written over each redacted area, for example "REDACTED". The default is no text
OverlayTextColor The color of the overlay text. The default is white
OverlayTextLanguage The language of the overlay text, as a language tag like en-US, written in accessible documents. When not set, the language of the document is used
PageCount The number of pages of the loaded document
PdfDocumentInfo Gets a reference to the object controlling the information of the redacted document, like the document title, author, subject or creation date. The values of the loaded document are used by default
PdfSecurityOptions Gets a reference to the object controlling the security settings of the redacted document, like user and owner password, restrict printing or editing
PdfViewerPreferences Gets a reference to the object controlling how the redacted document is displayed by a PDF viewer. The values of the loaded document are used by default
Redactions The areas marked for redaction
RemoveEmbeddedFiles Removes the files attached to the document and the file attachment annotations. The default is false
RemoveHiddenContent Removes from all the pages the content a viewer does not show: invisible text such as the searchable text of scanned pages, text outside the visible area, layers turned off and hidden annotations and form fields. The default is false
RemoveIntersectingAnnotations Removes the annotations, links and form fields that intersect a redacted area. The default is true
RemoveJavaScript Removes the document level scripts and the scripts run when the document is opened. The default is false
RemoveMetadata Removes the metadata of the document, pages, images and fonts, the page thumbnails and the document information. The title, author, subject, keywords and creator set after loading the document are still written, as well as the title of PDF/UA documents and the identification of the PDF/A and PDF/UA standards. The default is false
RepeatOverlayText Repeats the overlay text to fill each area. The default is false
Result What the redaction removed, available after the document is saved, null before

Methods

AddRedaction(PdfRedactionArea) Marks an area for redaction
AddRedaction(PdfTextMatch) Marks the areas of a text found in the document for redaction
AddRedaction(Int32, PdfRectangleF) Marks an area of a page for redaction
AddRedactionAnnotations Marks for redaction the areas of the redaction annotations of the document, with the fill color and the overlay text set in each annotation. The annotations are removed from the saved document
Dispose Releases all resources used by this instance
Dispose(Boolean) Performs the actual resource cleanup
Equals
(Inherited from Object)
Finalize
(Inherited from Object)
FindPersonalData Finds personal data recognized by its format in the text of the document, like email addresses, phone numbers, bank account and payment card numbers. Review the results before marking them for redaction
FindText(Regex) Finds the texts that match a regular expression in all the pages of the document. The text of a page is read in reading order, with one space between words and one line break between lines
FindText(String, Boolean, Boolean) Finds a text in all the pages of the document. The white space of the searched text matches any white space, including a line break
GetHashCode
(Inherited from Object)
GetPdfPageInfo Gets the size, rotation and boxes of a page of the loaded document
GetType
(Inherited from Object)
MemberwiseClone
(Inherited from Object)
RedactPage Marks a whole page for redaction. All the content of the page is removed, including the content outside the visible area of the page
RedactPages Marks a range of pages for redaction, as RedactPage(Int32) does for each page
RedactPersonalData Marks for redaction the personal data found by FindPersonalData(PdfPersonalDataTypes). The same texts are replaced with OverlayText, or with the word Redacted when it is not set, in the document information, metadata, bookmarks, annotation and form field values and alternate descriptions
RedactText(Regex) Marks for redaction every text of the document that matches a regular expression. The same texts are replaced with OverlayText, or with the word Redacted when it is not set, in the document information, metadata, bookmarks, annotation and form field values and alternate descriptions
RedactText(String, Boolean, Boolean) Marks for redaction every occurrence of a text in the document. The same texts are replaced with OverlayText, or with the word Redacted when it is not set, in the document information, metadata, bookmarks, annotation and form field values and alternate descriptions
Save Applies the redactions and returns the redacted PDF document. The redactor cannot be used after the document is saved
SaveAsync Asynchronously applies the redactions and returns the redacted PDF document
SaveRedactionMarks Saves the document with the marked areas as redaction annotations, without removing any content. The marks can be reviewed and changed in a PDF viewer, then applied with AddRedactionAnnotations. The redactor cannot be used after the document is saved
SaveRedactionMarksToFile Saves the document with the marked areas as redaction annotations to a file, without removing any content, as SaveRedactionMarks does
SaveToFile Applies the redactions and saves the redacted PDF document to a file
SaveToFileAsync Asynchronously applies the redactions and saves the redacted PDF document to a file
SetOverlayImage(Byte, Boolean) Sets an image drawn over each redacted area, after the fill color and under the overlay text. The image format is determined from the data. The supported formats are Jpeg, Png and Webp
SetOverlayImage(String, Boolean) Sets an image drawn over each redacted area from an image file. The supported formats are Jpeg, Png and Webp
ToString
(Inherited from Object)

See Also