Add Bookmark in Word with NET REST API

This article entails the process to add bookmark in Word with NET REST API. We will use Aspose.Words for .NET Cloud SDK to add bookmark to Word document with C# Low Code API. You will set various bookmark parameters and invoke API calls to add this bookmark to your Word file on the local disk.

Prerequisite

Steps to Create Bookmark in Word with NET REST API

  1. Set Client ID and Client Secret for the API to add a bookmark
  2. Instantiate an object of the WordsApi class with your client credentials
  3. Read the source Word file into the memory stream for creating a bookmark
  4. Define the start and end range of the bookmark using the PositionInsideNode class
  5. Create the InsertBookmarkOnlineRequest object by providing the required parameters
  6. Call the InsertBookmarkOnline method to insert a bookmark according to the InsertBookmarkOnlineRequest
  7. Save the resultant Word file with the new bookmark

The aforementioned steps describe how to create a bookmark in Word with C# Low Code API. Commence the process by creating a WordsApi object followed by reading the source Word file and defining the bookmark parameters. Finally, add this bookmark to your Word file by calling a few API calls followed by saving the resultant Word file on the local disk.

Code to Insert a Bookmark in Word with C# REST API

This sample code exhibits how to add bookmark in Word with C# REST API. The PositionInsideNode class is used to set the start and end range of the bookmark in the destination Word file. The resultant stream is returned as a dictionary item with the specified key and can be retrieved using the TryGetValue method as demonstrated in the sample code.

In this topic, we have learned how to make a bookmark in Word with C# REST API. If you are looking to convert a Word file to an HTML file, refer to the article on Convert DOCX to HTML with NET REST API.

 English