DocumentAppendDocument Method (Document, ImportFormatMode, ImportFormatOptions)

Appends the specified document to the end of this document.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.2
public void AppendDocument(
	Document srcDoc,
	ImportFormatMode importFormatMode,
	ImportFormatOptions importFormatOptions


Type: Aspose.WordsDocument
The document to append.
Type: Aspose.WordsImportFormatMode
Specifies how to merge style formatting that clashes.
Type: Aspose.WordsImportFormatOptions
Allows to specify options that affect formatting of a result document.
Shows how to resolve styles behavior while append document.
// Open a document with text in a custom style and clone it
Document srcDoc = new Document(MyDir + "Custom list numbering.docx");
Document dstDoc = srcDoc.Clone();

// We now have two documents, each with an identical style named "CustomStyle" 
// We can change the text color of one of the styles
dstDoc.Styles["CustomStyle"].Font.Color = Color.DarkRed;

ImportFormatOptions options = new ImportFormatOptions();
// Specify that if numbering clashes in source and destination documents
// then a numbering from the source document will be used
options.KeepSourceNumbering = true;

// If we join two documents which have different styles that share the same name,
// we can resolve the style clash with an ImportFormatMode
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepDifferentStyles, options);

dstDoc.Save(ArtifactsDir + "DocumentBuilder.ResolveStyleBehaviorWhileAppendDocument.docx");
See Also