Class PdfRedactor
- Namespace
- SoftZenPdf.Redact
- Assembly
- SoftZenPdf.Redact.dll
Redacts content from an existing PDF. Mark what to remove, by text pattern or by area, then save: everything drawn inside the marked areas is removed from the page content itself, not just covered.
public sealed class PdfRedactor
- Inheritance
-
PdfRedactor
- Inherited Members
Properties
- Areas
The areas marked for redaction so far, in the order they were added.
- FillColor
The colour of the box drawn over each redacted area, like a black bar on paper. Defaults to black; null draws no box, leaving the area blank.
- PageCount
The number of pages.
- ScrubDocumentText
Whether the text patterns given to RedactText(Regex, double) are also removed from text outside the pages: document metadata and XMP, bookmarks, annotation notes, form field values and the structure tree's alternate text. Defaults to true.
Methods
- Find(string, RegexOptions)
Finds text matching a regular expression on every page, without marking it.
- Find(Regex)
Finds text matching a regular expression on every page, without marking it.
- FromBytes(byte[], string?)
Opens a PDF held in memory for redaction.
- FromStream(Stream, string?)
Opens a PDF from a stream for redaction. The stream is read from its current position to the end and left open.
- GetPageText(int)
The text of a page as Find(Regex) searches it: in reading order, lines separated by line feeds, words by spaces. Invisible text, such as an OCR layer over a scan, is included.
- Open(string, string?)
Opens a PDF for redaction.
- RedactArea(RedactionArea)
Marks an area for redaction: everything drawn inside it is removed.
- RedactArea(int, double, double, double, double)
Marks an area for redaction: everything drawn inside it is removed.
- RedactText(string, RegexOptions, double)
Marks every match of a regular expression for redaction.
- RedactText(Regex, double)
Marks every match of a regular expression for redaction.
- Save(Stream)
Applies the redactions and writes the result to a stream. The output is a new file, not an update of the original: earlier revisions, unused objects and encryption are not carried over, so removed content cannot be recovered from it.
- Save(string)
Applies the redactions and saves the result to a file.
- ToArray()
Applies the redactions and returns the redacted PDF as a byte array.