Mail Merge incorporating IF and section breaks not behaving as desired

We have a template (template_with_sections.dot) that includes a MERGEFIELD, an IF statement and a section break such that the two sections have different page settings. The IF then controls whether to insert the section break. The MERGEFIELD is used in the condition of the IF.

The template_with_sections.dot has the following combination of IF, MERGEFIELD and sections.

{ IF { MERGEFIELD First_Page_Orientation} = "L" "Landscape SECTION BREAK" ""}

Portrait

The template should behave in the following way. If being merged with data whose First_Page_Orientation is ‘L’ then the first page should appear in landscape with the text “Landscape” and all remain pages should be Portrait. If First_Page_Orientation is any other letter, say ‘P’ then we expect all pages to be portrait with text “Portrait”.

We previously would perform the mail merge using word directly via its api in a visual basic script. When executing the mail merge via this script the produced document ended up as described above and shown in the attachment expected_output.docx.

When run via Aspose.Words using the following code (this is not the actual code but in terms of the aspose usage it is the same, the customDataSource basically holds the contents of example_data.txt)

final Document template = new Document( new FileInputStream("template_with_sections.dot") );
template.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS |
MaiMergeCleanupOptions.REMOVE_UNUSED_REGIONS |
MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS);
template.getMailMerge().execute(customDataSource);
final FileOutputStream outputStream = new
FileOutputStream(new File(actual_output.doc));
template.save( outputStream, SaveFormat.DOC);

When using Aspose.Words to merge the same template with a data file that contains a First_Page_Orientation of L then it produces a document as expected (first page should appear in landscape with the text “Landscape” and all remain pages should be Protrait). However, when merging with a data file that contains P for the First_Page_Orientation it produces a document like actual_output.doc (a document where the first page is landscape but has the text Portrait).

How can I get Aspose to have the same behaviour as the old vbs script manipulating word directly?

I hope this makes sense and any advice would be much appreciated.

Note: We are using Aspose.Words 13.8.

Hi Stuart,

Thanks for your inquiry. I tested the scenario and have managed to reproduce the same problem on my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-9166. Our development team will further look into the details of this problem and we will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Thanks for the reply and raising the issue. Is there an update as to how long it will take to resolve?

I would like to add that we are using the Java version of Aspose.WORDS, although it may also be an issue in the .NET version as well.

Thanks

Hi,

Thanks for your inquiry. Unfortunately, this issue is not resolved yet. This issue is more complex than we initially estimated. I have verified the status of your issue from our issue tracking system and regret to share with you that this issue has been postponed till a later date. We will notify you via this thread as soon as your issue is resolved. We apologize for your inconvenience.

Secondly, yes your understanding is correct i.e. the issue is reproducible with Aspose.Words for .NET also. The latest version of Aspose.Words for Java is completely auto-ported from .NET, i.e. we do not write code for Aspose.Words for Java; it is generated out automatically from C# code of Aspose.Words for .NET. In your case, the issue, that was previously logged with WORDSNET prefix, would be auto resolved for Java variant of Aspose.Words as well. Your problem will be fixed as soon as the linked issue is resolved.

Best regards,

Hi,

I’m looking for an update on this issue (WORDSNET-9166) and also whether there is any time frame for when I could expect it to be resolved.

Thanks

Hi Stuart,

Thanks for your inquiry. Unfortunately, this issue is not resolved yet. The fix to this issue may definitely come onto the product roadmap in the future but unfortunately at the moment we cannot provide you any reliable estimate. We will inform you via this thread as soon as this issue is resolved. We apologize for your inconvenience.

Best regards,