This guide shows how to Java developers can use Aspose.Words for Java Cloud SDK to add or update properties of a Word (DOCX) document via the REST API. You’ll learn to create a new custom property or modify an existing built‑in or custom property by specifying its name and the new value.
Prerequisite
- Create an account and get API credentials
- Download the Aspose.Words Cloud SDK for Java to work with Word document properties
- Set up a Java project and add the SDK as a dependency
Steps to Edit Document Properties in Word with Java REST API
- Set the Client ID and Client Secret for the API to modify Word properties.
- Instantiate the WordsApi class using the client credentials.
- Load the source Word file into a memory stream for property manipulation.
- Create a DocumentPropertyCreateOrUpdate object and assign the desired property value.
- Build a CreateOrUpdateDocumentPropertyOnlineRequest object, specifying the property name and value.
- Invoke the CreateOrUpdateDocumentPropertyOnline method to add or update the property.
- Save the resulting Word file, which now contains the updated property value.
The steps above outline the complete workflow for modifying document properties with the Java REST API. Begin by creating a WordsApi instance, load the source document into a stream, define the new property using DocumentPropertyCreateOrUpdate, construct the request object, and finally call CreateOrUpdateDocumentPropertyOnline to apply the changes.
Code to Edit the Document Properties with Java Low Code API
This sample demonstrates working with Microsoft Word properties using the Java Low Code API. When constructing the CreateOrUpdateDocumentPropertyOnlineRequest, the destFileName parameter defines the name of the output file stored in the cloud. After the property is processed, download the file using the same name to save it locally.
We have now covered how to edit document properties with the Java Low Code API. To learn how to read comments from a Word file, see the article: Read Comments in Word Document with Java REST API.
Keywords: word document property with Java Low Code API; change properties of word document with NET REST API; microsoft word properties with Java Low Code API; modify document properties with Java REST API; edit document properties with Java Low Code API.