GetPageTextArea(Int32,Double,Double,Double,Double) Method
Returns the whole text, that is contained within a specific area of the given page of the text-based document displayed in the GdViewer control. You have to set the required page area as a rectangle defined by its top left coordinates and by its width and height in inches.
If the format of the displayed document is other than supported text-based formats, which currently are DOCX, TXT, RTF and PDF, this method returns an empty string.
public string GetPageTextArea(
int ,
double ,
double ,
double ,
double
)
public function GetPageTextArea(
: Integer;
: Double;
: Double;
: Double;
: Double
): String;
public function GetPageTextArea(
: int,
: double,
: double,
: double,
: double
) : String;
public: string* GetPageTextArea(
int ,
double ,
double ,
double ,
double
)
public:
String^ GetPageTextArea(
int ,
double ,
double ,
double ,
double
)
'Declaration
Public Overloads Function GetPageTextArea( _
ByVal As Integer, _
ByVal As Double, _
ByVal As Double, _
ByVal As Double, _
ByVal As Double _
) As String
Parameters
- Page
- The number of the page to search for text. It must be a value from 1 to the value of the PageCount property.
- Left
- The horizontal (X) coordinate of the top left point of the required rectangle, in inches.
- Top
- The vertical (Y) coordinate of the top left point of the required rectangle, in inches.
- Width
- The width of the required rectangle, in inches.
- Height
- The height of the required rectangle, in inches.
Return Value
The text found within the defined area of the given page as a string, if the format of the displayed document is text-based. Otherwise, it returns an empty string. The
GetStat method can be subsequently used to determine if this method has been successful.
How to find a given text within a specified page area of the displayed document.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim pattern As String = "your patern text"
For i As Integer = 1 To GdViewer1.PageCount - 1
Dim page_text As String = GdViewer1.GetPageTextArea(i, 10, 10, 50, 50)
If (GdViewer1.GetStat() = GdPictureStatus.OK) AndAlso page_text.Equals(pattern) Then
GdViewer1.DisplayPage(i)
Exit For
End If
Next
Else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageTextArea")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
string pattern = "your patern text";
for (int i = 1; i < GdViewer1.PageCount; i++)
{
string page_text = GdViewer1.GetPageTextArea(i, 10, 10, 50, 50);
if ((GdViewer1.GetStat() == GdPictureStatus.OK) && page_text.Equals(pattern))
{
GdViewer1.DisplayPage(i);
break;
}
}
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageTextArea");