Skip to footer content
USING IRONPDF

Fixing PDF Orientation and Rotation in C# for Readable Documents

Two layout problems show up constantly in document workflows. Wide content such as financial tables, dashboards, and project timelines gets clipped or wrapped when forced into portrait. And scanned or imported pages often arrive sideways or upside down. IronPDF solves both in C#, setting orientation while a PDF is being rendered and rotating pages on documents that already exist.

The Business Problem

A reporting system outputs a spreadsheet-style table that overflows a portrait page. A document-intake process receives scans that are rotated the wrong way. A final report assembled from several sources has pages at inconsistent angles. Each case leaves users squinting, scrolling sideways, or rotating pages by hand in a viewer. The goal is correct, consistent layout produced automatically.

Setting Orientation at Render Time

Orientation is chosen when generating a PDF from another format, through the PaperOrientation property. Landscape gives wide content the horizontal room it needs.

using IronPdf;
using IronPdf.Rendering;

ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;

PdfDocument pdf = renderer.RenderHtmlAsPdf(reportHtml);
pdf.SaveAs("report-landscape.pdf");
using IronPdf;
using IronPdf.Rendering;

ChromePdfRenderer renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;

PdfDocument pdf = renderer.RenderHtmlAsPdf(reportHtml);
pdf.SaveAs("report-landscape.pdf");
Imports IronPdf
Imports IronPdf.Rendering

Dim renderer As New ChromePdfRenderer()
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape

Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(reportHtml)
pdf.SaveAs("report-landscape.pdf")
$vbLabelText   $csharpLabel

Rotating Pages on Existing Documents

Rotation works on documents already created, which makes it the tool for correcting scans or normalizing merged files. IronPDF offers four fixed angles through the PdfPageRotation enum and methods for one page, a selected set, or all pages.

PdfDocument pdf = PdfDocument.FromFile("scanned.pdf");

// Correct every page in a uniformly misrotated batch
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90);

// Fix a single page
pdf.SetPageRotation(1, PdfPageRotation.Clockwise180);

// Fix a selected set of pages
pdf.SetPageRotations(new List<int> { 0, 3 }, PdfPageRotation.Clockwise270);

pdf.SaveAs("corrected.pdf");
PdfDocument pdf = PdfDocument.FromFile("scanned.pdf");

// Correct every page in a uniformly misrotated batch
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90);

// Fix a single page
pdf.SetPageRotation(1, PdfPageRotation.Clockwise180);

// Fix a selected set of pages
pdf.SetPageRotations(new List<int> { 0, 3 }, PdfPageRotation.Clockwise270);

pdf.SaveAs("corrected.pdf");
Imports System.Collections.Generic

Dim pdf As PdfDocument = PdfDocument.FromFile("scanned.pdf")

' Correct every page in a uniformly misrotated batch
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90)

' Fix a single page
pdf.SetPageRotation(1, PdfPageRotation.Clockwise180)

' Fix a selected set of pages
pdf.SetPageRotations(New List(Of Integer) From {0, 3}, PdfPageRotation.Clockwise270)

pdf.SaveAs("corrected.pdf")
$vbLabelText   $csharpLabel

GetPageRotation reads the current angle of any page, which helps when normalizing documents merged from multiple sources.

PdfPageRotation rotation = pdf.GetPageRotation(1);
PdfPageRotation rotation = pdf.GetPageRotation(1);
Dim rotation As PdfPageRotation = pdf.GetPageRotation(1)
$vbLabelText   $csharpLabel

Points to Plan For

  • Render time versus existing files: PaperOrientation applies only while generating a PDF from another format. Rotation applies to PDFs that already exist. Keeping the two separate avoids the most common mistake.
  • Whole-page rotation: Rotation moves text, images, and annotations together, which differs from rotating individual text elements.
  • Zero-based indexing: SetPageRotation(1, ...) targets the second page.
  • Preserve originals: Save rotated output to a new filename, and use SetPageRotations for multiple pages for better performance.

Result

With orientation set during rendering and rotation applied afterward, teams produce reports that fit their content and intake pipelines that store correctly oriented documents, with no manual cleanup. Full method details are in the page orientation and rotation guide.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me