GuessPageTextRotation Method (GdPicturePDF)
 
            
                In This Topic
            
            Returns the prevailing text rotation in the clockwise direction, in degrees, based on all text presented on the currently selected page of the loaded PDF document. The returned value will always be a multiple of 90.
The resulting rotation value is measured considering all presented text on the page. Each single text rotation is recognised and the most represented (prevailing) value is returned.
Be aware that the text rotation is calculated relative to the page, that said the current page rotation is not considered here. You can use the GdPicturePDF.NormalizePage method to eliminate the potential page rotation before computing the text rotation.
 
            
            
            Syntax
            
            
            
            
            'Declaration
 
Public Function GuessPageTextRotation() As Integer
             
        
            
            public int GuessPageTextRotation()
             
        
            
            public function GuessPageTextRotation(): Integer; 
             
        
            
            public function GuessPageTextRotation() : int;
             
        
            
            public: int GuessPageTextRotation(); 
             
        
            
            public:
int GuessPageTextRotation(); 
             
        
             
        
            
            
            Return Value
The prevailing clockwise rotation of the text on the currently selected page in degrees. The returned value can only be 0, 90, 180 or 270. The 
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
 
            
            
            
            
            
            Example
How to rotate only those pages of your document, that contains some rotated text.
            
            
            
             
    
	
		Dim caption As String = "Example: GuessPageTextRotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim message As String = Nothing
        Dim page_text_rotation As Integer = 0
        For i As Integer = 1 To pageCount
            gdpicturePDF.SelectPage(i)
            message = message + "The page nr. " + i + ": "
            'Eliminating the possible page rotation.
            status = gdpicturePDF.NormalizePage()
            If status = GdPictureStatus.OK Then
                page_text_rotation = gdpicturePDF.GuessPageTextRotation()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    message = message + "text rotation: " + page_text_rotation.ToString()
                    If page_text_rotation > 0 Then
                        status = gdpicturePDF.RotatePage(page_text_rotation)
                        If status = GdPictureStatus.OK Then
                            message = message + " :page has been rotated" + vbCrLf
                        Else
                            message = message + " :page has NOT been rotated: " + status.ToString()
                            Exit For
                        End If
                    Else
                        message = message + " :page has not been rotated" + vbCrLf
                    End If
                End If
            Else
                message = message + status.ToString()
                Exit For
            End If
        Next
        If status = GdPictureStatus.OK Then
            status = gdpicturePDF.SaveToFile("test_rotated.pdf")
            If status = GdPictureStatus.OK Then
                message = message + vbCrLf + "The pages have been rotated successfully and the file has been saved."
            Else
                message = message + vbCrLf + "The pages have been rotated successfully but the file can't be saved."
            End If
        End If
        MessageBox.Show(message, caption)
    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: GuessPageTextRotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    int pageCount = gdpicturePDF.GetPageCount();
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        string message = null;
        int page_text_rotation = 0;
        for (int i = 1; i <= pageCount; i++)
        {
            gdpicturePDF.SelectPage(i);
            message = message + "The page nr. " + i + ": ";
            //Eliminating the possible page rotation.
            status = gdpicturePDF.NormalizePage();
            if (status == GdPictureStatus.OK)
            {
                page_text_rotation = gdpicturePDF.GuessPageTextRotation();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    message = message + "text rotation: " + page_text_rotation.ToString();
                    if (page_text_rotation > 0)
                    {
                        status = gdpicturePDF.RotatePage(page_text_rotation);
                        if (status == GdPictureStatus.OK)
                        {
                            message = message + " :page has been rotated\n";
                        }
                        else
                        {
                            message = message + " :page has NOT been rotated: " + status.ToString();
                            break;
                        }
                    }
                    else
                    {
                        message = message + " :page has not been rotated\n";
                    }
                }
            }
            else
            {
                message = message + status.ToString();
                break;
            }
        }
        if (status == GdPictureStatus.OK)
        {
            status = gdpicturePDF.SaveToFile("test_rotated.pdf");
            if (status == GdPictureStatus.OK)
                message = message + "\nThe pages have been rotated successfully and the file has been saved.";
            else
                message = message + "\nThe pages have been rotated successfully but the file can't be saved.";
        }
        MessageBox.Show(message, 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 rotate only those pages of your document, that contains some rotated text.
            
            Dim caption As String = "Example: GuessPageTextRotation"
            Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
            Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
            If status = GdPictureStatus.OK Then
                Dim pageCount As Integer = gdpicturePDF.GetPageCount()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    Dim message As String = Nothing
                    Dim page_text_rotation As Integer = 0
                    For i As Integer = 1 To pageCount
                        gdpicturePDF.SelectPage(i)
                        message = message + "The page nr. " + i + ": "
                        'Eliminating the possible page rotation.
                        status = gdpicturePDF.NormalizePage()
                        If status = GdPictureStatus.OK Then
                            page_text_rotation = gdpicturePDF.GuessPageTextRotation()
                            status = gdpicturePDF.GetStat()
                            If status = GdPictureStatus.OK Then
                                message = message + "text rotation: " + page_text_rotation.ToString()
                                If page_text_rotation > 0 Then
                                    status = gdpicturePDF.RotatePage(page_text_rotation)
                                    If status = GdPictureStatus.OK Then
                                        message = message + " :page has been rotated" + vbCrLf
                                    Else
                                        message = message + " :page has NOT been rotated: " + status.ToString()
                                        Exit For
                                    End If
                                Else
                                    message = message + " :page has not been rotated" + vbCrLf
                                End If
                            End If
                        Else
                            message = message + status.ToString()
                            Exit For
                        End If
                    Next
                    If status = GdPictureStatus.OK Then
                        status = gdpicturePDF.SaveToFile("test_rotated.pdf")
                        If status = GdPictureStatus.OK Then
                            message = message + vbCrLf + "The pages have been rotated successfully and the file has been saved."
                        Else
                            message = message + vbCrLf + "The pages have been rotated successfully but the file can't be saved."
                        End If
                    End If
                    MessageBox.Show(message, caption)
                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: GuessPageTextRotation";
            GdPicturePDF gdpicturePDF = new GdPicturePDF();
            GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
            if (status == GdPictureStatus.OK)
            {
                int pageCount = gdpicturePDF.GetPageCount();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    string message = null;
                    int page_text_rotation = 0;
                    for (int i = 1; i <= pageCount; i++)
                    {
                        gdpicturePDF.SelectPage(i);
                        message = message + "The page nr. " + i + ": ";
                        //Eliminating the possible page rotation.
                        status = gdpicturePDF.NormalizePage();
                        if (status == GdPictureStatus.OK)
                        {
                            page_text_rotation = gdpicturePDF.GuessPageTextRotation();
                            status = gdpicturePDF.GetStat();
                            if (status == GdPictureStatus.OK)
                            {
                                message = message + "text rotation: " + page_text_rotation.ToString();
                                if (page_text_rotation > 0)
                                {
                                    status = gdpicturePDF.RotatePage(page_text_rotation);
                                    if (status == GdPictureStatus.OK)
                                    {
                                        message = message + " :page has been rotated\n";
                                    }
                                    else
                                    {
                                        message = message + " :page has NOT been rotated: " + status.ToString();
                                        break;
                                    }
                                }
                                else
                                {
                                    message = message + " :page has not been rotated\n";
                                }
                            }
                        }
                        else
                        {
                            message = message + status.ToString();
                            break;
                        }
                    }
                    if (status == GdPictureStatus.OK)
                    {
                        status = gdpicturePDF.SaveToFile("test_rotated.pdf");
                        if (status == GdPictureStatus.OK)
                            message = message + "\nThe pages have been rotated successfully and the file has been saved.";
                        else
                            message = message + "\nThe pages have been rotated successfully but the file can't be saved.";
                    }
                    MessageBox.Show(message, 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