This short tutorial guides how to delete pages from PDF document with C# REST API. You will get the details to remove pages of a PDF with C# REST Interface using the .NET-based Cloud SDK without using any third-party tool. Options will be discussed to delete multiple pages from the PDF if required.
Prerequisite
- Create an account API credentials
- Download Aspose.PDF Cloud SDK for Dotnet
- Setup C# project with the above SDK for deleting pages
Steps to Remove Pages from PDF Document with C# Low Code API
- Instantiate the PdfApi class object by setting the client ID and secret for deleting a page
- Load the source PDF file into a memory stream to remove pages
- Upload the file in the memory stream to the Cloud storage
- Call the DeletePage() method by providing the page number and uploaded PDF file name
- Save the output PDF file using the API response
These steps describe how to remove a page in PDF with C# REST API. Upload the source PDF file to a Cloud storage using the memory stream and assign it a name. Call the DeletePage() method by providing the uploaded file reference and target page number that you want to delete using the page index starting from 1.
Code to Eliminate PDF Pages with C# RESTful Service
The above sample code demonstrates how to delete the pages in PDF with C# .NET-based API. While uploading a PDF file, a name is assigned to it that is used by the DeletePage() method, and pages are deleted in the PDF file in the Cloud Storage. Once you complete deleting the single or multiple pages by iterating the process, you can download the updated file from the cloud storage and save it on the disk.
This article has taught us how to remove pages of a PDF with C# REST Interface. If you want to count words in a PDF file, refer to the following article: Count words in PDF document with C# REST API.