GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / GetPageTextArea Method / GetPageTextArea(Int32,Single,Single,Single,Single) Method
The number of the page to search for text. It must be a value from 1 to the value of the PageCount property.
The horizontal (X) coordinate of the top left point of the required rectangle, in inches.
The vertical (Y) coordinate of the top left point of the required rectangle, in inches.
The width of the required rectangle, in inches.
The height of the required rectangle, in inches.
Example





In This Topic
GetPageTextArea(Int32,Single,Single,Single,Single) Method
In This Topic
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.

Syntax
'Declaration
 
Public Overloads Function GetPageTextArea( _
   ByVal Page As Integer, _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Width As Single, _
   ByVal Height As Single _
) As String
public string GetPageTextArea( 
   int Page,
   float Left,
   float Top,
   float Width,
   float Height
)
public function GetPageTextArea( 
    Page: Integer;
    Left: Single;
    Top: Single;
    Width: Single;
    Height: Single
): String; 
public function GetPageTextArea( 
   Page : int,
   Left : float,
   Top : float,
   Width : float,
   Height : float
) : String;
public: string* GetPageTextArea( 
   int Page,
   float Left,
   float Top,
   float Width,
   float Height
) 
public:
String^ GetPageTextArea( 
   int Page,
   float Left,
   float Top,
   float Width,
   float Height
) 

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.
Remarks
This method is only useful for text-based document formats, like DOCX, TXT, RTF and PDF, otherwise it returns an empty string.
Example
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");
See Also