GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / GetPageText Method / GetPageText() Method
Example





In This Topic
GetPageText() Method
In This Topic
Returns the whole text of the current page of the text-based document displayed in the GdViewer control. 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 GetPageText() As String
public string GetPageText()
public function GetPageText(): String; 
public function GetPageText() : String;
public: string* GetPageText(); 
public:
String^ GetPageText(); 

Return Value

The whole text of the currently displayed 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 get the text of the current page of the displayed document.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim page_text As String = GdViewer1.GetPageText()
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If String.IsNullOrEmpty(page_text) Then
            MessageBox.Show("The current page does not contain text.", "GdViewer.GetPageText")
        Else
            'Do your stuff with the page_text.
        End If
    Else
        MessageBox.Show("The GetPageText() method has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageText")
    End If
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageText")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string page_text = GdViewer1.GetPageText();
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (String.IsNullOrEmpty(page_text))
            MessageBox.Show("The current page does not contain text.", "GdViewer.GetPageText");
        //else
            //Do your stuff with the page_text.
    }
    else
        MessageBox.Show("The GetPageText() method has failed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageText");
}
else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageText");
See Also