GetPageText(Int32) Method
In This Topic
Returns the whole text of the specified 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( _
ByVal As Integer _
) As String
public string GetPageText(
int
)
public function GetPageText(
: Integer
): String;
public function GetPageText(
: int
) : String;
public: string* GetPageText(
int
)
public:
String^ GetPageText(
int
)
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.
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.
Example
How to get the text of all pages of the displayed document.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim message As String = "These pages contain text:" + vbCrLf
For i As Integer = 1 To GdViewer1.PageCount
Dim page_text As String = GdViewer1.GetPageText(i)
If GdViewer1.GetStat() = GdPictureStatus.OK Then
If Not String.IsNullOrEmpty(page_text) Then
message = message + i.ToString() + ", "
'Do your stuff with the page_text.
End If
End If
Next
MessageBox.Show(message, "GdViewer.GetPageText")
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 message = "These pages contain text:\n";
for (int i = 1; i <= GdViewer1.PageCount; i++)
{
string page_text = GdViewer1.GetPageText(i);
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
if (!String.IsNullOrEmpty(page_text))
{
message = message + i.ToString() + ", ";
//Do your stuff with the page_text.
}
}
}
MessageBox.Show(message, "GdViewer.GetPageText");
}
else
MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageText");
See Also