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
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.
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();
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