Cómo rotar texto en PDFs usando C# | IronPDF

Rotate PDF Text and Pages in .NET

This article was translated from English: Does it need improvement?
Translated
View the article in English

Rotating PDF text or pages refers to changing the orientation of either the entire page or specific text elements within a PDF document. This rotation can be carried out in degrees (typically 90, 180, or 270 degrees) to reposition content either clockwise or counterclockwise.

Quickstart: Rotate PDF Pages in .NET with IronPDF

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 your 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.

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("input.pdf")
      .SetAllPageRotations(IronPdf.PdfPageRotation.Clockwise90)
      .SaveAs("rotated.pdf");
  3. Deploy to test on your live environment

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


Rotate PDF Pages

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 is set to the desired degree, the methods would not affect the output file.

:path=/static-assets/pdf/content-code-examples/how-to/rotating-text-set-page-rotation.cs
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")
$vbLabelText   $csharpLabel

Use CSS3 to Rotate Text

After converting HTML to PDF in .NET, there might be a need to programmatically rotate text or entire pages. A frequent requirement is to render vertically aligned text in PDFs using HTML5 and CSS3. Here’s how you can achieve this.

CSS3 allows text rotation to any angle after converting a PDF to HTML 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.

:path=/static-assets/pdf/content-code-examples/how-to/rotating-text-css.cs
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")
$vbLabelText   $csharpLabel

Ready to see what else you can do? Check out our tutorial page here: Edit PDFs

Preguntas Frecuentes

¿Cómo puedo girar un archivo PDF en C#?

Puede girar un archivo PDF en C# usando la biblioteca IronPDF. Primero, descargue IronPDF desde NuGet y use métodos como SetPageRotation para especificar la rotación deseada para las páginas PDF programáticamente.

¿Qué métodos están disponibles para rotar páginas PDF?

IronPDF proporciona métodos como SetPageRotation, SetPageRotations y SetAllPageRotations. Estos métodos le permiten girar una sola página, múltiples páginas o todas las páginas especificando el grado de rotación.

¿Se puede usar CSS3 para girar texto en un PDF?

Sí, después de convertir HTML a PDF usando IronPDF, puede aplicar estilos CSS3 como transform: rotate(...) para girar elementos de texto dentro del PDF a cualquier ángulo deseado.

¿Cómo guardo un PDF rotado en C#?

Después de aplicar rotaciones a su PDF usando IronPDF, puede guardar el PDF modificado usando el método SaveAs, especificando el nombre de archivo deseado para el PDF rotado.

¿Por qué usar HTML5 y CSS3 para la rotación de texto en PDFs?

HTML5 y CSS3 proporcionan control preciso sobre la rotación de texto en PDFs. Al convertir HTML a PDF con IronPDF, puede aplicar rotaciones de CSS3 como transform: rotate(...) para lograr orientaciones y diseños de texto personalizados.

¿Es posible rotar solo elementos de texto específicos en un PDF?

Sí, IronPDF le permite rotar elementos de texto específicos dentro de un PDF al usar estilos CSS3 durante la conversión de HTML a PDF, permitiendo un control preciso sobre la orientación individual del texto.

¿Qué opciones de grado están disponibles para rotar páginas PDF?

Las páginas PDF pueden girarse en grados como 90, 180 o 270. Estas opciones le permiten reposicionar el contenido ya sea en el sentido de las agujas del reloj o en sentido contrario usando IronPDF.

¿Cómo puedo girar múltiples páginas en un documento PDF?

Use el método SetPageRotations de IronPDF para girar múltiples páginas dentro de un documento PDF especificando el grado de rotación deseado para cada página.

¿IronPDF es totalmente compatible con .NET 10 al rotar texto y páginas?

Sí, IronPDF es totalmente compatible con .NET 10. Los desarrolladores pueden usar todas las funciones de rotación (como SetPageRotation , SetPageRotations , SetAllPageRotations y la rotación de texto basada en CSS3) en proyectos .NET 10 sin necesidad de soluciones alternativas especiales.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 16,154,058 | Versión: 2025.11 recién lanzado