MailmergeCleanupOptions.RemoveEmptyParagraphs Empty Bookmark removed before IF fields are evaluated

Performing mailmerge on Microsoft Word document (docX)
It looks like MailmergeCleanupOptions.RemoveEmptyParagraphs removes Empty Bookmark content before IF fields are evaluated when performing a Mailmerge.

Why is that? - it does not seem to be the case when using mailmerge in Microsoft Word.
We have a document with a bookmark that contains a MergeField - this mergefield can be filled with some non empty value or an empty string during mailmerge. When testing on the value of the bookmark with IF fields later in the document, the test does not work as expected because the bookmark does not contain any data. So for example: {IF Bookmarkname = “” “Empty” “Not Empty”} results in “Not Empty” even though the Bookmark would have contained “” (ie. an empy string).

@StenBille

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

I think that it would be overdoing things i bit. It is very simple:

When performing a Mailmerge.Execute with the MailmergeCleanupOptions.RemoveEmptyParagraphs set to true, the mailmerge will remove empty paragraphs before IF field are evaluated thereby failing to test on the value “”

This is not the case when using Microsoft Word to do the Mailmerge. So why do Aspose implement this behavior? Or is there a way to make it behave differently?

I will upload a simple document with a bookmark containing a Mergefield and an IF field testing the bookmark for the value “” (ie. empty string).
in the document “DocumentWithBookmark.docx”

I think it will be very easy for you to test :smile:

But I will also upload my Result merge seen in the document “ResultingMergeWithBookmarkRemoveEmpty-636978241928419227.Docx”
TwoDocuments.zip (19.9 KB)

@StenBille

We have logged this problem in our issue tracking system as WORDSNET-18821. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

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