Inserting Document does not retain columns

hi,
I am inserting a document into parent document (including headers). During the insert process the columns of the child document are lost. The code is posted below and I have attached the Parent and Child documents.
Can you please help.

private void RunInsert()
{
    String dirname = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
    Aspose.Words.Document dstDoc = new Aspose.Words.Document(dirname + @"\Parent Document.docx");
    Aspose.Words.Document srcDoc = new Aspose.Words.Document(dirname + @"\Columns.docx");
    DocumentInsertHeaders(dstDoc, srcDoc, "InsertLocation");
    String fsavename = dirname + @"\OutPut.docx";
    dstDoc.Save(fsavename);
    System.Diagnostics.Process.Start(fsavename);
}
public Document DocumentInsertHeaders(Document dstDoc, Document srcDoc, String InsLocation)
{
    // Create DocumentBuilder so we can modify the document.
    DocumentBuilder builder = new DocumentBuilder(dstDoc);
    string[] fldNames = dstDoc.MailMerge.GetFieldNames();
    foreach(string fldName in fldNames)
    {
        if (fldName == InsLocation)
        {
            builder.MoveToMergeField(InsLocation);
            Section sectA = null;
            // Insert empty section
            builder.InsertBreak(BreakType.SectionBreakNewPage);
            sectA = builder.CurrentSection;
            foreach(Section sectB in srcDoc.Sections)
            {
                int sectBIndex = srcDoc.Sections.IndexOf(sectB);
                // Content
                sectA.PrependContent(sectB);
                // Loop throught all Headers/Footers in the B document
                foreach(HeaderFooter hfB in sectB.HeadersFooters)
                {
                    // Check whether current section from docA conteins
                    // Header/Footer with the same type as h/f from docB
                    if (sectA.HeadersFooters[hfB.HeaderFooterType] != null)
                    {
                        // Append content from h/f B to h/f A
                        foreach(Node childB in hfB.ChildNodes)
                        {
                            // Import node
                            Node childA = dstDoc.ImportNode(childB, true, ImportFormatMode.KeepSourceFormatting);
                            // Appent node to h/f
                            sectA.HeadersFooters[hfB.HeaderFooterType].AppendChild(childA);
                        }
                    }
                    else
                    {
                        // Copy whole h/f
                        Node hfA = dstDoc.ImportNode(hfB, true, ImportFormatMode.KeepSourceFormatting);
                        // Insert h/f
                        sectA.HeadersFooters.Add(hfA);
                    }
                }
            }
        }
    }
    return dstDoc;
}

Hi

Thanks for your inquiry. The problem occurs, because information about text columns is stored in the section, but in your code, you do not copy whole sections, you just copy content of the section, so section properties are lost. I modified your code to copy whole sections:

public Document DocumentInsertHeaders(Document dstDoc, Document srcDoc, String InsLocation)
{
    // Create DocumentBuilder so we can modify the document.
    DocumentBuilder builder = new DocumentBuilder(dstDoc);
    string[] fldNames = dstDoc.MailMerge.GetFieldNames();
    foreach(string fldName in fldNames)
    {
        if (fldName == InsLocation)
        {
            builder.MoveToMergeField(InsLocation);
            // Insert section break
            builder.InsertBreak(BreakType.SectionBreakContinuous);
            Section sectA = builder.CurrentSection;
            // Unlink header and footers.
            sectA.HeadersFooters.LinkToPrevious(false);
            foreach(Section sectB in srcDoc.Sections)
            {
                // Import whole section into the destination document.
                Node dstSection = dstDoc.ImportNode(sectB, true, ImportFormatMode.KeepSourceFormatting);
                // Insert section.
                sectA.ParentNode.InsertBefore(dstSection, sectA);
            }
        }
    }
    return dstDoc;
}

Hope this helps.
Best regards.