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

Free Support Forum - aspose.com

Cleanup removes placeholder but leaves empty line

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:

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();
doc.getMailMerge().setFieldMergingCallback((IFieldMergingCallback) new HandleMergeField());
| 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

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


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.


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,