ComponentOne PDF for .NET
In This Topic
    Page
    In This Topic

    A PDF document can contain multiple pages. PDF for .NET allows you to add pages in a PDF document, set their size and orientation through code. Let us discuss these basic operations that can be performed on the PDF pages in the following sections.

    Add Page

    When you create a PDF document, it automatically adds an empty page to it. However, you can add more pages to the document by using Pages.Add method of the C1PdfDocument class. This method adds a new blank page to the document and sets it as an active page for the PDF document.

    To add a new page to your Pdf document, use the following code.

    C#
    Copy Code
    //Add a page
    pdf.Pages.Add();
    

    Set Page Size

    With PDF for .NET, you can set the size of a page in a PDF document. To do so, you can use PaperKind property of the C1PdfDocument class. To set the page size in PDF, use the following code.

    C#
    Copy Code
    //Set page size
    pdf.PaperKind = System.Drawing.Printing.PaperKind.A4Small;
    

    Alternatively, you can use PageSize property of the C1PdfDocument class to set the size of a page in points.

    Set Page Orientation

    You can specify the page orientation in addition to the page size in a Pdf document. By default, orientation of a PDF document page is set to the portrait mode. However you may choose to display the page in landscape mode by setting Landscape property of the C1PdfDocument class to true.

    C#
    Copy Code
    //Set orientation
    pdf.Landscape = true;