GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / MovePage Method
The page number of a page you want to move. It must be a value from 1 to GetPageCount.
The page number of a destination page. It must be a value from 1 to GetPageCount.

The specified page you want to move takes on this page number after the successful move.

Example





In This Topic
MovePage Method (GdPicturePDF)
In This Topic
Moves a specified page to a destination page within the currently loaded PDF document. Moving a page means that the specified page takes on the page number, that is equal to the destination page number. Please note that the destination page doesn't change its position in the document. The current page is automatically set to the moved page after successful moving.
Syntax
'Declaration
 
Public Function MovePage( _
   ByVal PageNo As Integer, _
   ByVal Destination As Integer _
) As GdPictureStatus
public GdPictureStatus MovePage( 
   int PageNo,
   int Destination
)
public function MovePage( 
    PageNo: Integer;
    Destination: Integer
): GdPictureStatus; 
public function MovePage( 
   PageNo : int,
   Destination : int
) : GdPictureStatus;
public: GdPictureStatus MovePage( 
   int PageNo,
   int Destination
) 
public:
GdPictureStatus MovePage( 
   int PageNo,
   int Destination
) 

Parameters

PageNo
The page number of a page you want to move. It must be a value from 1 to GetPageCount.
Destination
The page number of a destination page. It must be a value from 1 to GetPageCount.

The specified page you want to move takes on this page number after the successful move.

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.

The moved page is automatically set as the current page after the successful moving.

This method requires the Document Editor component to run.

Example
How to move the first page of your document to become the third page.
Dim caption As String = "Example: MovePage"
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
        If count < 3 Then
            status = GdPictureStatus.InvalidParameter
        Else
            status = gdpicturePDF.MovePage(1, 3)
            If status = GdPictureStatus.OK Then
                If gdpicturePDF.SaveToFile("test_MovePage.pdf") = GdPictureStatus.OK Then
                    MessageBox.Show("The pages have been moved successfully and the file has been saved.", caption)
                Else
                    MessageBox.Show("The pages have been moved successfully, but the file can't be saved.", caption)
                End If
            Else
                MessageBox.Show("The MovePage() method has failed with the status: " + status.ToString(), caption)
                status = GdPictureStatus.OK
            End If
        End If
    End If
    If status <> GdPictureStatus.OK Then
        MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: MovePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetPageCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        if (count < 3)
            status = GdPictureStatus.InvalidParameter;
        else
        {
            status = gdpicturePDF.MovePage(1,3);
            if (status == GdPictureStatus.OK)
            {
                if (gdpicturePDF.SaveToFile("test_MovePage.pdf") == GdPictureStatus.OK)
                    MessageBox.Show("The pages have been moved successfully and the file has been saved.", caption);
                else
                    MessageBox.Show("The pages have been moved successfully, but the file can't be saved.", caption);
            }
            else
            {
                MessageBox.Show("The MovePage() method has failed with the status: " + status.ToString(), caption);
                status = GdPictureStatus.OK;
            }
        }
    }
    if (status != GdPictureStatus.OK)
        MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also