HTML JPG PDF XML DOCX
  Product Family
PDF

Delete Pages from PDF via .NET SDK

API for moving page from PDF documents to new position with .NET.

Get Started

How to move page from PDF documents to new position using Cloud .NET SDK

In order to move page from PDF documents to new position via Cloud .NET SDK, 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 delete pages using .NET SDK

Aspose.PDF Cloud developers can easily load & delete pages from PDF documents in just a few lines of code.

  1. Create a new Configuration object with your Application Secret and Key.
  2. Create an object to connect to the Cloud API.
  3. Uploads the PDF to cloud storage.
  4. Move page from PDF document to new postion in cloud storage.
  5. Checks the response and logs the result.
  6. Downloads the updated file for local use.
 

This sample code shows moving page from PDF document to new postion


    using Aspose.Pdf.Cloud.Sdk.Model;

    namespace Pages
    {
        public class PagesMove
        {
            public static async Task Move(string documentName, string outputName, int pageNumber, int newPageNumber, string remoteFolder)
            {
		// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required). 
		pdfApi = new PdfApi(AppSecret, AppSid);

                using (var file = File.OpenRead(Path.Combine(localFolder, documentName)))
		{ // Upload the local PDF to cloud storage folder name.
                    FilesUploadResult uploadResponse = await pdfApi.UploadFileAsync(Path.Combine(remoteFolder, documentName), documentName);
                    Console.WriteLine(uploadResponse.Uploaded[0]);
                }

                // Move page from the PDF to new positionon in cloud storage.
                AsposeResponse response = await pdfApi.PostMovePageAsync(documentName, pageNumber, newPageNumber, folder: remoteFolder);

                // Checks the response and logs the result.
                if (response == null)
                    Console.WriteLine("PagesMove(): Unexpected error!");
                else if (response.Code < 200 || response.Code > 299)
                    Console.WriteLine("PagesMove(): Failed to move page to new postion in the document.");
                else
                { // Downloads the updated file for local use.
                    Console.WriteLine("PagesMove(): page successfully moved to new position in the document '{0}.", documentName);
                    Stream stream = pdfApi.DownloadFile(Path.Combine(remoteFolder, documentName));
                    using var fileStream = File.Create(Path.Combine(localFolder, "move_pages_" + outputName));
                    stream.Position = 0;
                    await stream.CopyToAsync(fileStream);
                    Console.WriteLine("PagesMove(): File '{0}' successfully downloaded.", "move_pages_" + outputName);
                }
            }
        }
    }