We are printing a lot of documents created in Microsoft Word docx format. Before printing, we replace all the bookmarks by their corresponding values. This works fine in most cases except for bookmark values containing extra spaces at the end, used in combination with IF-conditions in Word Fields.
Attached I included a simple example to clarify this issue. The zip file aspose_words_test_doc.zip (74.2 KB) contains three files:
- TestAspose.java: A very simple java program which opens the document “aspose_words_test_doc.docx”, replaces the bookmarks, updates all the fields and saves the document to PDF, using the Aspose Words API.
-
aspose_words_test_doc.docx: a test document with a bookmark “weekday” and the field declaration:
IF { REF weekday } = “Monday ” “morning”
. - aspose_words_test_doc.pdf: the PDF output.
The document should print “Monday morning” for the bookmark value “Monday ” (see the extra space at the end of this bookmark value). But it is printed as “Monday” when using the Aspose Words API (see pdf document “aspose_words_test_doc.pdf”). When printing with the MSWord API it is printed as “Monday morning”.
It seems the extra spaces at the end of the bookmark value are not seen when evaluating the IF condition of the MSWord Field.
Thank you in advance for any assistance you can provide.