Free Support Forum - aspose.com

MailMerge.ExecuteWIthRegions multiplies text inside region


#1

Hi Aspose team,

looks like in 19.2 you’ve fixed one of the issues we had with execute with regions. The same example throws exception using 19.1. However, the fix here is not working 100% correct, as the ‘experience’ word seems to be multiplied not only inside Vehicle region, but also seems to be repeated for each Driver. Could you please take a look what is causing this?

Thanks,
Mateusz

asposeMultiply2.zip (9.3 MB)


#2

@acturisaspose

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

  • Your input Word document (MTA Docs_MD.dotx).
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • You have shared your complete project. Please create a simplified 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.


#3

Hi Tahir,

please find expected document attached, input and solution is attached to the original post. Problem is that the text inside first region is repeated for each occurence of data for second region. Please let me know if you need any more info.

ExpectedOutput.zip (13.3 KB)

Thanks,
Mateusz


#4

@acturisaspose

Thanks for your inquiry. You have shared your complete project. Please create a simplified console application that helps us to reproduce your problem on our end and attach it here for testing.

Thanks for your cooperation.


#5

Hi Tahir,

aspose.zip (89.2 KB)

I’ve cleaned this example a bit, but please note that it cannot be simplified any more. Implementation of MailMerge requires few classes to be added to the solution. It’s not our full project, it’s only a small snap with all the items required for replication. Also, I’ve been sending solutions of similar complexity before to log a number of issues related to MailMerge and MailMergeWithRegions and so far it wasn’t a problem.

This time I’ve excluded aspose library so the zip is lighter and packed the required MailMergeData implementation into regions so is should be more readable.

Thanks,
Mateusz


#6

@acturisaspose

Thanks for sharing the detail. To get the desired output, you need to modify the input document. We have attached the modified input document with this post for your kind refernece. Hope this helps you.
input 19.2.zip (13.9 KB)


#7

Hi Tahir,

thank you for looking into this. Could I please ask for some additional details why exactly this isn’t working correctly with the original input document?

I understand the solution you are proposing, however the templates are delivered by our clients and we only process them. In some cases where the template is invalid and the output will be the same after the update we can ask them to modify it. However, even if there is no other way to work around this issue, we will need a way to determine if there any other templates that may be affected.

Please note that this is closely related to the issue we already raised with your paid support - https://helpdesk.aspose.com/tickets.php?id=5654 and this is directly connected to the fix to
WORDSNET-17814
delivered in 19.1.

Many thanks for your support so far,
Mateusz


#8

@acturisaspose

Thanks for your inquiry. You are facing the expected behavior of Aspose.Words. You are getting multiple instances of text “experienced” because the table “Main” is in same paragraph and is twice. You need to modify your template document as suggested in my previous post.

There is another approach to achieve your requirement. Please put the “Main” table in separate paragraphs and call MailMerge.ExecuteWithRegions method twice as shown below. Please check the modified template document. input 19.2.zip (13.9 KB)

Hope this helps you.

document.MailMerge.ExecuteWithRegions(mergeData);
document.MailMerge.ExecuteWithRegions(mergeData);