Insert Paragraph in Word with NET REST API

This article guides on how to insert paragraph in Word with NET REST API. You will learn how to insert automatic paragraph in Word with C# REST API using the .NET cloud SDK. This article shares a sample code and steps for writing the application.

Prerequisite

Steps to Insert a New Paragraph in Word with C# Low Code API

  1. Instantiate the configuration object and declare a WordsApi object with it
  2. Read the source Word file into a byte array for adding a paragraph
  3. Create an object of the ParagraphInsert class and set the new text
  4. Instantiate the InsertParagraphOnlineRequest object by providing the input document, paragraph data, and position
  5. Invoke the InsertParagraphOnline() method with the above request object to insert the paragraph
  6. Save the output file from the stream returned by the API

These steps summarize how to insert a paragraph in Word with C# Low Code API. Create a Configuration object using the client ID and secret, instantiate the WordsApi object, read the input file into a byte array, and create a ParagraphInsert object for setting the text of the new paragraph. Initialize the InsertParagraphOnlineRequest() object and use it in the InsertParagraphOnline() method to insert the paragraph.

Code to Insert Paragraph with C# REST API

This sample code has demonstrated how to insert automatic paragraph in Word. Define the destination file name using the DestFileName property in the InsertParagraphOnlineRequest object for retrieving the output from the API response. You may use other options also such as load encoding, password, revision author name and date, and index using the insertBeforeNode property.

This article has taught us to insert a paragraph in a Word file. If you want to set the formatting of an existing paragraph, refer to the following article: Set paragraph formatting in Word with NET REST API.