PNG
JPG
BMP
TIFF
PDF
Split PDF in .NET SDK
Split Single PDF Pages in C# Cloud API without the use of any software like Adobe PDF.
Get StartedHow to Split Single PDF Files Using C# Cloud API
In order to split PDF files 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.
Command
PM> Install-Package Aspose.Pdf-Cloud
Steps for Splitting PDF via Cloud .NET SDK
A basic merging pdfs programmatically with Aspose.PDF Cloud .NET SDK APIs can be done with just few lines of code.
- Create a new Configuration object with your Application Secret and Key
- Create an object to connect to the Cloud API
- Upload your document file
- Perform the splitting
- Download the result
System Requirements
It is easy to get started with Aspose.PDF Cloud .NET SDK and there is nothing to install. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud .NET SDK.
- .NET Framework 2.0 or later
- JSON.NET
Split Single PDF File using C#
public static void SplitSinglePages()
{
const string localImageFileName = @"C:\Samples\Sample-Document-01.pdf";
const string storageFileName = "Sample-Document-01.pdf";
// Get your AppSid and AppSecret from https://dashboard.aspose.cloud (free registration required).
var pdfApi = new PdfApi(AppSecret, AppSid);
if (pdfApi.GetFilesList("").Value.All(f => f.Name != storageFileName))
{
using var file = File.OpenRead(localImageFileName);
var uploadResult = pdfApi.UploadFile(storageFileName, file);
Console.WriteLine(uploadResult.Uploaded[0]);
}
var response = pdfApi.PostSplitDocument(storageFileName);
uint index = 1;
foreach (var fileName in response.Result.Documents.Select(document=>document.Href))
{
pdfApi.DownloadFile(fileName)
.CopyTo(File.OpenWrite($"page{index++}.pdf"));
}
}