This article guides how to extract text from Word document with NET REST API. You will learn to automatically extract text from Word file with C# Low Code API by defining the start and end of the text you want to fetch from the loaded Word file. You can set the range parameters in various ways described in this article.
Prerequisite
- Create an account and get API credentials
- Download Aspose.Words Cloud SDK for Dotnet to extract a range of text from a Word file
- Setup C# solution project with the above SDK for saving a range to a string
Steps to Extract Specific Text from Word Document with NET REST API
- Create the WordsApi class object to extract a range of text from a Word file
- Instantiate the GetRangeTextOnlineRequest object and load the input Word file content in it
- Set the range parameters in the request object to define the start and end of the text range
- Call the GetRangeTextOnline method to extract the range of text
- Display the text from the response returned by the API call
The above steps describe the process to extract text from DOC with C# Low Code API. Commence the process by creating the WordsApi class object using the client ID and secret, and initiate the request object using the GetRangeTextOnlineRequest class. Fill in the parameters to define the range of text and use it while calling the GetRangeTextOnline() method that fetches data from the source file.
Code to Extract Text from DOCX with C# REST API
This code demonstrates how to extract text from Word document with C# REST API. The GetRangeTextOnlineRequest contains the parameters RangeStartIdentifier and RangeEndIdentifier that can be used to set the range of text that you want to fetch and save in a string variable. Use range identifiers such as page3 shows page number 3, page3:end shows the end of page 3, and document:end shows the end of the document.
This article has taught us how to define a range of text across the pages and save it in a string variable. To save a page in a Word file to an image, refer to the following article: Convert Word Page to Image with NET REST API.