Skip to main content

Get Started - Load and Edit a PDF File

  • 3 minutes to read

Important

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

This article describes how to get started with the non-visual PDF processing component for .NET Framework and .NET Core.

Create a .NET Framework Application

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

  2. Install the DevExpress.Document.Processor NuGet package or add references to the following libraries (if you have the DevExpress Unified Component Installer installed on your machine):

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

    View Example

    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

Create a .NET Core Application

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 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

See Also