We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Evaluation of IF-condition in Word Field does not allow spaces at the end of a bookmark value

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:

  1. 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.
  2. aspose_words_test_doc.docx: a test document with a bookmark “weekday” and the field declaration:
    IF { REF weekday } = “Monday ” “morning”.
  3. 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.


Thanks for your inquiry. We have tested the scenario and noticed the reported issue. We have logged a ticket WORDSNET-15606 in our issue tracking system for further investigation and rectification. We will notify you as soon as it is resolved.

We are sorry for the inconvenience.

Best Regards,


The issues you have found earlier (filed as WORDSNET-15606) have been fixed in this Aspose.Words for .NET 17.8 update and this Aspose.Words for Java 17.8 update.