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

Free Support Forum - aspose.com

Mail Merge fails when the tablestart starts in one section and tableend in another section

We are getting the following exception
Exception–>java.lang.IllegalStateException: Mail merge region ‘mLeter’ is badly formed. TableStart and TableEnd should be in the same section, same table row or same table cell.
Please find attached 6883464.doc

Thanks for your request. TableStart and TableEnd are placed in different section. As workaround you can use Page Break instead Section Break. Please see the attached document.
Best regards.

We cannot remove the sections and insert page breaks manually as there are hundreds of templates already present.
Is there a way to programmatically find the section breaks and remove it using Aspose.Words library?(At this point of time we are not sure if the section break needs to be replaced with page break).
If you provide us java code snippet to remove section breaks it would be great.

Thanks for your request. You can try using the following code.

// Open document document
Document doc = new Document("6883464.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
while (doc.getSections().get(1) != null)
    // Move cursor to last paragraph of the first section
    // Insert Page break
    // Append content of the second section 
    // Remove second section
// Save output document

I hope this could help you.
Best regards.