XDoc.PDF
Features
Tech Specs
How-to C#
How-to VB.NET
Pricing
C# PDF: How to HTML5 Viewer & Editor PDF Create PDF Export File and Page Process PDF Read PDF Write Form Process Document Protect Annotation & Drawing PDF Print WPF Viewer & Editor Work with Other SDKs Barcode Read Barcode Create OCR Twain
Page: Rotate a PDF Page
  |  
Home ›› XDoc.PDF ›› C# PDF: Rotate PDF Page

How to rotate PDF page orientations using XDoc.PDF for .NET library in C#, asp.net, winforms, azure


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




Best .NET PDF SDK supports PDF page rotation in Visual Studio .NET and C# programming language


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 certain PDF page, 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.





C# Rotate a PDF Page and save to a new pdf file


Note: When you get the error "Could not load file or assembly 'RasterEdge.Imaging.Basic' or any other assembly or one of its dependencies. An attempt to load a program with an incorrect format", please check your configure as follows:

       

       If you are using x64 libraries/dlls, Right click the project -> Properties -> Build -> Platform target: x64.

       

       If using x86, the platform target should be x86.




        #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);
        }
        #endregion




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);
        }
        #endregion




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);
        }
        #endregion




.NET Class Namespace Required



In order to run the sample code, the following steps would be necessary.


Add necessary references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.Imaging.Basic.Codec.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XImage.Raster.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XDoc.PDF.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.PDF;





public static int RotatePage(String inputFilePath, int pageIndex, int rotateInDegree, String outputFilePath)

Description:
     Rotate the page with specified degree and save it to a new PDF file.

Parameters:

Return:
     Error code, 0 if success.



public static int RotatePage(String inputFilePath, int pageIndex, int rotateInDegree)

Description:
     Rotate the page with specified degree and override the original PDF file.

Parameters:

Return:
     Error code, 0 if success.



public static int RotateAllPages(String inputFilePath, int rotateInDegree, String outputFilePath)

Description:
     Rotate all the pages with specified degree and save it to a new PDF file.

Parameters:

Return:
     Error code, 0 if success.



public static int RotateAllPages(String inputFilePath, int rotateInDegree)

Description:
     Rotate all the pages with specified degree and override the original PDF file.

Parameters:

Return:
     Error code, 0 if success.