public class ExactPhraseRedaction extends TextRedaction
Represents a text redaction that replaces exact phrase in the document's text, case insensitive by default.
Learn more
The following example demonstrates performing case-sensitive phrase search and replacement.
try (Redactor redactor = new Redactor("C:\\sample.pdf"))
{
// By default, the second parameter, isCaseSensitive = false;
doc.apply(new ExactPhraseRedaction("John Doe", true, new ReplacementOptions("[personal]")));
doc.save();
}
The following example demonstrates replacing phrase (case insensitive) with solid red rectangle.
try (Redactor redactor = new Redactor("C:\\sample.pdf"))
{
// By default, isCaseSensitive = false;
doc.apply(new ExactPhraseRedaction("John Doe", new ReplacementOptions(System.Drawing.Color.Red)));
doc.save();
}
Constructor and Description |
---|
ExactPhraseRedaction(String searchPhrase,
boolean isCaseSensitive,
ReplacementOptions options)
Initializes a new instance of ExactPhraseRedaction class.
|
ExactPhraseRedaction(String searchPhrase,
ReplacementOptions options)
Initializes a new instance of ExactPhraseRedaction class in case insensitive mode.
|
Modifier and Type | Method and Description |
---|---|
RedactorLogEntry |
applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
|
String |
getDescription()
Returns a string, describing the redaction and its parameters.
|
String |
getSearchPhrase()
Gets the string to search and replace.
|
boolean |
isCaseSensitive()
Gets a value indicating whether the search is case-sensitive or not.
|
getActionOptions, getOcrConnector, processAsTextual, setOcrConnector
public ExactPhraseRedaction(String searchPhrase, ReplacementOptions options)
Initializes a new instance of ExactPhraseRedaction class in case insensitive mode.
searchPhrase
- String to search and replaceoptions
- Replacement options (textual, color)public ExactPhraseRedaction(String searchPhrase, boolean isCaseSensitive, ReplacementOptions options)
Initializes a new instance of ExactPhraseRedaction class.
searchPhrase
- String to search and replaceisCaseSensitive
- True if case sensitive search is requiredoptions
- Replacement options (textual, color)public final String getSearchPhrase()
Gets the string to search and replace.
public final boolean isCaseSensitive()
Gets a value indicating whether the search is case-sensitive or not.
public String getDescription()
Returns a string, describing the redaction and its parameters.
getDescription
in class Redaction
public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.