Foxit PDF SDK
com.foxit.sdk.pdf.TextPage类 参考
类 com.foxit.sdk.pdf.TextPage 继承关系图:
com.foxit.sdk.common.Base

Public 成员函数

 TextPage (PDFPage page, int flags) throws com.foxit.sdk.PDFException
 从已解析的PDF页面构造函数。 更多...
 
 TextPage (TextPage other)
 用另一个文本页面对象的构造函数。 更多...
 
synchronized void delete ()
 直接清除C++相关资源。 更多...
 
int getBaselineRotation (int rect_index) throws com.foxit.sdk.PDFException
 获取指定矩形的文本趋势(作为旋转)。 更多...
 
int getCharCount () throws com.foxit.sdk.PDFException
 获取所有字符的数量。 更多...
 
TextPageCharInfo getCharInfo (int char_index) throws com.foxit.sdk.PDFException
 获取特定字符的字符信息。 更多...
 
Range getCharRange (RectF rect) throws com.foxit.sdk.PDFException
 获取指定矩形区域内所有文本矩形的字符索引范围。 更多...
 
String getChars (int start, int count) throws com.foxit.sdk.PDFException
 获取由起始索引和数量指定范围内的所有字符。 更多...
 
int getIndexAtPos (float x, float y, float tolerance) throws com.foxit.sdk.PDFException
 获取页面上指定位置处或附近的字符索引, 在中。 更多...
 
String getText (int flag) throws com.foxit.sdk.PDFException
 获取页面文本。 更多...
 
String getTextInRect (RectF rect) throws com.foxit.sdk.PDFException
 获取矩形内的文本,在中。 更多...
 
RectF getTextRect (int rect_index) throws com.foxit.sdk.PDFException
 通过索引获取文本矩形。 更多...
 
RectFArray getTextRectArrayByRect (RectF rect) throws com.foxit.sdk.PDFException
 获取指定矩形区域内所有文本矩形的数组。 更多...
 
int getTextRectCount (int start, int count) throws com.foxit.sdk.PDFException
 计算由起始索引和数量指定范围内的文本矩形。 更多...
 
String getTextUnderAnnot (Annot annot) throws com.foxit.sdk.PDFException
 获取与指定注释相交的页面文本。 更多...
 
Range getWordAtPos (float x, float y, float tolerance) throws com.foxit.sdk.PDFException
 获取页面上指定位置处或附近单词的字符范围, 在中。 更多...
 
boolean isEmpty ()
 检查当前对象是否为空。 更多...
 
- Public 成员函数 继承自 com.foxit.sdk.common.Base
synchronized void delete ()
 直接清除C++相关资源。 更多...
 

静态 Public 属性

static final int e_ParseTextNormal = 0x0000
 通过根据字符在PDF页面中的位置规范化字符来解析PDF页面的文本内容。
 
static final int e_ParseTextOutputHyphen = 0x0001
 在换行时输出连字符来解析PDF页面的文本内容。
 
static final int e_ParseTextUseStreamOrder = 0x0002
 按流顺序解析PDF页面的文本内容。
 
static final int e_TextDisplayOrder = 1
 如果设置,表示按显示顺序获取PDF页面的文本内容。
 
static final int e_TextStreamOrder = 0
 如果设置,表示按流顺序获取PDF页面的文本内容。
 

详细描述

PDF文本页面表示PDF页面中的所有文本内容,根据为这些文本指定的解析标志。 类 TextPage 可用于检索PDF页面中文本的信息,例如单个字符、单个单词、 指定字符范围或矩形内的文本内容等。
此类对象还可用于构造其他文本相关类的对象,以便对文本内容进行更多操作 或从文本内容访问指定信息:

  • 要在PDF页面的文本内容中搜索文本,请使用文本页面对象构造 TextSearch 对象。

  • 要访问用作超文本链接的文本,请使用文本页面对象构造 PageTextLinks 对象。

参见
TextSearch
PageTextLinks

构造及析构函数说明

◆ TextPage() [1/2]

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

从已解析的PDF页面构造函数。

参数
[in]page有效的PDF页面对象。此页面应已被解析。
[in]flags文本页面的解析标志。请参考从 com.foxit.sdk.pdf.TextPage.e_ParseTextNormal 开始的值,这可以是这些值中的一个或组合。

◆ TextPage() [2/2]

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

用另一个文本页面对象的构造函数。

参数
[in]other另一个文本页面对象。

成员函数说明

◆ delete()

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

直接清除C++相关资源。

返回
无。
注解
一旦这个接口被调用,这个对象将不能再被使用。

◆ getBaselineRotation()

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

获取指定矩形的文本趋势(作为旋转)。

参数
[in]rect_index要检索的矩形的索引。 有效范围:从0到(count -1)。count 由函数 TextPage.getTextRectCount 返回。
返回
文本趋势,作为旋转值。请参考从 com.foxit.sdk.common.Constants.e_Rotation0 开始的值, 这将是这些值中的一个。

◆ getCharCount()

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

获取所有字符的数量。

返回
字符数量。

◆ getCharInfo()

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

获取特定字符的字符信息。

参数
[in]char_index字符的从零开始的索引。 范围:从0到(charcount - 1)。charcount 由函数 TextPage.getCharCount 返回。
返回
由字符索引指定的字符的字符信息。

◆ getCharRange()

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

获取指定矩形区域内所有文本矩形的字符索引范围。

参数
[in]rect矩形区域,在中。
返回
指定矩形区域内所有文本矩形的字符索引范围。

◆ getChars()

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

获取由起始索引和数量指定范围内的所有字符。

参数
[in]start起始字符的索引,它是期望文本内容的第一个字符。 有效范围:从0到(charcount -1)。charcount 由函数 TextPage.getCharCount 返回。默认值:0。
[in]count要检索的字符数量。-1表示获取从start_index到PDF页面末尾的 所有字符。特别地,当参数count 大于(charcount - start),将检索所有剩余字符 (从start_index开始)。charcount 由函数 TextPage.getCharCount 返回。默认值:-1。
返回
指定字符索引范围内的字符。

◆ getIndexAtPos()

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

获取页面上指定位置处或附近的字符索引, 在中。

参数
[in]xx位置的值,在中。
[in]yy位置的值,在中。
[in]tolerance字符命中检测的容差值,以点为单位。这不应为负数。
返回
位于或接近点(x,y)的字符索引,从0开始。特别地,如果在点(x, y)附近 有多个字符,将返回最小的字符索引。 如果在该点处或附近没有字符,将返回-1。

◆ getText()

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

获取页面文本。

参数
[in]flag文本顺序标志,决定如何获取相关PDF页面的文本内容。请参考从 com.foxit.sdk.pdf.TextPage.e_TextStreamOrder 开始的值,这应该是这些值中的一个。
返回
相关PDF页面的所有文本内容,按指定的文本顺序。

◆ getTextInRect()

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

获取矩形内的文本,在中。

参数
[in]rect矩形区域,在中。
返回
指定矩形内的文本字符串。

◆ getTextRect()

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

通过索引获取文本矩形。

参数
[in]rect_index要检索的矩形的索引。 有效范围:从0到(count -1)。count 由函数 TextPage.getTextRectCount 返回。
返回
指定的文本矩形。

◆ getTextRectArrayByRect()

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

获取指定矩形区域内所有文本矩形的数组。

参数
[in]rect矩形区域,在中。
返回
指定矩形内的文本矩形数组。

◆ getTextRectCount()

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

计算由起始索引和数量指定范围内的文本矩形。

参数
[in]start字符索引范围中起始字符的索引。 有效范围:从0到(charcount -1)。charcount 由函数 TextPage.getCharCount 返回。
[in]count字符索引范围中的字符数量。-1表示获取从start_index到PDF页面末尾的 所有字符。
返回
指定字符索引范围内的文本矩形数量。-1表示错误。

◆ getTextUnderAnnot()

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

获取与指定注释相交的页面文本。

如果整个字符或字符的大部分与注释相交, 当前函数将检索此字符。

参数
[in]annot注释。要检索与此注释相交的页面文本。 目前,仅支持文本标记注释 (高亮/下划线/删除线/波浪线注释);对于其他类型的注释, 此函数将抛出异常 com.foxit.sdk.common.Constants.e_ErrUnsupported
返回
与指定注释相交的文本。

◆ getWordAtPos()

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

获取页面上指定位置处或附近单词的字符范围, 在中。

目前,对于中文/日文/韩文,仅支持获取指定位置处或附近的单个字符。

参数
[in]xx位置的值,在中。
[in]yy位置的值,在中。
[in]tolerance单词命中检测的容差值,以点为单位。这不应为负数。
返回
表示期望单词的字符范围。此范围对象中最多会有一个有效的范围段。 如果返回的范围对象为空,表示未找到此类单词。

◆ isEmpty()

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

检查当前对象是否为空。

当前对象为空时,意味着当前对象无用。

返回
true 表示当前对象为空,false 表示不为空。