GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / DuplicatePage Method
The number of copies of the selected page you want to duplicate.
Example





In This Topic
DuplicatePage Method (GdPicturePDF)
In This Topic
Duplicates the currently selected page into the loaded PDF document according to a specified number of copies. All duplicated pages retain its content and the layer structure. They all are appended at the end of the current document and the last page is automatically selected as the current page.

This method is particularly useful if you want to apply a common page header and footer while keeping the file size as small as possible.

Syntax
'Declaration
 
Public Function DuplicatePage( _
   ByVal Count As Integer _
) As GdPictureStatus
public GdPictureStatus DuplicatePage( 
   int Count
)
public function DuplicatePage( 
    Count: Integer
): GdPictureStatus; 
public function DuplicatePage( 
   Count : int
) : GdPictureStatus;
public: GdPictureStatus DuplicatePage( 
   int Count
) 
public:
GdPictureStatus DuplicatePage( 
   int Count
) 

Parameters

Count
The number of copies of the selected page you want to duplicate.

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 last added page is automatically selected as the current page after the successful duplication of the required page.

Example
How to duplicate the first page of your document three times. This example shows you that all three newly created pages are added at the end of the document and the last page is selected as the current.
Dim caption As String = "Example: DuplicatePage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("testPDF.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        If count > 0 Then
            status = gdpicturePDF.SelectPage(1)
            If status = GdPictureStatus.OK Then
                status = gdpicturePDF.DuplicatePage(3)
                If status = GdPictureStatus.OK Then
                    Dim current As Integer = gdpicturePDF.GetCurrentPage()
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        status = gdpicturePDF.SaveToFile("test_DuplicatePage.pdf")
                        If status = GdPictureStatus.OK Then
                            MessageBox.Show("The example HAS been followed successfully." + vbCrLf +
                                            "The current page before the page duplication was: 1 " + vbCrLf +
                                            "The current page after the page duplication is: " + current.ToString(), caption)
                        End If
                    End If
                Else
                    MessageBox.Show("The DuplicatePage() method has failed with the status: " + status.ToString(), caption)
                    status = GdPictureStatus.OK
                End If
            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: DuplicatePage";
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 > 0)
        {
            status = gdpicturePDF.SelectPage(1);
            if (status == GdPictureStatus.OK)
            {
                status = gdpicturePDF.DuplicatePage(3);
                if (status == GdPictureStatus.OK)
                {
                    int current = gdpicturePDF.GetCurrentPage();
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                    {
                        status = gdpicturePDF.SaveToFile("test_DuplicatePage.pdf");
                        if (status == GdPictureStatus.OK)
                            MessageBox.Show("The example HAS been followed successfully.\nThe current page before the page duplication was: 1 \n" +
                            "The current page after the page duplication is: " + current.ToString(), caption);
                    }
                }
                else
                {
                    MessageBox.Show("The DuplicatePage() 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