Page parameters

Docotic.Pdf Library Help > Samples > Pages and Navigation > Page parameters

This sample shows how to setup a page size, orientation or rotation.

You can specify size of any page in pixels using PdfPage.Width and PdfPage.Height properties. You can also use PdfPage.Size property to specify size of a page using a value from PdfPaperSize enumeration. This enumeration defines a lot of predefined paper formats like A4, Letter or Envelope.

Please use PdfPage.Orientation property to specify orientation of a page (portrait or landscape).

You can specify a rotation for a page using PdfPage.Rotation property. Rotation can be 90, 180 or 270 degrees in clockwise direction.

CopyC#
using System.Diagnostics;

namespace BitMiracle.Docotic.Pdf.Samples
{
    public static class PageParameters
    {
        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.

            PdfDocument pdf = new PdfDocument();
            pdf.InitialView = pdf.CreateView(0);
            pdf.InitialView.SetFitPage();

            PdfPage firstPage = pdf.Pages[0];
            firstPage.Size = PdfPaperSize.A6;

            PdfPage secondPage = pdf.AddPage();
            secondPage.Width = 300;
            secondPage.Height = 100;

            PdfPage thirdPage = pdf.AddPage();
            thirdPage.Rotation = PdfRotation.Rotate90;

            PdfPage fourthPage = pdf.AddPage();
            fourthPage.Orientation = PdfPaperOrientation.Landscape;

            string pathToFile = "PageParameters.pdf";
            pdf.Save(pathToFile);
            pdf.Dispose();

            Process.Start(pathToFile);
        }
    }
}
CopyVB.NET
Imports System.Diagnostics

Imports BitMiracle.Docotic.Pdf

Namespace BitMiracle.Docotic.Pdf.Samples
    Public NotInheritable Class PageParameters
        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 pdf As New PdfDocument()
            pdf.InitialView = pdf.CreateView(0)
            pdf.InitialView.SetFitPage()

            Dim firstPage As PdfPage = pdf.Pages(0)
            firstPage.Size = PdfPaperSize.A6

            Dim secondPage As PdfPage = pdf.AddPage()
            secondPage.Width = 300
            secondPage.Height = 100

            Dim thirdPage As PdfPage = pdf.AddPage()
            thirdPage.Rotation = PdfRotation.Rotate90

            Dim fourthPage As PdfPage = pdf.AddPage()
            fourthPage.Orientation = PdfPaperOrientation.Landscape

            Dim pathToFile As String = "PageParameters.pdf"
            pdf.Save(pathToFile)
            pdf.Dispose()

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