How to Set Page Orientation and Rotation in .NET C# | IronPDF

How to Set Page Orientation & Rotation in .NET C#

IronPDF enables you to set page orientation (portrait/landscape) during PDF rendering and rotate existing or newly created PDF pages to 0°, 90°, 180°, or 270° angles using simple C# methods.

Page Orientation refers to how a page is laid out, either vertically (portrait) or horizontally (landscape).

Page Rotation is the adjustment of a page's angle, allowing you to change its orientation, which can be useful for correcting alignment or meeting specific viewing preferences. Page angles can be set at 90, 180, and 270 degrees.

IronPDF allows you to specify the orientation as either portrait or landscape during the rendering process. Additionally, you can individually rotate newly rendered or existing PDF pages to angles of 0, 90, 180, or 270 degrees as needed.

Quickstart: Set PDF Page Orientation and Rotation in C#

Set page orientation and rotation in your PDF files using IronPDF in .NET C#. Begin by loading your PDF, then apply desired rotations or orientations with simple method calls. Save your updated document, ensuring your layout meets specific requirements. This guide helps you get started quickly.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. Copy and run this code snippet.

    IronPdf.PdfDocument.FromFile("file.pdf")
        .SetAllPageRotations(IronPdf.PdfDocument.PageRotation.Rotate90)
        .SaveAs("rotated.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer


How Do I Set Page Orientation in IronPDF?

Setting the orientation is only possible when generating a PDF document from other formats. You can access the PaperOrientation property from the RenderingOptions class. This property can be set to either portrait or landscape. Portrait is the default page orientation setting.

When working with IronPDF, you'll find that the rendering options provide extensive control over how your PDFs are generated. The orientation setting is particularly important when converting HTML documents, web pages, or other formats to PDF, as it determines the fundamental layout of your pages.

When Should I Use Landscape Orientation?

Landscape orientation is ideal for content that requires more horizontal space, such as wide tables, charts, dashboards, or presentations. When you're converting HTML files to PDF, landscape mode ensures that wide content displays correctly without unwanted text wrapping or element overflow. This orientation is particularly useful for reports containing financial data, project timelines, or any content designed for widescreen viewing.

:path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-orientation.cs
using IronPdf;
using IronPdf.Rendering;

ChromePdfRenderer renderer = new ChromePdfRenderer();

// Change paper orientation
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;

PdfDocument pdf = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page");

pdf.SaveAs("landscape.pdf");
$vbLabelText   $csharpLabel

The ChromePdfRenderer class offers additional flexibility when setting orientation. You can also specify custom paper sizes alongside orientation settings to create PDFs that meet exact specifications. This is particularly valuable when creating documents for specialized printing requirements or unique display formats.

What Does the Landscape Output Look Like?


How Do I Rotate PDF Pages in C#?

There are four possible rotation degrees offered by IronPDF:

  • None: 0 degrees or non-rotated document.
  • Clockwise90: 90 degrees rotated clockwise.
  • Clockwise180: 180 degrees rotated clockwise.
  • Clockwise270: 270 degrees rotated clockwise.

Please noteAll page index positions mentioned below follow zero-based indexing.

Page rotation is a fundamental feature when editing PDFs programmatically. Unlike orientation settings which apply during rendering, rotation can be applied to existing PDF documents. This makes it an essential tool for correcting scanned documents, adjusting imported content, or preparing documents for specific viewing requirements.

Which Methods Should I Use to Rotate Pages?

Use the methods below to set the rotation for a single page, multiple pages, or all pages.

  • SetAllPageRotations: Sets the rotation degree for all pages.
  • SetPageRotation: Sets the rotation degree for a single page.
  • SetPageRotations: Sets the rotation degree for a selected list of pages.

IronPDF's rotation methods work seamlessly with other page manipulation features. You can combine rotation with other transform operations to achieve complex document layouts, or use them alongside methods for rotating text and pages to create sophisticated document structures.

:path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-set-rotation.cs
using IronPdf;
using IronPdf.Rendering;
using System.Collections.Generic;

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

// Set all pages
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90);

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

// Set multiple pages
List<int> selectedPages = new List<int>() { 0, 3 };
pdf.SetPageRotations(selectedPages, PdfPageRotation.Clockwise270);

pdf.SaveAs("rotatedLandscape.pdf");
$vbLabelText   $csharpLabel

When working with rotation, it's important to understand that the operation affects the entire page content, including text, images, and any annotations. This differs from text-specific rotation, which only affects individual text elements. For more granular control over document layout, explore the comprehensive PDF creation tutorial that covers advanced formatting techniques.

What Does the Rotated PDF Look Like?

How Can I Check the Current Page Rotation?

Use the GetPageRotation method to retrieve the rotation of any particular page in the PDF document. Simply supply the page index to the method.

This method is particularly useful when processing documents with mixed orientations or when you need to maintain consistent rotation across merged documents. The ability to query current rotation states enables intelligent document processing workflows, especially when combined with other page orientation examples.

:path=/static-assets/pdf/content-code-examples/how-to/page-orientation-rotation-get-rotation.cs
using IronPdf;
using IronPdf.Rendering;

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

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

Best Practices for Page Orientation and Rotation

When implementing page orientation and rotation in your applications, consider these best practices:

  1. Determine Orientation Before Rendering: Set orientation before rendering to ensure optimal layout.

  2. Batch Processing: Use SetPageRotations for multiple pages to improve performance.

  3. Preserve Original Files: Save rotated versions with new filenames to preserve originals.

  4. Consider User Experience: Remember that rotation affects PDF viewer display.

  5. Combine with Other Features: Use rotation with headers, merging, or watermarks.

Troubleshooting Common Issues

If you encounter issues with page orientation or rotation, consider these solutions:

  • Content Cut-off in Landscape: Ensure HTML content is responsive or adjust viewport width
  • Rotation Not Applied: Verify you're calling SaveAs after applying rotation methods
  • Mixed Orientations: Process portrait and landscape pages separately before merging

For additional support and advanced techniques, explore the comprehensive IronPDF documentation or check out more specialized tutorials on PDF manipulation.

Frequently Asked Questions

How do I set page orientation to landscape when creating PDFs?

With IronPDF, you can set page orientation using the PaperOrientation property in the RenderingOptions class. Simply set it to landscape or portrait before rendering your PDF from HTML or other formats. Portrait is the default setting.

What's the difference between page orientation and page rotation?

Page orientation in IronPDF determines the initial layout (portrait or landscape) when rendering PDFs from other formats. Page rotation allows you to adjust existing PDF pages to angles of 0°, 90°, 180°, or 270° after creation, perfect for correcting alignment issues.

Can I rotate individual pages or do I have to rotate the entire PDF?

IronPDF provides flexibility to rotate both individual pages and entire PDFs. You can use methods to rotate specific pages by their index or apply rotation to all pages at once using the SetAllPageRotations method.

When should I use landscape orientation for my PDFs?

Landscape orientation in IronPDF is ideal for wide content like tables, charts, dashboards, or presentations. It's particularly useful when converting HTML files containing financial data, project timelines, or any content designed for widescreen viewing to prevent text wrapping or element overflow.

How can I check the current rotation angle of a PDF page?

IronPDF allows you to retrieve the current rotation angle of any PDF page programmatically. This feature helps you determine the existing orientation before making adjustments or verify that your rotation changes have been applied correctly.

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
Ready to Get Started?
Nuget Downloads 17,012,929 | Version: 2025.12 just released