# Rotate PDF pages in C#

> Rotate one page or every page of a PDF in .NET by a multiple of 90 degrees, without rewriting the page content. MIT licensed, pure C#.

Available since 1.0.

Turn pages clockwise by 90, 180 or 270 degrees.

## Short answer

Call `Rotate` on a page with a multiple of 90. The rotation adds to the page's current one and
viewers apply it when they display the page; the content itself is not rewritten. `Rotation` reads
the result: 0, 90, 180 or 270.

```csharp title="recipe-rotate-pdf-pages.cs"
#:package PdfNetStack@1.2.0
using PdfNetStack;

PdfDocument doc = PdfDocument.Open("report.pdf");
doc.Pages[0].Rotate(90);                      // clockwise, a multiple of 90
foreach (PdfPage page in doc.Pages.Skip(1))
{
    page.Rotate(180);
}
doc.Save("report-rotated.pdf");
Console.WriteLine(string.Join(", ", doc.Pages.Select(p => p.Rotation)));
```

```bash
dotnet add package PdfNetStack
```

## Related

- [Edit pages](https://www.jadev-corp.com/guides/edit-pages/)
- [Command line](https://www.jadev-corp.com/cli/): `pdfnetstack rotate in.pdf out.pdf 90 2-4`
- API: [PdfPage](https://www.jadev-corp.com/api/pdfnetstack/pdfpage/)

Source: https://www.jadev-corp.com/pdfnetstack/recipes/rotate-pdf-pages/
