foxit.pdf.TextPage Class Reference
Inheritance diagram for foxit.pdf.TextPage:
foxit.common.Base

Public Types

enum  TextParseFlags { TextParseFlags.e_ParseTextNormal = 0x0000, TextParseFlags.e_ParseTextOutputHyphen = 0x0001, TextParseFlags.e_ParseTextUseStreamOrder = 0x0002 }
 Enumeration for parsing flags used for text page.
More...
 

Public Member Functions

 TextPage (PDFPage page, int flags)
 Constructor, from a parsed PDF page.
More...
 
 TextPage (TextPage other)
 Constructor, with another TextPage object.

 
Rotation GetBaselineRotation (int rect_index)
 Get the text trend (as rotation) of a specified rectangle.
More...
 
int GetCharCount ()
 Get the count of all the characters.
More...
 
string GetChars (int start, int count)
 Get all the characters within a range specified by a start index and count.
More...
 
int GetIndexAtPos (float x, float y, float tolerance)
 Get the character index at or around a specified position on the page, in PDF coordinate system .
More...
 
string GetTextInRect (RectF rect)
 Get the text within a rectangle, in PDF coordinate system .
More...
 
RectF GetTextRect (int rect_index)
 Get the text rectangle by the index.
More...
 
int GetTextRectCount (int start, int count)
 Count the text rectangles within a range specified by a start index and count.
More...
 
Range GetWordAtPos (float x, float y, float tolerance)
 Get the character range of a word at or around a specified position on the page, in PDF coordinate system .
More...
 
bool IsEmpty ()
 Check whether current object is empty or not.
More...
 

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 TextPage object.
To access text that are used as a hypertext link, please construct a PageTextLinks object with TextPage object.

See also
TextSearch
PageTextLinks

Member Enumeration Documentation

◆ TextParseFlags

Enumeration for parsing flags used for text page.

Values of this enumeration can be used alone or in combination.

Enumerator
e_ParseTextNormal 

No special parsing options for text page.

e_ParseTextOutputHyphen 

Parse the text content of a PDF page with outputting the hyphen on a line feed.

e_ParseTextUseStreamOrder 

Parse the text content of a PDF page by the stream order.

Constructor & Destructor Documentation

◆ TextPage()

foxit.pdf.TextPage.TextPage ( PDFPage  page,
int  flags 
)
inline

Constructor, from a parsed PDF page.

Parameters
pageA valid PDF page object. This page should has been parsed.
flagsParsing flags for the text page. Please refer to e_ParseTextXXX values and this can be one or combination of these values.

Member Function Documentation

◆ GetBaselineRotation()

Rotation foxit.pdf.TextPage.GetBaselineRotation ( int  rect_index)
inline

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

Parameters
rect_indexThe 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 e_RotationXXX values and this would be one of these values.

◆ GetCharCount()

int foxit.pdf.TextPage.GetCharCount ( )
inline

Get the count of all the characters.

Returns
Count of characters.

◆ GetChars()

string foxit.pdf.TextPage.GetChars ( int  start,
int  count 
)
inline

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

Parameters
startIndex 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.
countCount 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.


Returns
The characters within the specified character index range.

◆ GetIndexAtPos()

int foxit.pdf.TextPage.GetIndexAtPos ( float  x,
float  y,
float  tolerance 
)
inline

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

Parameters
xValue of x position, in PDF coordinate system .
yValue of y position, in PDF coordinate system .
toleranceTolerance 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.

◆ GetTextInRect()

string foxit.pdf.TextPage.GetTextInRect ( RectF  rect)
inline

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

Parameters
rectA rectangle region, in PDF coordinate system .
Returns
Text string within the specified rectangle.

◆ GetTextRect()

RectF foxit.pdf.TextPage.GetTextRect ( int  rect_index)
inline

Get the text rectangle by the index.

Parameters
rect_indexThe 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.

◆ GetTextRectCount()

int foxit.pdf.TextPage.GetTextRectCount ( int  start,
int  count 
)
inline

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

Parameters
startIndex of start character in the character index range. Valid range: from 0 to (charcount -1). charcount is returned by function TextPage::GetCharCount.
countCount 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.

◆ GetWordAtPos()

Range foxit.pdf.TextPage.GetWordAtPos ( float  x,
float  y,
float  tolerance 
)
inline

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
xValue of x position, in PDF coordinate system .
yValue of y position, in PDF coordinate system .
toleranceTolerance 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()

bool foxit.pdf.TextPage.IsEmpty ( )
inline

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.

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.