Show / Hide Table of Contents

Class TextRange

The TextRange class represents a contiguous range of text on a PDF page. It may be the result of a text search, or simply a couple of highlighted or underlined words.

Each text range contains a few pieces of information:

page: the number of the page this piece of text is on; position: the start position (text offset); length: the length.

You are able to retrieve further information about the text range, such as its coordinates, the text itself, as well as characters before and after.

Inheritance
object
TextRange
Implements
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: pdftron.PDF
Assembly: PDFNet.dll
Syntax
public class TextRange : IDisposable

Constructors

TextRange()

Creates a default TextRange object

Declaration
public TextRange()

TextRange(TextRange)

Declaration
public TextRange(TextRange tr)
Parameters
Type Name Description
TextRange tr

Methods

Dispose()

Releases all resources used by the TextRange

Declaration
public override sealed void Dispose()

Dispose(bool)

Declaration
[HandleProcessCorruptedStateExceptions]
protected virtual void Dispose(bool A_0)
Parameters
Type Name Description
bool A_0

~TextRange()

Declaration
protected ~TextRange()

GetPageNumber()

Get the page number of the current highlight.

Declaration
public int GetPageNumber()
Returns
Type Description
int

the current page number

GetQuads()

Get the corresponding quadrangles of the current highlight.

Declaration
public double[] GetQuads()
Returns
Type Description
double[]

the output quadrangles. Each quadrangle has eight doubles (x1, y1), (x2, y2), (x3, y3), (x4, y4) denoting the four vertices in counter-clockwise order.

Remarks

since a highlight may correspond to multiple quadrangles, e.g., when it crosses a line, the number of resulting quadrangles may be larger than 1.

GetText()

Get the Unicode string content of the text range.

Declaration
public string GetText()
Returns
Type Description
string

the text within the range

GetTextAfter(int)

Get the Unicode string content immediately after the text range.

Declaration
public string GetTextAfter(int count)
Parameters
Type Name Description
int count

the number of characters to retrieve after the text range

Returns
Type Description
string

the text after the range

GetTextBefore(int)

Get the Unicode string content immediately before the text range.

Declaration
public string GetTextBefore(int count)
Parameters
Type Name Description
int count

the number of characters to retrieve before the text range

Returns
Type Description
string

the text before the range

Implements

IDisposable
In This Article
  • Constructors
    • TextRange()
    • TextRange(TextRange)
  • Methods
    • Dispose()
    • Dispose(bool)
    • ~TextRange()
    • GetPageNumber()
    • GetQuads()
    • GetText()
    • GetTextAfter(int)
    • GetTextBefore(int)
  • Implements
Back to top Generated by DocFX