DocumentBuilderInsertDocument Method (Document, ImportFormatMode)
Inserts a document at the cursor position.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.10
Syntax
public Node InsertDocument(
	Document srcDoc,
	ImportFormatMode importFormatMode
)

Parameters

srcDoc
Type: Aspose.WordsDocument
Source document for inserting.
importFormatMode
Type: Aspose.WordsImportFormatMode
Specifies how to merge style formatting that clashes.

Return Value

Type: Node
First node of the inserted content.
Remarks
This method mimics the MS Word behavior, as if CTRL+'A' (select all content) was pressed, then CTRL+'C' (copy selected into the buffer) inside one document and then CTRL+'V' (insert content from the buffer) inside another document.
Examples
Shows how to insert a document content into another document keep formatting of inserted document.
[C#]

Document doc = new Document(MyDir + "Document.docx");

DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
builder.InsertBreak(BreakType.PageBreak);

Document docToInsert = new Document(MyDir + "DocumentBuilder.KeepSourceFormatting.docx");

builder.InsertDocument(docToInsert, ImportFormatMode.KeepSourceFormatting);
builder.Document.Save(ArtifactsDir + "DocumentBuilder.InsertDocument.docx");
See Also