Rotate a PDF page
This code sample creates a copy of a PDF document with each page rotated 90 degrees. Note that you can rotate each page to a custom angle.
using (FileStream inFile = new FileStream(@"..\..\..\inputDocuments\PackingLightBrochure.pdf", FileMode.Open, FileAccess.Read))
{
// open the source document
Document documentIn = new Document(inFile);
// create the target document
Document documentOut = new Document();
// enumerate the pages in the source document
foreach (Page inputPage in documentIn.Pages)
{
// append a rotated version of the original page to the target document
// create a new page that has the width and height swapped
Page page = new Page(inputPage.Height, inputPage.Width);
// because the pageShape rotates clockwise with the rotation point at the lower left
// corner, we must apply a translation in order to get the page in view again
PageShape pageShape = new PageShape(inputPage, 0, inputPage.Width, inputPage.Width, inputPage.Height, true, 90, PageBoundary.Default);
page.VisualOverlay.Add(pageShape);
documentOut.Pages.Add(page);
}
// write the target document to disk
using (FileStream outFile = new FileStream(@"..\..\rotatepage.pdf", FileMode.Create, FileAccess.Write))
{
documentOut.Write(outFile);
}
Using inFile As New FileStream("..\..\..\inputDocuments\PackingLightBrochure.pdf", FileMode.Open, FileAccess.Read)
' open the source document
Dim documentIn As New Document(New BinaryReader(inFile))
' create the target document
Dim documentOut As New Document()
For i As Integer = 0 To documentIn.Pages.Count - 1
' enumerate the pages in the source document
' append a rotated version of thew original page to the target document
' create a new page that has the width and height swapped
Dim page As New Page(documentIn.Pages(i).Height, documentIn.Pages(i).Width)
' because the pageShape rotates clockwise with the rotation point at the lower left
' corner, we must apply a translation in order to get the page in view again
Dim pageShape As New PageShape(documentIn.Pages(i), 0, page.Height, page.Height, page.Width, True, _
90, PageBoundary.[Default])
page.VisualOverlay.Add(pageShape)
documentOut.Pages.Add(page)
Next
' write the target document to disk
Using outFile As New FileStream("..\..\rotatepage.pdf", FileMode.Create, FileAccess.Write)
documentOut.Write(New BinaryWriter(outFile))
End Using
End Using

PDFControls.NET 2.0
A collection of UI controls for adding PDF read and edit functionality to your .NET Windows application.
Print PDF unattended
Convert PDF to JPG PNG
Convert to multi-page TIFF
Single assembly

PDFControls.NET 3.0
Build your own PDF editor. UI Controls for adding PDF read and edit functionality to your .NET application.

PDFKit.NET 4.0
Create and manipulate PDF documents. Split, append, stamp, encrypt, extract, fill and more.
Single assembly
Convert PDF to JPG PNG
Convert to multi-page TIFF
Print PDF unattended

PDFKit.NET 5.0
Create and manipulate PDF documents. Split, append, stamp, encrypt, extract, fill and more.
Single assembly
Convert PDF to JPG PNG
Convert to multi-page TIFF
Print PDF unattended