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.
-
1Install IronPDF with NuGet Package Manager
-
2Copy and run this code snippet.
var pdf = IronPdf.PdfDocument.FromFile("file.pdf"); pdf.SetAllPageRotations(IronPdf.Rendering.PdfPageRotation.Clockwise90); pdf.SaveAs("file-rotated.pdf");C# -
3Deploy to test on your live environment
Start using IronPDF in your project today with a free trial
Minimal Workflow (5 steps)
- Download the IronPDF C# Library for PDF Page Orientation and Rotation
- Use the PaperOrientation property to set page orientation before rendering
- Explore All Page Rotation Options with IronPDF
- Learn Method to Rotate Individual or Multiple PDF Pages
- Retrieve PDF Page Rotation with IronPDF
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.
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");Imports IronPdf
Imports IronPdf.Rendering
Private renderer As New ChromePdfRenderer()
' Change paper orientation
renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape
Dim pdf As PdfDocument = renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Main_Page")
pdf.SaveAs("landscape.pdf")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.
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.
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");Imports IronPdf
Imports IronPdf.Rendering
Imports System.Collections.Generic
Private pdf As PdfDocument = PdfDocument.FromFile("landscape.pdf")
' Set all pages
pdf.SetAllPageRotations(PdfPageRotation.Clockwise90)
' Set a single page
pdf.SetPageRotation(1, PdfPageRotation.Clockwise180)
' Set multiple pages
Dim selectedPages As New List(Of Integer)() From {0, 3}
pdf.SetPageRotations(selectedPages, PdfPageRotation.Clockwise270)
pdf.SaveAs("rotatedLandscape.pdf")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.
using IronPdf;
using IronPdf.Rendering;
PdfDocument pdf = PdfDocument.FromFile("rotatedLandscape.pdf");
PdfPageRotation rotation = pdf.GetPageRotation(1);Imports IronPdf
Imports IronPdf.Rendering
Private pdf As PdfDocument = PdfDocument.FromFile("rotatedLandscape.pdf")
Private rotation As PdfPageRotation = pdf.GetPageRotation(1)The IronSuite play a crucial role in our operations. These are tools that increase efficiencies across the business including creating floor plans and improving inventory management.
Best Practices for Page Orientation and Rotation
When implementing page orientation and rotation in your applications, consider these best practices:
- Determine Orientation Before Rendering: Set orientation before rendering to ensure optimal layout.
- Batch Processing: Use
SetPageRotationsfor multiple pages to improve performance. - Preserve Original Files: Save rotated versions with new filenames to preserve originals.
- Consider User Experience: Remember that rotation affects PDF viewer display.
- 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
SaveAsafter 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 can I set page orientation in a PDF using IronPDF?
To set page orientation, you can use the `PaperOrientation` property from the `RenderingOptions` class in IronPDF. This allows you to specify either portrait or landscape orientation when generating a PDF document.
What rotation angles are supported by IronPDF?
IronPDF supports rotation angles of 0, 90, 180, and 270 degrees, allowing you to adjust the layout of PDF pages to fit specific viewing preferences or correction needs.
What is the difference between page orientation and page rotation in IronPDF?
Page orientation refers to the layout of the page as either portrait or landscape during rendering, while page rotation adjusts the angle of a page in an existing PDF document to 0, 90, 180, or 270 degrees.
How do I rotate an entire PDF document using IronPDF?
To rotate an entire PDF document, you can use the `SetAllPageRotations` method in IronPDF. This method allows you to apply the desired rotation angle to all pages within the document.
Can I rotate individual pages in a PDF with IronPDF?
Yes, you can rotate individual pages in a PDF using the `SetPageRotation` method. This method allows you to specify the rotation angle for a single page by its index.
What should I consider when using landscape orientation in PDFs?
Landscape orientation is best for content that requires more horizontal space, such as wide tables or charts. It helps display wide content correctly without text wrapping issues.
How can I check the current rotation of a specific PDF page?
You can check the current rotation of a PDF page by using the `GetPageRotation` method, supplying the page index as a parameter to retrieve the rotation degree of that page.
Is it possible to set different page orientations for merged PDFs using IronPDF?
Yes, IronPDF provides options to manage page orientation for PDFs prior to merging. It's advisable to process pages with different orientations separately before merging them.
How does page rotation affect the overall PDF layout?
Page rotation affects the entire content of the page, including text, images, and annotations. It is typically used for document alignment corrections or specific viewing requirements.
What best practices should I follow for page orientation and rotation in PDF files?
Best practices include determining orientation before rendering, using batch processing for rotation, preserving original files, considering user experience, and combining rotation with features like headers or watermarks.

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.