This samples shows how to add or insert pages to your PDF documents.

You can access the collection of PDF document pages using PdfDocument.Pages property. Use PdfDocument.AddPage() method to add a new page to the end of the document. Use PdfDocument.InsertPage(int position) method to insert a new page to an arbitrary position in the document. Valid range for position argument is (0..Pages.Count) inclusive.

Call to the InsertPage method with position argument equal to PdfDocument.Pages.Count is the same as call to the PdfDocument.AddPage() method. Both of AddPage and InsertPage methods return the newly created page.

C#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class AddPages
    {
        public static void Main()
        {
            // NOTE: 
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToFile = "AddPages.pdf";

            using (PdfDocument pdf = new PdfDocument())
            {
                // There is already one page in PDF document after creation
                PdfPage firstPage = pdf.Pages[0];
                firstPage.Canvas.DrawString("This is the auto-created first page");

                // AddPage method adds a new page to the end of the PDF document
                PdfPage secondPage = pdf.AddPage();
                secondPage.Canvas.DrawString("Second page");

                // You can insert a new page in an arbitrary place
                PdfPage newFirstPage = pdf.InsertPage(0);
                newFirstPage.Canvas.DrawString("New first page");

                // This call is an equivalent of AddPage method
                PdfPage lastPage = pdf.InsertPage(pdf.PageCount);
                lastPage.Canvas.DrawString("Last page");

                pdf.Save(pathToFile);
            }

            Process.Start(pathToFile);
        }
    }
}
VB
Imports System.Diagnostics
Imports System.IO

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class AddPages
        Public Shared Sub Main()
            ' NOTE: 
            ' When used in trial mode, the library imposes some restrictions.
            ' Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            ' for more information.

            Dim pathToFile As String = "AddPages.pdf"

            Using pdf As New PdfDocument()
                ' There is already one page in PDF document after creation
                Dim firstPage As PdfPage = Pdf.Pages(0)
                firstPage.Canvas.DrawString("This is the auto-created first page")

                ' AddPage method adds a new page to the end of the PDF document
                Dim secondPage As PdfPage = Pdf.AddPage()
                secondPage.Canvas.DrawString("Second page")

                ' You can insert a new page in an arbitrary place
                Dim newFirstPage As PdfPage = Pdf.InsertPage(0)
                newFirstPage.Canvas.DrawString("New first page")

                ' This call is an equivalent of AddPage method
                Dim lastPage As PdfPage = Pdf.InsertPage(Pdf.PageCount)
                lastPage.Canvas.DrawString("Last page")

                Pdf.Save(pathToFile)
            End Using

            Process.Start(pathToFile)
        End Sub
    End Class
End Namespace