Thanks to visit codestin.com
Credit goes to docs.devexpress.com

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 and .NET Framework.

Create a .NET 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 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;
    using System.Diagnostics;
    
    using (PdfDocumentProcessor pdfProcessor = new PdfDocumentProcessor()) {
    
        // Load the source PDF document
        pdfProcessor.LoadDocument(@"C:\Test Documents\Document.pdf");
        int angle = 0;
    
        // Rotate each page in the document by 90 degrees more than the previous page
        foreach (PdfPage page in pdfProcessor.Document.Pages) {
            angle = (angle + 90) % 360;
            page.Rotate = angle;
        }
        // Save the rotated PDF document to the output path
        pdfProcessor.SaveDocument(@"C:\Test Documents\Document_Rotated.pdf");
    }
    Process.Start(new ProcessStartInfo(@"C:\Test Documents\Document_Rotated.pdf") { UseShellExecute = true });
    
  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 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.v25.1.dll
    • DevExpress.Docs.v25.1.dll
    • DevExpress.Drawing.v25.1.dll
    • DevExpress.Office.v25.1.Core.dll
    • DevExpress.Pdf.v25.1.Core.dll
    • DevExpress.Pdf.v25.1.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;
    using System.Diagnostics;
    
    using (PdfDocumentProcessor pdfProcessor = new PdfDocumentProcessor())
    {
        // Load the source PDF document
        pdfProcessor.LoadDocument("..\\..\\docs\\TextRotate.pdf");
        int angle = 0;
    
        // Rotate each page in the document by 90 degrees more than the previous page
        foreach (PdfPage page in pdfProcessor.Document.Pages) {
            angle = (angle + 90) % 360;
            page.Rotate = angle;
        }
     }
        // Save the rotated PDF document to the output path
        pdfProcessor.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