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.
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# |
コードのコピー
|
---|---|
//ページを追加します
pdf.Pages.Add();
|
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# |
コードのコピー
|
---|---|
//ページ サイズを設定します
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.
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# |
コードのコピー
|
---|---|
//方向を設定します pdf.Landscape = true; |