Move Pages from PDF via .NET SDK
API for moving page from PDF documents to new position with .NET.
Get StartedHow 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: PM> Install-Package Aspose.Pdf-Cloud
Steps to move pages using .NET SDK
Aspose.PDF Cloud developers can easily load & move pages from PDF documents in just a few lines of code.
- Create a new Configuration object with your Application Secret and Key.
- Create an object to connect to the Cloud API.
- Uploads the PDF to cloud storage.
- Move page from PDF document to new postion in cloud storage.
- Checks the response and logs the result.
- Downloads the updated file for local use.
This sample code shows moving page from PDF document to new postion
public static async Task MovePage()
{
const string localPdfFileName = @"C:\Samples\sample.pdf";
const string storageFileName = "sample.pdf";
const string localFolder = @"C:\Samples";
const string resultFileName = "output_move_page.pdf";
const string storageTempFolder = "YourTempFolder";
const int pageNumber = 3;
const int newPageNumber = 7;
// Get your AppSid and AppSecret https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
using var file = File.OpenRead(localPdfFileName);
var uploadResult = pdfApi.UploadFile(Path.Combine(storageTempFolder, storageFileName), file);
Console.WriteLine(uploadResult.Uploaded[0]);
AsposeResponse response = await pdfApi.PostMovePageAsync(storageFileName, pageNumber, newPageNumber, folder: storageTempFolder);
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 index in the document.");
else {
using Stream downloadStream = pdfApi.DownloadFile(Path.Combine(storageTempFolder, storageFileName));
using FileStream localStream = File.Create(Path.Combine(localFolder, resultFileName));
downloadStream.CopyTo(localStream);
Console.WriteLine("PagesMove(): page '{0}'successfully moved to new index '{1}' of the document '{2}.", pageNumber, newPageNumber, resultFileName);
}
}
- Learning Resources
- Documentation
- Source Code
- API References
- Product Support
- Free Support
- Paid Support
- Blog
- Why Aspose.PDF Cloud for .NET?
- Customers List
- Security