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

Free Support Forum - aspose.com

Cleanup removes placeholder but leaves empty line

Hi,
I am using Aspose word version 16.7.0

My issue is after mailmerge , the placeholders inside dataTable leaves empty line if there is no data for it. For example:
«TableStart:person»
«NAME»
«ADDRESSLINE1»
«ADDRESSLINE2»
«CITY», «STATE» «ZIP_CODE»«ZIP_CODE_EXT»
«TableEnd:person»

gets mailmerged PDF as

John Doe
1100 Laxinton St

Denver,IA 95666


There is a noticeable line break in the place of ADDRESSLINE2 when it has no data.


My code looks something like this:

DataSet ds = new DataSet();
ds.readXml(getXml));
doc.getMailMerge().setFieldMergingCallback((IFieldMergingCallback) new HandleMergeField());
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS
| MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS
| MailMergeCleanupOptions.REMOVE_STATIC_FIELDS
| MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS
| MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS);
doc.getMailMerge().execute(ds.getTables().get("Order")); // this is for another order section
doc.getMailMerge().executeWithRegions(ds);
doc.save(getMergedWordFilePath());

Please suggest , how to get rid of the empty line left.

Thanks

Hi there,


Thanks for your inquiry. We have tested the scenario by setting REMOVE_EMPTY_PARAGRAPHS CleanupOptions with a sample document using Aspose.Words for Java 17.5. We are unable to notice the reported issue. Please download and try latest version of Aspose.Words for Java, it will resolve the issue.

However, if the issue persists then please share your sample input document along with working code (without compilation error). We will try to replicate the issue at our end and will guide you accordingly.

Best Regards,

I tried with 17.5 version . It doesn’t help though.

I have included simplest form of my code,template and data xml file with generated pdf , which displays the “empty line” issue.
Please suggest.

Thanks

Hi there,


Thanks for sharing your source documents. Please note the PERSON_ADDRESSLINE2 filed in the template contains line break character instead of paragraph break, it is causing the issue. Please replace it with paragraph break, it will resolve the issue.

Best Regards,