In this short guide, you will get a brief description of how to edit Word document metadata in Java. It explains the required configuration in the IDE, a programming logic through detailed steps, and a runnable sample code to develop a DOCX metadata editor in Java. Different types of custom and built-in properties are demonstrated for a clear understanding of this feature.
Steps to Change Properties of Word Document in Java
- Set the environment to use Aspose.Words for Java to edit the document properties
- Load the target Word file where properties are to be modified
- Access the collection of custom properties and check if the desired property is available or not
- Set new values of the custom properties
- Access and update the built-in properties
- Save the resultant Word file with updated properties
By adhering to these steps, you can edit Word metadata in Java. This process is commenced by loading the source Word file, accessing the custom properties, and then modifying them as per the requirements. In the next steps, the built-in properties are accessed and updated accordingly before saving the resultant Word file.
Code to Edit Document Properties in Word in Java
You have explored the process to edit Word document metadata in Java through this coded snippet. The getCustomDocumentProperties() method in the Document class provides the collection of custom properties for editing where individual properties can be accessed by using the get() method. Similarly, the getBuiltInDocumentProperties() method provides access to the built-in properties for modification.
This article has directed us to access and modify the Word metadata. If you want to convert a Word file to a markdown file, refer to the article on how to convert Word to markdown using Java.