How to use Cleanup options for multiple regions using Java

Hello,

document.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS);
document.getMailMerge().executeWithRegions(new MyDataSource("Table1"));
document.getMailMerge().executeWithRegions(new MyDataSource("Table2"));

When using the code above we noticed that option REMOVE_UNUSED_REGIONS is applied right after the first executing for "Table1". So "Table2" is completely removed and will not be rendered.

How is it possible to combine REMOVE_UNUSED_REGIONS and multiple data tables for a document?

Best regards, Evgeniy

Hi Evgeniy,

Thanks for your query. The MailMergeCleanupOptions.RemoveUnusedRegions flag will remove any region in the document which is not found in the current data source.

If you are merging data from many data sources by using separate calls to MailMerge.ExecuteWithRegions then you need to make sure that this flag is only enabled with the very last merge. Otherwise all unused regions will be removed from the document before they can be merged.

doc.getMailMerge().executeWithRegions(table1);

doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS);

doc.getMailMerge().executeWithRegions(table2);

Hi Tahir,

Thanks a lot!

Best regards, Evgeniy