Skip to main content
A newer version of this page is available. .

Get Started - Load and Edit a PDF File

  • 4 minutes to read

Important

You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use these examples in production code. Refer to the DevExpress Subscription page for pricing information.

Perform the following steps to get started with the non-visual PDF processing component:

  1. Run Microsoft Visual Studio and create a new Console Application (.NET Framework) project.

  2. Right-click References in the Solution Explorer and select Add Reference… in the invoked context menu.

    pdf-doc-processor-add-reference

  3. Add references to the following libraries:

    • DevExpress.Data.v19.2;
    • DevExpress.Docs.v19.2;
    • DevExpress.Pdf.v19.2.Core;
    • DevExpress.Pdf.v19.2.Drawing.
  4. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    Note

    A complete sample project is available at https://github.com/DevExpress-Examples/how-to-rotate-pdf-pages-t114305

    using DevExpress.Pdf;
    
    namespace PdfPageRotationExample
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
                {
                    pdfDocumentProcessor.LoadDocument("..\\..\\docs\\TextRotate.pdf");
                    int angle = 0;
                    foreach (PdfPage page in pdfDocumentProcessor.Document.Pages) {
                        angle = (angle + 90) % 360;
                        page.Rotate = angle;
                    }
                    pdfDocumentProcessor.SaveDocument("..\\..\\docs\\Rotated.pdf");
                }
            }
        }
    }
    
  5. Run the project. After executing the code above, the pages are rotated and the new document is saved to the specified location.

pdf-doc-processor-rotate

  1. Run Microsoft Visual Studio and create a new Console Application (.NET Core) project.

  2. Install the DevExpress.Document.Processor NuGet package.

  3. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.Pdf;
    
    namespace PdfPageRotationExample
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
                {
                    pdfDocumentProcessor.LoadDocument("..\\..\\docs\\TextRotate.pdf");
                    int angle = 0;
                    foreach (PdfPage page in pdfDocumentProcessor.Document.Pages) {
                        angle = (angle + 90) % 360;
                        page.Rotate = angle;
                    }
                    pdfDocumentProcessor.SaveDocument("..\\..\\docs\\Rotated.pdf");
                }
            }
        }
    }
    
  4. Run the project. After executing the code above, the pages are rotated and the new document is saved to the specified location.

pdf-doc-processor-rotate

  1. Run Microsoft Visual Studio and create a new Console Application (.NET Core) project.

  2. Install the DevExpress.WindowsDesktop.Document.Processor NuGet package.

  3. Right-click the project in the Solution Explorer and select Edit Project File.

    Office_NetCore_3_Edit_Project_File

    Change the project’s SDK attribute to Microsoft.NET.Sdk.WindowsDesktop and set the UseWindowsForms option to true.

    <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
    
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>netcoreapp3.0</TargetFramework>
        <UseWindowsForms>true</UseWindowsForms>
      </PropertyGroup>
    </Project>
    
  4. Paste the code below in the Main method of the Program.cs file (Main procedure of the Module1.vb file for Visual Basic).

    using DevExpress.Pdf;
    
    namespace PdfPageRotationExample
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
                {
                    pdfDocumentProcessor.LoadDocument("..\\..\\docs\\TextRotate.pdf");
                    int angle = 0;
                    foreach (PdfPage page in pdfDocumentProcessor.Document.Pages) {
                        angle = (angle + 90) % 360;
                        page.Rotate = angle;
                    }
                    pdfDocumentProcessor.SaveDocument("..\\..\\docs\\Rotated.pdf");
                }
            }
        }
    }
    
  5. Run the project. After executing the code above, the pages are rotated and the new document is saved to the specified location.

pdf-doc-processor-rotate

See Also