In this short tutorial, you will learn how to count pages in PDF without opening using C# REST API. You will learn to automatically count pages in multiple PDF files with C# REST Interface by parsing all the files in a folder and using the given sample code for each file. It supports counting the pages by filtering items in the returned List object using different properties of each page.
Prerequisite
- Create an account API credentials
- Download Aspose.PDF Cloud SDK for Dotnet
- Setup C# project with the above SDK
Steps for PDF Page Counter Software with C# REST Interface
- Set the PdfApi object using a client ID and the secret to analyze the pages
- Read all the bytes of the PDF file and save it in a memory stream
- Upload the PDF file to the Cloud storage using the UploadFile() method by setting the name and bytes stream
- Call the GetPages() method that returns the DocumentPagesResponse object
- Check the status and response list object validity
- Display the count of the pages in the list
These steps describe how to develop an online PDF page counter with C# .NET-based API. Load the PDF file into a memory stream and upload to the Cloud storage. Call the GetPages() for the uploaded file and display the count of list items in the response object.
Code for Adobe PDF Page Counter with C# RESTful Service
This code has demonstrated how to count PDF pages in a folder with C# Low Code API by iterating all the PDF files one by one. You can count the specific pages based on each page’s properties exposed by the Page class. The response can be discarded if the status is not ok or the list object is null.
This article has taught us to count the PDF file file pages without opening it in any software. Another relevant feature can be found in the article Count words in PDF document with C# REST API.