How to Start Tutorials Troubleshooting Main Operations Convert PDF Read PDF Edit PDF PDF Report Generator Work with PDF Modules PDF Document PDF Pages Text Image Graph & Path Annotation, Markup & Drawing Redaction Security Digital Signature Forms Watermark Bookmark Link File Attachment File Metadata Printing Work with Other SDKs Barcode read Barcode create OCR Twain

C# PDF Page Rotation Library
How to rotate PDF document pages orientations permanently using C# in, Windows apps

Empower C# Users to Change the Rotation Angle of PDF File Page Using C# Programming Language in .NET Application. Free Online Trial Download.

In this C# tutorial, you will learn how to rotate PDF document pages orientation (portrait and landscape) programmatically in C#

  • Rotate a PDF page
  • Rotate all pages in PDF document

How to rotate PDF pages programmatically in C#

  1. Download XDoc.PDF Pages Editor C# library
  2. Install C# library to rotate PDF pages programmatically
  3. Step by Step Tutorial

  • Best C#.NET PDF SDK supports PDF page rotation in Visual Studio .NET and C# programming language
  • C#.NET Core library also includes how to add header in pdf using in c#, how to crop pdf page and save as image in c#, c# change pdf page size, c# pdf add background, add pages to pdf c#.
  • Free .NET evaluation library for rotating PDF page in both .NET WinForms and ASP.NET application
  • Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
  • Online C# class source codes enable the ability to rotate single specified page or entire pages permanently in PDF file in .NET framework project
  • Able to rotate page in PDF document to 90,180,270 degree in both clockwise and anticlockwise
  • Enable individual page or batch pages orientation changing without other PDF reader control
  • Support to overwrite PDF and save rotation changes to original PDF file
  • Easy to preview rotated PDF pages using our sample applications
  • Able to save to another PDF file after rotating PDF pages

C#.NET PDF page rotator library control, RasterEdge XDoc.PDF, is a 100% clean .NET solution for C# developers to permanently rotate PDF document page and save rotated PDF document back or as a new file. This PDF page rotating control toolkit automates the process of rotating individual PDF document page to desired degree angle using C# .NET code.

Using this C# .NET PDF rotate page control SDK, you can easily select any page from a multi-page PDF document file, rotate selected PDF page to special orientation and save rotated PDF file accordingly. Thus, this C# .NET PDF library can help developers achieve permanent PDF page rotation in any .NET class applications.

RasterEdge PDF page rotating SDK is, in essence, a multi-functional PDF page processing utility. Besides the functionality to rotate PDF document page, it is also featured with the functions to merge PDF files using C# .NET, add new PDF page, delete existing PDF pages, reorder existing PDF pages and split PDF document in both Windows and ASP.NET web applications.

There are three rotation angles supported by XDoc.PDF, which include 90, 180, and 270 in clockwise. And C# users may choose to only rotate a single page of PDF file or all the pages. See C# programming demos below.

How to rotate a PDF Page orientation permanently using C#

You can easily rotate a PDF page in C#. Below are the steps and C# sample code to rotate a page in a PDF document.

  • Select the page index to rotate (0 is the first page)
  • Choose the rotation angle (Rotate 180 in clockwise)
  • Call method PDFDocument.RotatePage to apply the page rotation

        #region rotate one page and save to a new pdf file
        internal static void rotateOnePageAndSaveToNewFile()
            String inputFilePath = @"C:\1.pdf";
            String outputFilePath = @"C:\Output.pdf";

            // Specify the first page to be rotated.
            int pageIndex = 0;

            // Rotate 180 in clockwise.
            int rotateInDegree = 180;

            // Rotate the selected page.
            PDFDocument.RotatePage(inputFilePath, pageIndex, rotateInDegree, outputFilePath);

C# Rotate a PDF Page and overwrite the original pdf file

        #region rotate all pages and save to a new pdf file
        internal static void rotateAllPageAndSaveToNewFile()
            String inputFilePath = @"C:\1.pdf";
            String outputFilePath = @"C:\Output.pdf";

            // Rotate 180 in clockwise.
            int rotateInDegree = 180;

            // Rotate all PDF pages.
            PDFDocument.RotateAllPages(inputFilePath, rotateInDegree, outputFilePath);

C# Rotate All PDF Pages and overwrite the original pdf file

        #region Rotate All PDF Pages and overwrite the original pdf file
        internal static void rotateAllPageAndOverwriteOriginalFile()
            String inputFilePath = @"C:\1.pdf";

            // Rotate 90 in clockwise.
            int rotateInDegree = 180;

            // Rotate all PDF pages.
            PDFDocument.RotateAllPages(inputFilePath, rotateInDegree);

How to read, get PDF page rotation angle in C#

Call method PDFPage.GetRotation() to get a PDF page rotation angle in C# class. The valid page rotation angles are 0, 90, 180, 270.

The C# source code below shows how to read and get a PDF page current rotation angle.

            String inputFilePath = @"C:\1.pdf";

            PDFDocument doc = new PDFDocument(inputFilePath);

            // Get the first page object
            PDFPage aPage = (PDFPage)doc.GetPage(0);

            float pageRotationAngle = aPage.GetRotation();

            Console.WriteLine("Page rotation angle: " + pageRotationAngle);