Table of Contents

Method RemoveText

Namespace
BitMiracle.Docotic.Pdf
Assembly
BitMiracle.Docotic.Pdf.dll

RemoveText(string)

Removes all occurrences of the specified text from the PDF document.

public void RemoveText(string text)

Parameters

text string

The text to remove.

Remarks

Removing a text fragment does not affect the positions of the remaining text.

The text search follows the order of the text elements in the PDF content stream. This order may differ from the logical reading order of the document.

Neighboring text elements can be combined with or without whitespace when searching depending on their positions.

Text elements separated by a significant horizontal or vertical distance are combined with whitespace. For example, "a" on one line followed by "b" on the next line is searched as "a b".

Text on different pages is searched independently. For example, if one page ends with "hello" and the next page starts with "world", searching for "hello world" does not produce a match across the page boundary.

Exceptions

ArgumentNullException

text is null.

RemoveText(Regex)

Removes all text that matches the specified regular expression from the PDF document.

public void RemoveText(Regex regex)

Parameters

regex Regex

The regular expression used to find text to remove.

Remarks

Removing a text fragment does not affect the positions of the remaining text.

If the regular expression contains no capturing groups, the entire match is removed. If the regular expression contains one or more capturing groups, only the text captured by those groups is removed. If a capturing group occurs multiple times during a match, all of its captured occurrences are removed.

Use non-capturing groups (?:...) or the ExplicitCapture flag to prevent groups from being captured.

The text search follows the order of the text elements in the PDF content stream. This order may differ from the logical reading order of the document.

Neighboring text elements can be combined with or without whitespace when searching depending on their positions.

Text elements separated by a significant horizontal or vertical distance are combined with a line feed (\n). For example, "a" on one line followed by "b" on the next line is searched as "a\nb".

Text on different pages is searched independently. For example, if one page ends with "hello" and the next page starts with "world", searching for "hello world" does not produce a match across the page boundary.

Exceptions

ArgumentNullException

regex is null.