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
- Create an account and get API credentials
- Download Aspose.Words Cloud SDK for Dotnet to add a paragraph in a Word file
- Setup C# solution project with the above SDK for inserting paragraphs at a specified position
Steps to Insert a New Paragraph in Word with C# Low Code API
- Instantiate the configuration object and declare a WordsApi object with it
- Read the source Word file into a byte array for adding a paragraph
- Create an object of the ParagraphInsert class and set the new text
- Instantiate the InsertParagraphOnlineRequest object by providing the input document, paragraph data, and position
- Invoke the InsertParagraphOnline() method with the above request object to insert the paragraph
- 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.