PdfText Class
Represents a snapshot mapping from a sequence of Unicode characters to a sequence of complete, partial or none PdfContentElements and provides various text related functionalities.
- Inheritance:
- System.ObjectPdfText
Remarks
The PdfText is a snapshot and if the underlying PDF content is changed, that change won't be visible in the PdfText, instead PdfText should be retrieved again to get the actual snapshot.
Properties
Bounds
Gets the bounds of the PdfText.
Property Value
Format
Gets the formatting properties applied to the PdfText.
Property Value
The formatting properties applied to the PdfText.
Remarks
Setting the properties of the returned PdfContentFormat is currently not supported.
Length
Gets the number of Unicode characters in the current PdfText object.
Property Value
- System.Int32
The number of Unicode characters in the current PdfText object.
Methods
Find(String, StringComparison)
Finds all occurrences of the specified text in this PdfText instance.
public IEnumerable<PdfText> Find(string text, StringComparison comparisonType = StringComparison.InvariantCulture)
Public Function Find(text As String, comparisonType As StringComparison = StringComparison.InvariantCulture) As IEnumerable(Of PdfText)
Parameters
text
- System.String
The searched text.
comparisonType
- System.StringComparison
One of the enumeration values that specifies the rules for the search.
Returns
- System.Collections.Generic.IEnumerable<PdfText>
All occurrences of the specified text in this PdfText instance.
Exceptions
- System.ArgumentNullException
text
is null.
Find(Regex)
Finds all matches of the specified regular expression in this PdfText instance.
public IEnumerable<PdfText> Find(Regex regex)
Public Function Find(regex As Regex) As IEnumerable(Of PdfText)
Parameters
regex
- System.Text.RegularExpressions.Regex
The regular expression used to find the matches.
Returns
- System.Collections.Generic.IEnumerable<PdfText>
All matches of the specified regular expression in this PdfText instance.
Exceptions
- System.ArgumentNullException
regex
is null.
Highlight()
Highlights the PDF content associated with the current PdfText.
Returns
The PdfContentFormat used to customize the highlight.
Redact()
Removes the PDF content associated with the current PdfText.
Subtext(Int32)
Retrieves a subtext from this instance. The subtext starts at a specified character position and continues to the end of the text.
public PdfText Subtext(int startIndex)
Public Function Subtext(startIndex As Integer) As PdfText
Parameters
startIndex
- System.Int32
The zero-based starting character position of a subtext in this instance.
Returns
Exceptions
- System.ArgumentOutOfRangeException
startIndex
is less than zero or greater than the length of this instance.
Subtext(Int32, Int32)
Retrieves a subtext from this instance. The subtext starts at a specified character position and has a specified length.
public PdfText Subtext(int startIndex, int length)
Public Function Subtext(startIndex As Integer, length As Integer) As PdfText
Parameters
startIndex
- System.Int32
The zero-based starting character position of a subtext in this instance.
length
- System.Int32
The number of characters in the subtext.
Returns
A PdfText that is equivalent to the subtext of length length
that begins at startIndex
in this instance.
Exceptions
- System.ArgumentOutOfRangeException
startIndex
plus length
indicates a position not within this instance or startIndex
or length
is less than zero.
ToString()
Returns a Unicode text contained in this PdfText.
Returns
- System.String
A Unicode text contained in this PdfText.