import com.aspose.words.*; public class Main { public static void main(String[] args) throws Exception // Update Word Metadata in Java { // Set the licenses new com.aspose.words.License().setLicense("Aspose.Total.lic"); // Load the document Document doc = new Document("SampleProps.docx"); // Access the properties CustomDocumentProperties custProps = doc.getCustomDocumentProperties(); // Check the desired property if (custProps.get("Reviewed") != null) { // Set new properties custProps.get("Reviewed By").setValue("Mart"); custProps.get("Reviewed Date").setValue(new java.util.Date()); } // Access the properties BuiltInDocumentProperties documentProperties = doc.getBuiltInDocumentProperties(); // Update the properties documentProperties.get("Pages").setValue(doc.getPageCount()); documentProperties.get("Comments").setValue("Document Comments"); documentProperties.get("Title").setValue("Document Title"); // Save the output file doc.save("Output.docx"); System.out.println("Done"); } }