MetadataSearchRedaction

MetadataSearchRedaction class

Represents a metadata redaction that searches and redacts metadata using regular expressions, matching keys and/or values.

public class MetadataSearchRedaction : MetadataRedaction

Constructors

Name Description
MetadataSearchRedaction(Regex, string) Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.
MetadataSearchRedaction(string, string) Initializes a new instance of MetadataSearchRedaction class, using value to match redacted items.
MetadataSearchRedaction(Regex, string, Regex) Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.
MetadataSearchRedaction(string, string, string) Initializes a new instance of MetadataSearchRedaction class, using item name and value to match redacted items.

Properties

Name Description
override Description { get; } Returns a string, describing the redaction and its parameters.
Filter { get; set; } Gets or sets the filter, which is used to select all or specific metadata, for example Author or Company.
KeyExpression { get; } Gets the regular expression to match name (key) of metadata item.
Replacement { get; } Gets the textual replacement value.
ValueExpression { get; } Gets the regular expression to match value text of a metadata item.

Methods

Name Description
override ApplyTo(DocumentFormatInstance) Applies the redaction to a given format instance.

Remarks

Learn more

Examples

The following example demonstrates how to search and redact certain text in specific metadata.

using (Redactor redactor = new Redactor(@"C:\sample.docx"))
{
   MetadataSearchRedaction redaction = new MetadataSearchRedaction("Company Ltd.", "--company--");
   // If not set, applies to all metadata items
   redaction.Filter = MetadataFilters.Company;
   redactor.Apply(redaction);
   redactor.Save();
}

See Also