This article describes how to add page numbers in PDF using C# REST API. You will learn to automatically insert a page number in PDF using C# Low Code API with the help of a .NET-based Cloud SDK. It shares details to customize the page number stamp by using the exposed properties of the library.
Prerequisite
- Create an account API credentials to add page numbers in PDF
- Download Aspose.PDF Cloud SDK for Dotnet for inserting page numbers
- Setup a C# project with the above SDK
Steps to Add Page No to PDF using C# REST Interface
- Initialize the PdfApi client with ClientKey and ClientId
- Set the inputPdf and outputPdf file names for use in the application
- Read and upload the input PDF file to the Cloud storage
- Configure PageNumberStamp with margins, alignment, and starting number
- Call the PostDocumentPageNumberStamps() method to apply numbering to all pages
- Download the updated PDF with page numbers and save it as a PDF
These steps summarize how to insert Page No in PDF using C# RESTful Service. Upload the source PDF file to the Cloud storage, create a pageNumberStamp object and set the parameters of the stamp, and call the PostDocumentPageNumberStamps() method to insert Page Number on all the pages. Finally, if no error is raised, download the updated PDF file in the Cloud and save on the disk.
Code to Insert Page Number in PDF using C# .NET-based API
This code demonstrates the process to add Page No in PDF using C# Low Code API. You can set other stamp properties, such as opacity, rotate the page number stamp, and adjust other indentation parameters. The rotation enum supports 0, 90, 180, and 270 degrees.
This article has guided us to add page numbers in an existing PDF file. To convert file format from GIF to PDF, refer to the article Convert GIF to PDF using C# REST API.