GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / InsertPage Method / InsertPage(PdfPageSizes,Int32) Method
A member of the PdfPageSizes enumeration. The predefined page size.
The required position of the page to insert, that means the page number for the newly inserted page. It must be a value greater than 0.

If the specified value is greater than the number of all pages in the loaded document, the new page is automatically inserted as the last page.

Example





In This Topic
InsertPage(PdfPageSizes,Int32) Method
In This Topic
Inserts a new blank page according to the required predefined page size and the page position into the currently loaded PDF document. The newly inserted page is automatically selected as the current page.
Syntax
'Declaration
 
Public Overloads Function InsertPage( _
   ByVal PageSize As PdfPageSizes, _
   ByVal PageNo As Integer _
) As GdPictureStatus
public GdPictureStatus InsertPage( 
   PdfPageSizes PageSize,
   int PageNo
)
public function InsertPage( 
    PageSize: PdfPageSizes;
    PageNo: Integer
): GdPictureStatus; 
public function InsertPage( 
   PageSize : PdfPageSizes,
   PageNo : int
) : GdPictureStatus;
public: GdPictureStatus InsertPage( 
   PdfPageSizes PageSize,
   int PageNo
) 
public:
GdPictureStatus InsertPage( 
   PdfPageSizes PageSize,
   int PageNo
) 

Parameters

PageSize
A member of the PdfPageSizes enumeration. The predefined page size.
PageNo
The required position of the page to insert, that means the page number for the newly inserted page. It must be a value greater than 0.

If the specified value is greater than the number of all pages in the loaded document, the new page is automatically inserted as the last page.

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 inserted page is automatically set as the current page after the successful insertion.

Example
How to insert a standard A4 page into the newly created document.
Dim caption As String = "Example: InsertPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
    Dim status As GdPictureStatus = gdpicturePDF.InsertPage(PdfPageSizes.PdfPageSizeA4, 1)
    If status = GdPictureStatus.OK Then
        If gdpicturePDF.SaveToFile("test_InsertPage.pdf") = GdPictureStatus.OK Then
            MessageBox.Show("The page has been inserted successfully and the file has been saved.", caption)
        Else
            MessageBox.Show("The page has been inserted successfully, but the file can't be saved.", caption)
        End If
    Else
        MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: InsertPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
    GdPictureStatus status = gdpicturePDF.InsertPage(PdfPageSizes.PdfPageSizeA4, 1);
    if (status == GdPictureStatus.OK)
    {
        if (gdpicturePDF.SaveToFile("test_InsertPage.pdf") == GdPictureStatus.OK)
            MessageBox.Show("The page has been inserted successfully and the file has been saved.", caption);
        else
            MessageBox.Show("The page has been inserted successfully, but the file can't be saved.", caption);
    }
    else
        MessageBox.Show("The InsertPage() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
See Also