GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / RotatePage Method
The rotation angle, in degrees, determining the clockwise rotation. This parameter can be set to 90, -90, 180, -180, 270, -270 or any multiple of 90.
Example





In This Topic
RotatePage Method (GdPicturePDF)
In This Topic
Rotates clockwise the currently selected page of the loaded PDF document. The rotation angle can be set to 90, 180 or 270 degrees.
Syntax
'Declaration
 
Public Function RotatePage( _
   ByVal Rotation As Integer _
) As GdPictureStatus
public GdPictureStatus RotatePage( 
   int Rotation
)
public function RotatePage( 
    Rotation: Integer
): GdPictureStatus; 
public function RotatePage( 
   Rotation : int
) : GdPictureStatus;
public: GdPictureStatus RotatePage( 
   int Rotation
) 
public:
GdPictureStatus RotatePage( 
   int Rotation
) 

Parameters

Rotation
The rotation angle, in degrees, determining the clockwise rotation. This parameter can be set to 90, -90, 180, -180, 270, -270 or any multiple of 90.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

This method requires the Document Editor component to run.

Example
How to rotate all pages of your document step by step by multiple of 90 degrees, that means each page is rotated by next (means page number) multiple of 90. You can subsequently determine the actual page rotation.
Dim caption As String = "Example: RotatePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        For i As Integer = 1 To count
            status = gdpicturePDF.SelectPage(i)
            If status = GdPictureStatus.OK Then
                status = gdpicturePDF.RotatePage(i * 90)
                If status = GdPictureStatus.OK Then
                    Dim rotation As Integer = gdpicturePDF.GetPageRotation()
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        MessageBox.Show("The rotation angle of the page nr." + i.ToString() + " is " + rotation.ToString() + " degrees.", caption)
                    Else
                        MessageBox.Show("The GetPageRotation() method has failed with the status: " + status.ToString(), caption)
                    End If
                    If i = count Then
                        If gdpicturePDF.SaveToFile("test_RotatePage.pdf") = GdPictureStatus.OK Then
                            MessageBox.Show("The pages have been rotated successfully and the file has been saved.", caption)
                        Else
                            MessageBox.Show("The pages have been rotated successfully but the file can't be saved.", caption)
                        End If
                    End If
                Else
                    MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
                    Exit For
                End If
            Else
                MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
                Exit For
            End If
        Next
    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: RotatePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetPageCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        for (int i = 1; i <= count; i++)
        {
            status = gdpicturePDF.SelectPage(i);
            if (status == GdPictureStatus.OK)
            {
                status = gdpicturePDF.RotatePage(i*90);
                if (status == GdPictureStatus.OK)
                {
                    int rotation = gdpicturePDF.GetPageRotation();
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                        MessageBox.Show("The rotation angle of the page nr." + i.ToString() + " is " + rotation.ToString() + " degrees.", caption);
                    else
                        MessageBox.Show("The GetPageRotation() method has failed with the status: " + status.ToString(), caption);
                    if (i == count)
                    {
                        if (gdpicturePDF.SaveToFile("test_RotatePage.pdf") == GdPictureStatus.OK)
                            MessageBox.Show("The pages have been rotated successfully and the file has been saved.", caption);
                        else
                            MessageBox.Show("The pages have been rotated successfully but the file can't be saved.", caption);
                    }
                }
                else
                {
                    MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
                    break;
                }
            }
            else
            {
                MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
                break;
            }
        }
    }
    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