Add a Page Number in Word with NET REST API

This article describes how to add a page number in Word with NET REST API. You will learn how to put page number on Word with C# REST API by using Aspose.Words for .NET Cloud SDK. Various options are available for setting the page numbering properties like its format, placement, alignment, starting page number, and other flags.

Prerequisite

Steps for Numbering Pages in Word with C# Low Code API

  1. Initialize the WordsApi object by setting the cloned ID and secret to add page numbers
  2. Read the input Word file into the memory stream for numbering the pages
  3. CrCreate the PageNumber object and set the desired properties such as alignment, format, starting page number, etc.
  4. Create the InsertPageNumbersOnlineRequest object by providing the input file, request object, and output file name
  5. Call the InsertPageNumbersOnline to add page numbers to the input word file
  6. Retrieve the output file from the response and save it on the disk

The above steps define how to add page no in Word with C# Low Code API. Commence the process by creating the WordsApi object and creating the PageNumber object to set the parameters for the page numbering. Finally, create the InsertPageNumbersOnlineRequest object and use it in the InsertPageNumbersOnline() method to insert page numbers in the input Word file.

Code to Add Page Numbers to Word Document with C# REST API

This sample code exhibits how to insert page number on Word with NET REST API. The PageNumber class contains various parameters and most of them are mandatory to set, therefore, you may set all the properties to avoid exceptions. The output file name is helpful while getting the output file from the response object returned by the API call.

In this topic, we have learned the process of adding page numbers in an existing Word file. If you are looking to insert a footnote in a Word file, refer to the following article: Insert Footnote in Word with NET REST API.

 English