Reference Guide
GdPicture14 Namespace / GdPicturePDF Class / ClonePage Method / ClonePage(Int32) Method
The page number of a page you want to clone. It must be a value from 1 to GetPageCount.
Example





In This Topic
    ClonePage(Int32) Method
    In This Topic
    Clones a page specified by its page number, that means creates exactly the same copy of the specified page, in the currently loaded PDF document. The newly created page is added at the end of the document as the last page and it is automatically selected as the current page.

    Just to inform you, that the toolkit offers the adaptive file caching mechanism to significantly reduce memory usage while cloning large documents. The feature is available in both 32-bit and 64-bit mode by default.

    Syntax
    'Declaration
     
    
    Public Overloads Function ClonePage( _
       ByVal PageNo As Integer _
    ) As GdPictureStatus
    public GdPictureStatus ClonePage( 
       int PageNo
    )
    public function ClonePage( 
        PageNo: Integer
    ): GdPictureStatus; 
    public function ClonePage( 
       PageNo : int
    ) : GdPictureStatus;
    public: GdPictureStatus ClonePage( 
       int PageNo
    ) 
    public:
    GdPictureStatus ClonePage( 
       int PageNo
    ) 

    Parameters

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

    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 newly created page is automatically set as the current page after successful cloning.

    Example
    How to clone all pages of the PDF document.
    Dim caption As String = "Example: ClonePage"
    Dim oGdPicturePDF As New GdPicturePDF()
    If oGdPicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
        Dim count As Integer = oGdPicturePDF.GetPageCount()
        Dim status As GdPictureStatus = oGdPicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            For i As Integer = 1 To count
                status = oGdPicturePDF.ClonePage(i)
                If status <> GdPictureStatus.OK Then
                    MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption)
                    Exit For
                End If
            Next
            If status = GdPictureStatus.OK Then
                If oGdPicturePDF.SaveToFile("test_ClonePage.pdf") = GdPictureStatus.OK Then
                    MessageBox.Show("The pages have been cloned successfully and the file has been saved.", caption)
                Else
                    MessageBox.Show("The pages have been cloned successfully, but the file can't be saved.", caption)
                End If
            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
    oGdPicturePDF.Dispose()
    string caption = "Example: ClonePage";
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    if (oGdPicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
    {
        int count = oGdPicturePDF.GetPageCount();
        GdPictureStatus status = oGdPicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
        {
            for (int i = 1; i <= count; i++)
            {
                status = oGdPicturePDF.ClonePage(i);
                if (status != GdPictureStatus.OK)
                {
                    MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption);
                    break;
                }
            }
            if (status == GdPictureStatus.OK)
            {
                if (oGdPicturePDF.SaveToFile("test_ClonePage.pdf") == GdPictureStatus.OK)
                    MessageBox.Show("The pages have been cloned successfully and the file has been saved.", caption);
                else
                    MessageBox.Show("The pages have been cloned successfully, but the file can't be saved.", 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);
    oGdPicturePDF.Dispose();
    See Also