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

Free Support Forum - aspose.com

Mail Merging with IF unused space problem

Hi,

I’m using mailmerging with xml and on the template i use an IF surrounding a table

{ IF{{issue.title}} <> null " ->hier goes table " \* MERGEFORMAT}

It works ok, but even if i use all cleanup options, the blank line of IF statement end MERGEFORMAT statement remain on the generated pdf

How is it possible to clena this unused lines ?

Please see attached file

thanks

Hi Simone,

Thanks for your inquiry. In your case, I suggest you please use DataSet.readXml as shown in following code example instead of XmlMailMergeDataSet. Hope this helps you. I have attached the output documents with this post for your kind reference. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "merging.rtf");
doc.getMailMerge().setUseNonMergeFields(**true**);
// Cleanup options
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS | MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS | MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS | MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS);
DataSet ds = new DataSet();
ds.readXml(MyDir + "in.xml");
doc.getMailMerge().executeWithRegions(ds);
doc.save(MyDir + "Out.docx");
doc.save(MyDir + "Out.pdf");

Hi Tahir, maybe i haven’t explained my self well.

The problem is on the generated file: the blank lines of IF
statement end MERGEFORMAT statement remain on the generated pdf and are not deleted. I’m expection to have a generated file without this blank lines.

Thanks

Hi Simone,

Thanks for sharing the detail. I have tested the scenario and have managed to reproduce the same issue at my side. For the sake of correction, I have logged this problem in our issue tracking system as WORDSNET-12543. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Has it been solved in 15.10.0 ?? thanks

Hi Simone,

Thanks
for your inquiry. We have asked for the ETA of this issue from our
product team. As soon as any information is shared by them, we will be
more than happy to share that with you.

Thanks for your patience.

Hi Simone,

Thanks for your patience.

It is to inform you that our product team has completed the work on this issue (WORDSNET-12543) and has come to a conclusion that this issue and the undesired behavior you’re observing is actually not a bug in Aspose.Words. So, we have closed this issue as ‘Not a Bug’. We are quoting developer’s comments here for your reference.

The RemoveEmptyParagraphs option is applied before the RemoveContainingFields option. Aspose.Words does not remove mentioned paragraphs, because they are not empty at RemoveEmptyParagraphs stage, before RemoveContainingFields stage. Cleanup should be performed in this order to make documents merged with and without the RemoveContainingFields option look equally.

We suggest you following workaround :

Please use nested region instead of IF field. Modified sample document is attached (merging_modified.rtf). There are output documents, populated with different data sources:

Docx (‘with issue table.docx’) is generated from following data source.

<iscrizionePdf>
  <identity>
     <name>Simone</name>
     <id>123</id>
  </identity>
  <issue>
     <title>xxxx</title>
     <descr>description…</descr>
  </issue>
  <test>ABC</test>
</iscrizionePdf>

Docx (‘without issue table.docx’) is generated from following data source.

<iscrizionePdf>
  <identity>
     <name>Simone</name>
     <id>123</id>
  </identity>
  <test>ABC</test>
</iscrizionePdf>