Working with Page Rotation

Rotate page using PageRotations

To rotate pages in document we can use PageRotations. PageRotations contains the page number and rotation degree, the key represents the page number, the value of key represents the rotation in degrees.

public static void RotatePages1()
{
    var editor = new PdfPageEditor();
    editor.BindPdf(_dataDir + "sample.pdf");

    editor.PageRotations = new System.Collections.Generic.Dictionary<int, int> { { 1, 90 }, { 2, 180 }, { 3,270 } };

    editor.Save(_dataDir + "sample-rotate-a.pdf");
}

Rotate page using Rotation

We can also use Rotation propety. The rotation must be 0, 90, 180 or 270

public static void RotatePages2()
{
    var editor = new PdfPageEditor();
    editor.BindPdf(_dataDir + "sample.pdf");

    editor.ProcessPages = new int[] { 1, 3 };
    editor.Rotation = 90;

    editor.Save(_dataDir + "sample-rotate-a.pdf");
}