In This Topic
                                    
                                
                                Returns if the currently selected page of the loaded PDF contains text, regardless if visible or hidden. It is the same as what the PageHasText(false) method does. Please note that special characters like \r, \n, \l are always considered as text. 
This method uses an internal algorithm which is faster than the full page text extraction.
Syntax
            
            
            
            
            'Declaration
 
Public Overloads Function PageHasText() As Boolean
             
        
            
            public bool PageHasText()
             
        
            
            public function PageHasText(): Boolean; 
             
        
            
            public function PageHasText() : boolean;
             
        
            
            public: bool PageHasText(); 
             
        
            
            public:
bool PageHasText(); 
             
        
             
        
            
            
            Return Value
true if the currently selected page contains text, both visible and hidden, otherwise false. The 
GetStat method can be subsequently used to determine if this method has been successful.
 
            
            
            
            
            
            Example
How to find out if the current page in the PDF document contains text. The example shows you how to check all pages in the PDF document if they contain text or not (no matter if visible text or hidden).
            
            
            
             
    
	
		Dim caption As String = "Example: PageHasText"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim result As Boolean = False
        Dim pagesWithText As Integer = 0, pagesWithoutText As Integer = 0
        For i As Integer = 1 To pageCount
            status = gdpicturePDF.SelectPage(i)
            If status = GdPictureStatus.OK Then
                result = gdpicturePDF.PageHasText()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    If result Then
                        pagesWithText += 1
                        MessageBox.Show("The page nr." + i.ToString() + " HAS text.", caption)
                    Else
                        pagesWithoutText += 1
                        MessageBox.Show("The page nr." + i.ToString() + " HAS NO text.", caption)
                    End If
                Else
                    MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption)
                End If
            Else
                MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
            End If
        Next
        If (pagesWithText + pagesWithoutText) <> pageCount Then
            MessageBox.Show("Something goes wrong: " + ((pagesWithText + pagesWithoutText).ToString() + "!=" + pageCount.ToString()), caption)
        Else
            MessageBox.Show("Finished successfully.", caption)
        End If
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
	 
	
		string caption = "Example: PageHasText";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    int pageCount = gdpicturePDF.GetPageCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        bool result = false;
        int pagesWithText = 0, pagesWithoutText = 0;
        for (int i = 1; i <= pageCount; i++)
        {
            status = gdpicturePDF.SelectPage(i);
            if (status == GdPictureStatus.OK)
            {
                result = gdpicturePDF.PageHasText();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    if (result)
                    {
                        pagesWithText++;
                        MessageBox.Show("The page nr." + i.ToString() + " HAS text.", caption);
                    }
                    else
                    {
                        pagesWithoutText++;
                        MessageBox.Show("The page nr." + i.ToString() + " HAS NO text.", caption);
                    }
                }
                else
                {
                    MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption);
                }
            }
            else
            {
                MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
            }
        }
        if ((pagesWithText + pagesWithoutText) != pageCount)
        {
            MessageBox.Show("Something goes wrong: " + ((pagesWithText + pagesWithoutText).ToString() + "!=" + pageCount.ToString()), caption);
        }
        else
        {
            MessageBox.Show("Finished successfully.", caption);
        }
    }
    else
    {
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
	 
	
 
Example
How to find out if the current page in the PDF document contains text. The example shows you how to check all pages in the PDF document if they contain text or not (no matter if visible text or hidden).
            
            Dim caption As String = "Example: PageHasText"
            Dim gdpicturePDF As New GdPicturePDF()
            Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
            If status = GdPictureStatus.OK Then
                Dim pageCount As Integer = gdpicturePDF.GetPageCount()
                If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                    Dim result As Boolean = False
                    Dim pagesWithText As Integer = 0, pagesWithoutText As Integer = 0
                    For i As Integer = 1 To pageCount
                        status = gdpicturePDF.SelectPage(i)
                        If status = GdPictureStatus.OK Then
                            result = gdpicturePDF.PageHasText()
                            status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then
                                If result Then
                                    pagesWithText += 1
                                    MessageBox.Show("The page nr." + i.ToString() + " HAS text.", caption)
                                Else
                                    pagesWithoutText += 1
                                    MessageBox.Show("The page nr." + i.ToString() + " HAS NO text.", caption)
                                End If
                            Else
                                MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption)
                            End If
                        Else
                            MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
                        End If
                    Next
                    If (pagesWithText + pagesWithoutText) <> pageCount Then
                        MessageBox.Show("Something goes wrong: " + ((pagesWithText + pagesWithoutText).ToString() + "!=" + pageCount.ToString()), caption)
                    Else
                        MessageBox.Show("Finished successfully.", caption)
                    End If
                Else
                    MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
                End If
            Else
                MessageBox.Show("The file can't be loaded.", caption)
            End If
            gdpicturePDF.Dispose()
            
            string caption = "Example: PageHasText";
            GdPicturePDF gdpicturePDF = new GdPicturePDF();
            GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
            if (status == GdPictureStatus.OK)
            {
                int pageCount = gdpicturePDF.GetPageCount();
                if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                {
                    bool result = false;
                    int pagesWithText = 0, pagesWithoutText = 0;
                    for (int i = 1; i <= pageCount; i++)
                    {
                        status = gdpicturePDF.SelectPage(i);
                        if (status == GdPictureStatus.OK)
                        {
                            result = gdpicturePDF.PageHasText();
                            status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK)
                            {
                                if (result)
                                {
                                    pagesWithText++;
                                    MessageBox.Show("The page nr." + i.ToString() + " HAS text.", caption);
                                }
                                else
                                {
                                    pagesWithoutText++;
                                    MessageBox.Show("The page nr." + i.ToString() + " HAS NO text.", caption);
                                }
                            }
                            else
                            {
                                MessageBox.Show("The PageHasText() method has failed with the status: " + status.ToString(), caption);
                            }
                        }
                        else
                        {
                            MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
                        }
                    }
                    if ((pagesWithText + pagesWithoutText) != pageCount)
                    {
                        MessageBox.Show("Something goes wrong: " + ((pagesWithText + pagesWithoutText).ToString() + "!=" + pageCount.ToString()), caption);
                    }
                    else
                    {
                        MessageBox.Show("Finished successfully.", caption);
                    }
                }
                else
                {
                    MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
                }
            }
            else
            {
                MessageBox.Show("The file can't be loaded.", caption);
            }
            gdpicturePDF.Dispose();
            
            
            
            See Also