Package com.pspdfkit.datastructures
Class TextBlock
-
- All Implemented Interfaces:
-
java.lang.Comparable
public final class TextBlock implements Comparable<T>
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.
-
-
Field Summary
Fields Modifier and Type Field Description public final String
text
public final int
pageIndex
public final Range
range
public final List<RectF>
pageRects
public final Annotation
annotation
-
Method Summary
Modifier and Type Method Description static TextBlock
create(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex, @NonNull() Range range)
Creates a TextBlock from the given page. static TextBlock
create(@IntRange(from = 0) int pageIndex, @NonNull() Range range, @NonNull() List<RectF> pageRects, @NonNull() String text)
Creates a TextBlock from the given page. static TextBlock
create(@NonNull() PdfDocument document, @NonNull() Annotation annotation, @NonNull() Range range)
Creates TextBlock from textual annotation. static String
getTextForBlocks(@NonNull() PdfDocument document, @NonNull() List<TextBlock> textBlocks)
Returns page text for a list of text blocks. int
compareTo(@NonNull() TextBlock another)
String
toString()
-
-
Method Detail
-
create
static TextBlock create(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex, @NonNull() 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.
-
create
static TextBlock create(@IntRange(from = 0) int pageIndex, @NonNull() Range range, @NonNull() List<RectF> pageRects, @NonNull() 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.pageRects
- PDF rects represented by this text block.text
- The represented string on the document.
-
create
static TextBlock create(@NonNull() PdfDocument document, @NonNull() Annotation annotation, @NonNull() 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.
-
getTextForBlocks
@NonNull() static String getTextForBlocks(@NonNull() PdfDocument document, @NonNull() 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.
-
-
-
-