Hi,
we are using the latest version of Aspose.Words for Java. It seems we have found a bug with handling REF fields when saving a dotm based template as doc file.
Test files:
Test Templates.zip (20.9 KB)
Background:
We use the SET and REF fields to display data. The value is set in the SET field and displayed in the REF field.
If the field is used in Word without a function specification, this is interpreted in Word as a REF field.
In the attached test files “UpdateSetRef.dotm” and “UpdateSetRef.dot” we have two REF outputs, one with REF and one without specification:
{ REF FIRMA }
{ FIRMA }
If the document template is now saved as a document, the expected result is that the value from the SET field is used as output for both REF fields:
Result:
Test
Test
Problem:
The following combinations lead to the following result
- ok - expected result: Document template dot - Save as doc
- ok - expected result: Document template dot - Save as docm
- ok - expected result: Document template dotm - Save as docm
- fail - not expected result: Document template dotm - Save as doc
In the last variant (document template dotm - save as doc) the second REF field is apparently defect. It can no longer be updated even in Word. It is probably no longer identified as a REF field.
Example code for reproducing the scanario:
String path = "C:\\Test\\";
String simpleFileName = "Test UpdateSetRef";
Document docDotm = new Document(path + simpleFileName + ".dotm");
docDotm.updateFields();
docDotm.save(path + simpleFileName + " dotm.docm");
docDotm.save(path + simpleFileName + " dotm.doc");
docDotm.cleanup();
Document docDot = new Document(path + simpleFileName + ".dot");
docDot.updateFields();
docDot.save(path + simpleFileName + " dot.docm");
docDot.save(path + simpleFileName + " dot.doc");
docDot.cleanup();
Note:
- In Version 19.11 this works fine
Is there any possibility in coding to avoid this result.
Kind regards
Matthias