Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.PDF for .NET API provides full flexibility to work with pages in a PDF document using C# or any other .NET language. It maintains all the pages of a PDF document in PageCollection that can be used to work with PDF pages. Aspose.PDF for .NET lets you insert a page to a PDF document at any location in the file as well as add pages to the end of a PDF file. This section shows how to add pages to a PDF using C#.
Aspose.PDF for .NET lets you insert a page to a PDF document at any location in the file as well as add pages to the end of a PDF file.
The following code snippet also work with Aspose.PDF.Drawing library.
To insert an empty page in a PDF file:
The following code snippet shows you how to insert a page in a PDF file.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void InsertAnEmptyPage()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Pages();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "InsertEmptyPage.pdf"))
{
// Insert an empty page in a PDF
document.Pages.Insert(2);
// Save PDF document
document.Save(dataDir + "InsertEmptyPage_out.pdf");
}
}
In example above, we added empty page with default parameters. If you need to make page size the same as another page in document you should add a few lines of code:
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void InsertAnEmptyPageWithParameters()
{
var page = document.Pages.Insert(2);
//copy page parameters from page 1
page.ArtBox = document.Pages[1].ArtBox;
page.BleedBox = document.Pages[1].BleedBox;
page.CropBox = document.Pages[1].CropBox;
page.MediaBox = document.Pages[1].MediaBox;
page.TrimBox = document.Pages[1].TrimBox;
}
Sometimes, you want to ensure that a document ends on an empty page. This topic explains how to insert an empty page at the end of the PDF document.
To insert an empty page at the end of a PDF file:
The following code snippet shows you how to insert an empty page at the end of a PDF file.
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void InsertAnEmptyPageAtTheEnd()
{
// The path to the documents directory
var dataDir = RunExamples.GetDataDir_AsposePdf_Pages();
// Open PDF document
using (var document = new Aspose.Pdf.Document(dataDir + "InsertEmptyPageAtEnd.pdf"))
{
// Insert an empty page at the end of a PDF file
document.Pages.Add();
// Save PDF document
document.Save(dataDir + "InsertEmptyPageAtEnd_out.pdf");
}
}
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.