I attached my word template to this post.
I am trying to display customer address from xml input file. If i am getting empty string for ADDRESS_LINE2 merge field, i am seeing empty row in address. So how can i remove the empty row in result docuemnt.
I tried below option , but did not workout.
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS);
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS);
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS);
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS);
doc.getMailMerge().deleteFields();
Thanks.
Hi Prashanth,
Thanks for your inquiry.
Please use the MailMerge.setCleanupOptions method as shown below to get the required output.
Hope this helps
you. Please let us know if you have any more queries.
Document doc = new Document(MyDir
doc.getMailMerge().setCleanupOptions(MailMergeCleanupOptions.REMOVE_EMPTY_PARAGRAPHS
| MailMergeCleanupOptions.REMOVE_UNUSED_FIELDS
| MailMergeCleanupOptions.REMOVE_CONTAINING_FIELDS
| MailMergeCleanupOptions.REMOVE_UNUSED_REGIONS);
doc.getMailMerge().execute(new String[] { ..... }, new Object[] { ..... });
doc.save(MyDir + “Out.doc”);
Thanks for your quick reply.
The solution which you provided it works for me.
But may I know what is difference for those two approaches.
Thanks,