ExactPhraseRedaction
Leave feedback
On this page
Inheritance: java.lang.Object, com.groupdocs.redaction.Redaction, com.groupdocs.redaction.redactions.TextRedaction
public class ExactPhraseRedaction extends TextRedaction
Represents a text redaction that replaces exact phrase in the document’s text, case insensitive by default.
Learn more
- More details about applying redactions: Redaction basics
- More details about document text redactions: Text redactions
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 | Description |
|---|---|
| ExactPhraseRedaction(String searchPhrase, ReplacementOptions options) | Initializes a new instance of ExactPhraseRedaction class in case insensitive mode. |
| ExactPhraseRedaction(String searchPhrase, boolean isCaseSensitive, ReplacementOptions options) | Initializes a new instance of ExactPhraseRedaction class. |
| Method | Description |
|---|---|
| getSearchPhrase() | Gets the string to search and replace. |
| isCaseSensitive() | Gets a value indicating whether the search is case-sensitive or not. |
| isRightToLeft() | Gets a value indicating if this text is right-to-Left or not, false by default. |
| setRightToLeft(boolean value) | Sets a value indicating if this text is right-to-Left or not, false by default. |
| getDescription() | Returns a string, describing the redaction and its parameters. |
| applyTo(DocumentFormatInstance formatInstance) | Applies the redaction to a given format instance. |
public ExactPhraseRedaction(String searchPhrase, ReplacementOptions options)
Initializes a new instance of ExactPhraseRedaction class in case insensitive mode.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| searchPhrase | java.lang.String | String to search and replace |
| options | ReplacementOptions | Replacement options (textual, color) |
public ExactPhraseRedaction(String searchPhrase, boolean isCaseSensitive, ReplacementOptions options)
Initializes a new instance of ExactPhraseRedaction class.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| searchPhrase | java.lang.String | String to search and replace |
| isCaseSensitive | boolean | True if case sensitive search is required |
| options | ReplacementOptions | Replacement options (textual, color) |
public final String getSearchPhrase()
Gets the string to search and replace.
Returns: java.lang.String - The string to search and replace.
public final boolean isCaseSensitive()
Gets a value indicating whether the search is case-sensitive or not.
Returns: boolean - A value indicating whether the search is case-sensitive or not.
public final boolean isRightToLeft()
Gets a value indicating if this text is right-to-Left or not, false by default.
Returns: boolean - A value indicating if this text is right-to-Left or not, false by default.
public final void setRightToLeft(boolean value)
Sets a value indicating if this text is right-to-Left or not, false by default.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| value | boolean | A value indicating if this text is right-to-Left or not, false by default. |
public String getDescription()
Returns a string, describing the redaction and its parameters.
Returns: java.lang.String - Text, containing redaction name and parameters.
public RedactorLogEntry applyTo(DocumentFormatInstance formatInstance)
Applies the redaction to a given format instance.
Parameters:
| Parameter | Type | Description |
|---|---|---|
| formatInstance | DocumentFormatInstance | An instance of a document to apply redaction |
Returns: RedactorLogEntry - Status of the redaction: success/failure and error message if any
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.