I'm creating a word doc with multiple tables that each come from a different mail merge template, but I can't get rid of the white space between them

Hello!

I am trying to create a single document by combining multiple mail merge templates together. However, when I add a new section to the main document, it also adds white space between the two sections. Do you have any idea how I might remove that white space.

mainDoc = new Document(template1);
mainBuilder = new DocumentBuilder(mainDoc);
mainDoc.MailMerge.ExecuteWithRegions(CreateDeepCopy(mainSource));

secondDoc = new Document(template2);

mainBuilder.MoveToDocumentEnd();
mainBuilder.InsertDocument(secondDoc , ImportFormatMode.UseDestinationStyles);

No matter what I seem to try, I can’t remove the white space between mainDoc and secondDoc.

@bweiss444 A table cannot be the only or the last node in MS Word document. There is always a paragraph at the end of the document. In your case when you move document builder to the end of the document, you move it to the empty paragraph at the end of the document, the content of the sub document is inserted right after this empty paragraph.
You can remove empty paragraph after tables in your document using code like the following:

Document doc = new Document(@"C:\Temp\in.docx");

NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);
foreach (Table table in tables)
{
    Paragraph nextParagraph = table.NextSibling as Paragraph;
    while (nextParagraph != null && !nextParagraph.HasChildNodes)
    {
        nextParagraph.Remove();
        nextParagraph = table.NextSibling as Paragraph;
    }
}

doc.Save(@"C:\Temp\out.docx");

But you should note that there must be a paragraph between tables in MS Word documents. If there is no paragraph between tables, they are concatenated into one table.

Thank you for the help. This is exactly what I needed.