Rotate PDF pages in C#
Turn pages clockwise by 90, 180 or 270 degrees.
Short answer
Section titled “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.
#:package PdfNetStack@1.2.0using PdfNetStack;
PdfDocument doc = PdfDocument.Open("report.pdf");doc.Pages[0].Rotate(90); // clockwise, a multiple of 90foreach (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)));dotnet add package PdfNetStackRelated
Section titled “Related”- Edit pages
- Command line:
pdfnetstack rotate in.pdf out.pdf 90 2-4 - API: PdfPage