How to split a PDF file into separate page PDF files in C# .NET Framework
2 min readFeb 21, 2020
Splitting PDFs into individual pages is such a hassle to implement in the traditional way. That’s why we are going to show you how to use and API to do it for you instead.
Open up the console of Package manager and run this command to install the API client.
Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0
Now invoke SplitDocumentPdfByPage:
using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class SplitDocumentPdfByPageExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new SplitDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.var returnDocumentContents = true; // bool? | Set to true to directly return all of the document contents in the DocumentContents field; set to false to return contents as temporary URLs (more efficient for large operations). Default is false. (optional)try{// Split a PDF file into separate PDF files, one per pageSplitPdfResult result = apiInstance.SplitDocumentPdfByPage(inputFile, returnDocumentContents);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling SplitDocumentApi.SplitDocumentPdfByPage: " + e.Message );}}}}
And that’s it. The API will proceed to split up the PDF into individual pages.