HTML JPG PDF XML DOCX
  Product Family
PDF

Rotate PDF in .NET SDK

API for rotate pages in PDF document using .NET.

Get Started

How to rotate PDF via Cloud .NET SDK

To rotate PDF documents, we’ll use Aspose.PDF Cloud .NET SDK This Cloud SDK allows you to easily build cloud-based PDF creator, editor & converter apps in C#, ASP.NET, or other .NET languages for various cloud platforms. Open NuGet package manager, search for Aspose.PDF Cloud and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


    PM> Install-Package Aspose.Pdf-Cloud
     

Steps to Rotate PDF using .NET SDK

Aspose.PDF Cloud developers can easily load & Rotate PDF in just a few lines of code.

  1. Upload the PDF to the cloud.
  2. Set Parameters for Page Rotation.
  3. Rotate the specified pages using the desired angle.
  4. Download the modified PDF.
 

Rotate PDF using .NET Cloud SDK


    public static async Task RotatePages()
    {
        const string localPdfFileName = @"C:\Samples\sample.pdf";
        const string storageFileName = "sample.pdf";
        const string localFolder = @"C:\Samples";
        const string resultFileName = "output_rotate.pdf";
        const string storageTempFolder = "YourTempFolder";
        const string rotationPages = "1, 3 - 5, 8";
    
        // Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required). 
        pdfApi = new PdfApi(AppSecret, AppSid);
    
        using var file = File.OpenRead(localPdfFileName);
        await pdfApi.UploadFileAsync(Path.Combine(storageTempFolder, storageFileName), file);
    
        AsposeResponse response = await pdfApi.PostDocumentPagesRotateAsync(storageFileName, Rotation.On90.ToString(), rotationPages, folder: storageTempFolder);
        if (response.Code != 200)
            Console.WriteLine("RotatePages(): Unexpected error!");
        else {
            using Stream downloadStream = pdfApi.DownloadFile(Path.Combine(storageTempFolder, storageFileName));
            using FileStream localStream = File.Create(Path.Combine(localFolder, resultFileName));
            downloadStream.CopyTo(localStream);
            Console.WriteLine("RotatePages(): Pages '{0}' successfully rotated!", rotationPages);
        } 
    }