Rotate PDF Text and Pages in C# with IronPDF
IronPDF enables C# developers to rotate PDF pages and text programmatically using simple methods like SetPageRotation() for complete pages or CSS3 transforms for specific text elements, supporting rotations of 90, 180, or 270 degrees clockwise.
Rotating PDF text or pages changes the orientation of either entire pages or specific text elements within a PDF document. This rotation occurs in degrees (typically 90, 180, or 270) to reposition content clockwise or counterclockwise. This capability is essential for correcting scanned documents, creating landscape reports, or adjusting content presentation for specific viewing requirements.
Easily rotate PDF pages in your .NET applications using IronPDF. With just a few lines of code, you can adjust the orientation of your PDF content to any desired angle. This quickstart guide shows you how to rotate the first page of a PDF document by 90 degrees and save the changes effortlessly. Perfect for developers looking to enhance document presentation with minimal effort.
-
1Install IronPDF with NuGet Package Manager
-
2Copy and run this code snippet.
IronPdf.PdfDocument.FromFile("input.pdf") .SetAllPageRotations(IronPdf.PdfPageRotation.Clockwise90) .SaveAs("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
IronPdfC# PDF Library to rotate PDF - Use the provided methods to set page rotation
- Rotate PDF Pages Programmatically
- Use CSS3 to Rotate PDF Text
- View your PDF Document
How Do I Rotate PDF Pages Programmatically?
Which Methods Should I Use for Different Rotation Scenarios?
Use the SetPageRotation, SetPageRotations, and SetAllPageRotations methods to set rotation for a single page, multiple pages, and all pages, respectively. These methods completely overwrite the current page rotation with the specified degree, measured clockwise. If the original page rotation already matches the desired degree, the methods won't affect the output file.
The IronPdf library provides comprehensive page orientation and rotation capabilities that integrate seamlessly with existing PDF workflows. Whether you're working with newly created PDFs or existing documents, these rotation methods offer precise control over page orientation without affecting the actual content structure.
What Rotation Angles Are Supported?
IronPDF supports four standard rotation angles: 0° (no rotation), 90°, 180°, and 270° clockwise. These angles cover all common rotation requirements for PDF documents. The rotation is applied at the page level, meaning the entire page content, including text, images, and graphics, rotates as a single unit. This approach maintains the spatial relationships between elements on the page.
using IronPdf;
using IronPdf.Rendering;
using System.Linq;
// Import PDF
PdfDocument pdf = PdfDocument.FromFile("multi-page.pdf");
// Set rotation for a single page
pdf.SetPageRotation(0, PdfPageRotation.Clockwise90);
// Set rotation for multiple pages
pdf.SetPageRotations(Enumerable.Range(1,3), PdfPageRotation.Clockwise270);
// Set rotation for the entire document
pdf.SetAllPageRotations(PdfPageRotation.Clockwise180);
pdf.SaveAs("rotated.pdf");Imports IronPdf
Imports IronPdf.Rendering
Imports System.Linq
' Import PDF
Private pdf As PdfDocument = PdfDocument.FromFile("multi-page.pdf")
' Set rotation for a single page
pdf.SetPageRotation(0, PdfPageRotation.Clockwise90)
' Set rotation for multiple pages
pdf.SetPageRotations(Enumerable.Range(1,3), PdfPageRotation.Clockwise270)
' Set rotation for the entire document
pdf.SetAllPageRotations(PdfPageRotation.Clockwise180)
pdf.SaveAs("rotated.pdf")When working with page rotations, it's important to understand how they interact with other PDF features. For example, if you're also using custom paper sizes, the rotation will be applied after the page size is set. This means a portrait page rotated 90 degrees will effectively become landscape oriented.
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.
How Can I Use CSS3 to Rotate Text in PDFs?
Why Use CSS3 Transform Instead of Page Rotation?
After converting HTML to PDF in .NET, you might need to programmatically rotate text or entire pages. A frequent requirement is rendering vertically aligned text in PDFs using HTML5 and CSS3. CSS3 transforms offer more granular control compared to page-level rotation, allowing you to rotate individual text elements or sections while keeping the rest of the page in its original orientation.
This approach is particularly useful when creating documents with mixed orientations, such as reports with vertical labels on charts or tables with rotated headers. The HTML to PDF conversion process in IronPDF fully supports CSS3 transforms, ensuring your styled content appears exactly as intended in the final PDF.
What CSS Properties Control Text Rotation?
CSS3 allows text rotation to any angle after converting HTML to PDF using the IronPdf .NET Library you installed earlier. This is achieved using the transform: rotate(...) CSS3 style, which can rotate any HTML element to any angle. The rotation origin can be customized using the transform-origin property, giving you complete control over the rotation pivot point.
using IronPdf;
var renderer = new IronPdf.ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(@"
<html>
<head>
<style>
.rotated{
-webkit-transform: rotate(-180deg);
width:400;
height:400;
}
</style>
</head>
<body>
<p class='rotated'>Rotated Text</p>
</body>
</html>
");
pdf.SaveAs("rotated.pdf");Imports IronPdf
Private renderer = New IronPdf.ChromePdfRenderer()
Private pdf = renderer.RenderHtmlAsPdf("
<html>
<head>
<style>
.rotated{
-webkit-transform: rotate(-180deg);
width:400;
height:400;
}
</style>
</head>
<body>
<p class='rotated'>Rotated Text</p>
</body>
</html>
")
pdf.SaveAs("rotated.pdf")The CSS3 transform property supports various rotation units including degrees (deg), radians (rad), gradians (grad), and turns. For PDF generation, degrees are most commonly used. You can also combine rotation with other transforms like scale and translate to achieve complex positioning effects. When using responsive CSS with IronPDF, these transforms adapt seamlessly to different page sizes and orientations.
For more advanced scenarios, you might want to explore transforming PDF pages programmatically after the initial render. This allows you to apply additional transformations to existing PDFs or combine CSS-based rotations with page-level transformations for complex document layouts.
Ready to see what else you can do? Check out our tutorial page here: Edit PDFs or explore how to create new PDFs from scratch with custom orientations. For managing different page orientations within the same document, see our guide on portrait and landscape orientation.
Frequently Asked Questions
How can I rotate PDF pages using IronPDF in C#?
You can rotate PDF pages using the IronPDF library by utilizing the `SetPageRotation`, `SetPageRotations`, or `SetAllPageRotations` methods to rotate single, multiple, or all pages in a document, respectively.
What rotation angles are supported for PDF pages in IronPDF?
IronPDF supports rotation angles of 0° (no rotation), 90°, 180°, and 270° clockwise, allowing you to adjust the orientation of entire pages within a PDF document.
Can I rotate only specific text elements in a PDF using IronPDF?
Yes, IronPDF allows you to rotate specific text elements using CSS3 transforms applied during the HTML to PDF conversion process. This method provides granular control over individual text sections.
Why would I use CSS3 transforms instead of full-page rotation in IronPDF?
CSS3 transforms offer more precise control for rotating individual elements or sections within a PDF, which is useful for creating documents with mixed orientations or when rendering vertically aligned text.
How do I apply CSS3 transforms to text when generating PDFs with IronPDF?
You can apply CSS3 transforms by using the `transform: rotate(...)` style in your HTML content. The rotation can be customized with the `transform-origin` property for precise control over the pivot point.
Can IronPDF handle rotation applied to pages with custom paper sizes?
Yes, IronPDF applies rotation after the page size is set, meaning that if you have a portrait page and rotate it 90 degrees, it becomes landscape oriented while maintaining its custom dimensions.
Is it possible to combine multiple CSS transforms for more complex text positioning?
Yes, IronPDF supports combining rotation with other CSS3 transforms like scale and translate, allowing for complex text positioning effects in the PDF output.
What are the typical use cases for rotating PDF pages using IronPDF?
Typical use cases include correcting scanned document orientations, creating landscape-oriented reports, or adjusting document layouts for specific viewing requirements.
Does IronPDF support other units for CSS3 rotation besides degrees?
Yes, CSS3 in IronPDF supports rotation units such as radians, gradians, and turns, although degrees are most commonly used for PDF generation.
How can I ensure text rotates correctly during HTML to PDF conversion with IronPDF?
To ensure correct text rotation, use CSS3 transform properties in your HTML content, and IronPDF will render the styled content as it appears in the final PDF, respecting the specified transformations.

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.