Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
com.foxit.sdk.pdf.TextPage Class Reference
Inheritance diagram for com.foxit.sdk.pdf.TextPage:

## Public Member Functions
| TextPage (PDFPage page, int flags) throws com.foxit.sdk.PDFException
| Constructor, from a parsed PDF page. More...
| TextPage (TextPage other)
| Constructor, with another text page object. More...
synchronized void | delete ()
| Clean up related C++ resources immediately. More...
int | getBaselineRotation (int rect_index) throws com.foxit.sdk.PDFException
| Get the text trend (as rotation) of a specified rectangle. More...
int | getCharCount () throws com.foxit.sdk.PDFException
| Get the count of all the characters. More...
TextPageCharInfo | getCharInfo (int char_index) throws com.foxit.sdk.PDFException
| Get character information of a specific character. More...
Range | getCharRange (RectF rect) throws com.foxit.sdk.PDFException
| Get the character index range of all text rectangles within the specified rectangle region. More...
String | getChars (int start, int count) throws com.foxit.sdk.PDFException
| Get all the characters within a range specified by a start index and count. More...
int | getIndexAtPos (float x, float y, float tolerance) throws com.foxit.sdk.PDFException
| Get the character index at or around a specified position on the page, in PDF coordinate system. More...
String | getText (int flag) throws com.foxit.sdk.PDFException
| Get the page text. More...
String | getTextInRect (RectF rect) throws com.foxit.sdk.PDFException
| Get the text within a rectangle, in PDF coordinate system. More...
RectF | getTextRect (int rect_index) throws com.foxit.sdk.PDFException
| Get the text rectangle by the index. More...
RectFArray | getTextRectArrayByRect (RectF rect) throws com.foxit.sdk.PDFException
| Get the array of all text rectangles within the specified rectangle region. More...
int | getTextRectCount (int start, int count) throws com.foxit.sdk.PDFException
| Count the text rectangles within a range specified by a start index and count. More...
String | getTextUnderAnnot (Annot annot) throws com.foxit.sdk.PDFException
| Get the page text which intersect with a specified an annotation. More...
Range | getWordAtPos (float x, float y, float tolerance) throws com.foxit.sdk.PDFException
| Get the character range of a word at or around a specified position on the page, in PDF coordinate system. More...
boolean | isEmpty ()
| Check whether current object is empty or not. More...

## Static Public Attributes
static final int | e_ParseTextNormal = 0x0000
| Parse the text content of a PDF page by normalizing characters based on their positions in the PDF page.
static final int | e_ParseTextOutputHyphen = 0x0001
| Parse the text content of a PDF page with outputting the hyphen on a line feed.
static final int | e_ParseTextUseStreamOrder = 0x0002
| Parse the text content of a PDF page by the stream order.
static final int | e_TextDisplayOrder = 1
| If this is set, that means to get text content of a PDF page by the display order.
static final int | e_TextStreamOrder = 0
| If this is set, that means to get text content of a PDF page by the stream order.

## Detailed Description

PDF text page represents all the text contents in a PDF page, according to a specified parsing flag for these text. Class TextPage can be used to retrieve information about text in a PDF page, such as single character, single word, text content within specified character range or rectangle and so on.
This class object can also be used to construct objects of other text related classes in order to do more operation for text contents or access specified information from text contents:

- To search text in text contents of a PDF page, please construct a TextSearch object with text page object.
- To access text that are used as a hypertext link, please construct a PageTextLinks object with text page object.

See also
  TextSearch
  PageTextLinks

## Constructor & Destructor Documentation

## ◆ TextPage() [1/2]

com.foxit.sdk.pdf.TextPage.TextPage | ( | PDFPage | page,
|  | int | flags
| ) |  | throws com.foxit.sdk.PDFException

Constructor, from a parsed PDF page.

Parameters

  [in] | page | A valid PDF page object. This page should has been parsed.
  [in] | flags | Parsing flags for the text page. Please refer to values starting from com.foxit.sdk.pdf.TextPage.e_ParseTextNormal and this can be one or combination of these values.

## ◆ TextPage() [2/2]

com.foxit.sdk.pdf.TextPage.TextPage | ( | TextPage | other | ) |

Constructor, with another text page object.

Parameters

  [in] | other | Another text page object.

## Member Function Documentation

## ◆ delete()

synchronized void com.foxit.sdk.pdf.TextPage.delete | ( |  | ) |

Clean up related C++ resources immediately.

Returns
  None.

Note
  Once this function is called, current object cannot be used anymore.

Reimplemented from com.foxit.sdk.common.Base.

## ◆ getBaselineRotation()

int com.foxit.sdk.pdf.TextPage.getBaselineRotation | ( | int | rect_index | ) | throws com.foxit.sdk.PDFException

Get the text trend (as rotation) of a specified rectangle.

Parameters

  [in] | rect_index | The index of the rectangle to be retrieved. Valid range: from 0 to (count -1). count is returned by function TextPage.getTextRectCount .

Returns
  Text trend, as rotation value. Please refer to values starting from com.foxit.sdk.common.Constants.e_Rotation0 and this would be one of these values.

## ◆ getCharCount()

int com.foxit.sdk.pdf.TextPage.getCharCount | ( |  | ) | throws com.foxit.sdk.PDFException

Get the count of all the characters.

Returns
  Count of characters.

## ◆ getCharInfo()

TextPageCharInfo com.foxit.sdk.pdf.TextPage.getCharInfo | ( | int | char_index | ) | throws com.foxit.sdk.PDFException

Get character information of a specific character.

Parameters

  [in] | char_index | A zero-based index of character. Range: from 0 to (charcount - 1).charcount is returned by function TextPage.getCharCount .

Returns
  Character information for the character speicifed by character index.

## ◆ getCharRange()

Range com.foxit.sdk.pdf.TextPage.getCharRange | ( | RectF | rect | ) | throws com.foxit.sdk.PDFException

Get the character index range of all text rectangles within the specified rectangle region.

Parameters

  [in] | rect | A rectangle region, in PDF coordinate system.

Returns
  Character index range of all text rectangles within the specified rectangle region.

## ◆ getChars()

String com.foxit.sdk.pdf.TextPage.getChars | ( | int | start,
|  | int | count
| ) |  | throws com.foxit.sdk.PDFException

Get all the characters within a range specified by a start index and count.

Parameters

  [in] | start | Index of start character, which is the first character of the expected text content. Valid range: from 0 to (charcount -1). charcount is returned by function TextPage.getCharCount . Default value: 0.
  [in] | count | Count of characters to be retrieved. -1 means to get the whole characters from start_index to the end of PDF page. Especially, when parameter count is larger than (charcount - start), all the rest character (from start_index) will be retrieved. charcount is returned by function TextPage.getCharCount . Default value: -1.

Returns
  The characters within the specified character index range.

## ◆ getIndexAtPos()

int com.foxit.sdk.pdf.TextPage.getIndexAtPos | ( | float | x,
|  | float | y,
|  | float | tolerance
| ) |  | throws com.foxit.sdk.PDFException

Get the character index at or around a specified position on the page, in PDF coordinate system.

Parameters

  [in] | x | Value of x position, in PDF coordinate system.
  [in] | y | Value of y position, in PDF coordinate system.
  [in] | tolerance | Tolerance value for character hit detection, in point units. This should not be a negative.

Returns
  Index of the character, which is at or nearby point (x,y), starting from 0. Specially, if there are several characters near by point (x, y), the smallest character index will be returned. If there is no character at or nearby the point, -1 will be returned.

## ◆ getText()

String com.foxit.sdk.pdf.TextPage.getText | ( | int | flag | ) | throws com.foxit.sdk.PDFException

Get the page text.

Parameters

  [in] | flag | Text order flag to decide how to get text content of the related PDF page. Please refer to values starting from com.foxit.sdk.pdf.TextPage.e_TextStreamOrder and this should be one of these values.

Returns
  All the text content of the related PDF page, in specified text order.

## ◆ getTextInRect()

String com.foxit.sdk.pdf.TextPage.getTextInRect | ( | RectF | rect | ) | throws com.foxit.sdk.PDFException

Get the text within a rectangle, in PDF coordinate system.

Parameters

  [in] | rect | A rectangle region, in PDF coordinate system.

Returns
  Text string within the specified rectangle.

## ◆ getTextRect()

RectF com.foxit.sdk.pdf.TextPage.getTextRect | ( | int | rect_index | ) | throws com.foxit.sdk.PDFException

Get the text rectangle by the index.

Parameters

  [in] | rect_index | The index of the rectangle to be retrieved. Valid range: from 0 to (count -1). count is returned by function TextPage.getTextRectCount .

Returns
  A specified text rectangle.

## ◆ getTextRectArrayByRect()

RectFArray com.foxit.sdk.pdf.TextPage.getTextRectArrayByRect | ( | RectF | rect | ) | throws com.foxit.sdk.PDFException

Get the array of all text rectangles within the specified rectangle region.

Parameters

  [in] | rect | A rectangle region, in PDF coordinate system.

Returns
  Text rectangle array within the specified rectangle.

## ◆ getTextRectCount()

int com.foxit.sdk.pdf.TextPage.getTextRectCount | ( | int | start,
|  | int | count
| ) |  | throws com.foxit.sdk.PDFException

Count the text rectangles within a range specified by a start index and count.

Parameters

  [in] | start | Index of start character in the character index range. Valid range: from 0 to (charcount -1). charcount is returned by function TextPage.getCharCount .
  [in] | count | Count of characters in the character index range. -1 means to get the whole characters from start_index to the end of PDF page.

Returns
  The count of text rectangles in the specified character index range. -1 means error.

## ◆ getTextUnderAnnot()

String com.foxit.sdk.pdf.TextPage.getTextUnderAnnot | ( | Annot | annot | ) | throws com.foxit.sdk.PDFException

Get the page text which intersect with a specified an annotation.

If the whole character or most part of the character intersects with an annotation, this character will be retrieved by current function.

Parameters

  [in] | annot | An annotation. Page text which intersects with this annotation is to be retrieved. Currently, only support text markup annotation (highlight/underline/strike-out/squggly annotations); for annotation in other types, this function will throw exception com.foxit.sdk.common.Constants.e_ErrUnsupported .

Returns
  The text which intersects with the specified annotation.

## ◆ getWordAtPos()

Range com.foxit.sdk.pdf.TextPage.getWordAtPos | ( | float | x,
|  | float | y,
|  | float | tolerance
| ) |  | throws com.foxit.sdk.PDFException

Get the character range of a word at or around a specified position on the page, in PDF coordinate system.

Currently, for Chinese/Japanese/Korean, only support to get a single character at or around the specified position.

Parameters

  [in] | x | Value of x position, in PDF coordinate system.
  [in] | y | Value of y position, in PDF coordinate system.
  [in] | tolerance | Tolerance value for word hit detection, in point units.This should not be a negative.

Returns
  The character range that represents the expected word. There would be at most one valid range segment in this range object. If returned range object is empty, that means no such word is found.

## ◆ isEmpty()

boolean com.foxit.sdk.pdf.TextPage.isEmpty | ( |  | ) |

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
  true means current object is empty, while false means not.