DocumentAppendDocument(Document, ImportFormatMode, ImportFormatOptions) Method

Appends the specified document to the end of this document.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.10.0


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 manage list style clashes while appending a 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".
// Change the text color for one of the styles to set it apart from the other.
dstDoc.Styles["CustomStyle"].Font.Color = Color.DarkRed;

// If there is a clash of list styles, apply the list format of the source document.
ImportFormatOptions options = new ImportFormatOptions();
options.KeepSourceNumbering = true;

// Joining two documents that have different styles that share the same name causes a style clash.
// We can specify an import format mode while appending documents to resolve this clash.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepDifferentStyles, options);

dstDoc.Save(ArtifactsDir + "DocumentBuilder.AppendDocumentAndResolveStyles.docx");

ExpandedSee Also