Importing

Document element instances from one document instance cannot be inserted to another document instance. They must first be imported to another document, and then the imported elements can be inserted.

Following example shows how to import a document element into another document.

Importing Screenshot
Upload your file (Drag file here)
using GemBox.Document;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        DocumentModel document = DocumentModel.Load("%InputFileName%");

        DocumentModel sourceDocument = DocumentModel.Load("%#Reading.docx%", LoadOptions.DocxDefault);

        // Reuse same mapping for importing all sections to improve performance.
        var mapping = new ImportMapping(sourceDocument, document, false);

        // Import all sections from source document.
        foreach (Section sourceSection in sourceDocument.Sections)
        {
            Section destinationSection = document.Import(sourceSection, true, mapping);
            document.Sections.Add(destinationSection);
        }

        document.Save("Importing.%OutputFileType%");
    }
}
Imports GemBox.Document

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Dim document As DocumentModel = DocumentModel.Load("%InputFileName%")

        Dim sourceDocument As DocumentModel = DocumentModel.Load("%#Reading.docx%", LoadOptions.DocxDefault)

        ' Reuse same mapping for importing all sections to improve performance.
        Dim mapping = New ImportMapping(sourceDocument, document, False)

        ' Import all sections from source document.
        For Each sourceSection As Section In sourceDocument.Sections
            Dim destinationSection As Section = document.Import(sourceSection, True, mapping)
            document.Sections.Add(destinationSection)
        Next

        document.Save("Importing.%OutputFileType%")

    End Sub

End Module

Check next example or download examples from GitHub.