Free Support Forum -

CustomDocumentProperties Cannot Be Resolved or It Is Not a Field

I have the import com.aspose.words.* in my Java class and successfully created an instance of the Document; but I soon ran into a syntax error. This is a code snippet:

Document wordMeasurementSummaryReport = new Document(); // no problem

wordMeasurementSummaryReport.removeAllChildren(); // no problem

Date now = new Date(); // no problem

wordMeasurementSummaryReport.CustomDocumentProperties.Add( "Creation Date", now );

The fourth line (right above) gives a syntax error:

wordMeasurementSummaryReport.CustomDocumentProperties cannot be resolved or is not a field. What is wrong with that statement?

You just need to use getCustomDocumentProperties instead. Please refer to API reference if you have any syntax problems. For example in this case you can check the Document class description:

Best regards,

I have followed your recommendation and modified my Aspose Words statement in my Java class accordingly; however, I am still getting the same syntax error: wordMeasurementSummaryReport.getCustomDomumentProperties cannot be resolved or is not a field.

wordMeasurementSummaryReport.getCustomDocumentProperties.Add( "Creation Date", now );


getCustomDocumentProperties is a method so you should call it with parentheses, i.e. getCustomDocumentProperties().