public final class

TextBlock

extends Object
implements Comparable<T>
java.lang.Object
   ↳ com.pspdfkit.datastructures.TextBlock

Class Overview

Represents a text located on a document page. This model contains the actual text the range (i.e. the start and end index of the text on the page), and a list of pageRects holding the PDF coordinates of the text.

Summary

Fields
public final Annotation annotation Annotation that contains the text.
public final int pageIndex Number of the page that this text block resides on.
public final List<RectF> pageRects PDF rects represented by this text block.
public final Range range Actual text range (i.e.
public final String text The represented string on the document.
Public Methods
int compareTo(TextBlock another)
static TextBlock create(PdfDocument document, Annotation annotation, Range range)
Creates TextBlock from textual annotation.
static TextBlock create(PdfDocument document, int pageIndex, Range range)
Creates a TextBlock from the given page.
static TextBlock create(int pageIndex, Range range, List<RectF> pageRects, String text)
Creates a TextBlock from the given page.
static String getTextForBlocks(PdfDocument document, List<TextBlock> textBlocks)
Returns page text for a list of text blocks.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.Comparable

Fields

public final Annotation annotation

Annotation that contains the text. Valid only when text block resides in annotation and not in page contents. Note that range represents coordinates of the text block in annotation contents (not in the page text).

public final int pageIndex

Number of the page that this text block resides on.

public final List<RectF> pageRects

PDF rects represented by this text block. This list has at least one item.

public final Range range

Actual text range (i.e. start and end character index) of the represented text. This range is on the page with pageIndex. When source of the text block is annotation, this range is relative to annotation contents.

public final String text

The represented string on the document.

Public Methods

public int compareTo (TextBlock another)

public static TextBlock create (PdfDocument document, Annotation annotation, Range range)

Creates TextBlock from textual annotation.

Parameters
document Document this text block resides on.
annotation Annotation this text block resides on.
range Range of the text block inside annotation (i.e. start and end character index).

public static TextBlock create (PdfDocument document, int pageIndex, Range range)

Creates a TextBlock from the given page.

Parameters
document Document this text block resides on.
pageIndex Page this text block resides on.
range Range of the text block on page (i.e. start and end character index).

public static TextBlock create (int pageIndex, Range range, List<RectF> pageRects, String text)

Creates a TextBlock from the given page.

Parameters
pageIndex Page this text block resides on.
range Range of the text block on page (i.e. start and end character index).
pageRects PDF rects represented by this text block.
text The represented string on the document.

public static String getTextForBlocks (PdfDocument document, List<TextBlock> textBlocks)

Returns page text for a list of text blocks. The text is created by sequentially concatenating text blocks with a single space used as a separator.

Parameters
document Document this text block resides on.
textBlocks List of text blocks to return text for.

public String toString ()