DocumentAppendDocument(Document, ImportFormatMode) 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


Type: Aspose.WordsDocument
The document to append.
Type: Aspose.WordsImportFormatMode
Specifies how to merge style formatting that clashes.


Shows how to append a document to the end of another document.
Document srcDoc = new Document();
srcDoc.FirstSection.Body.AppendParagraph("Source document text. ");

Document dstDoc = new Document();
dstDoc.FirstSection.Body.AppendParagraph("Destination document text. ");

// Append the source document to the destination document while preserving its formatting,
// then save the source document to the local file system.
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

dstDoc.Save(ArtifactsDir + "Document.AppendDocument.docx");
Shows how to append all the documents in a folder to the end of a template document.
Document dstDoc = new Document();

DocumentBuilder builder = new DocumentBuilder(dstDoc);
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
builder.Writeln("Template Document");
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.Writeln("Some content here");

// Append all unencrypted documents with the .doc extension
// from our local file system directory to the base document.
foreach (string fileName in Directory.GetFiles(MyDir, "*.doc"))
    FileFormatInfo info = FileFormatUtil.DetectFileFormat(fileName);
    if (info.IsEncrypted)

    Document srcDoc = new Document(fileName);
    dstDoc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles);

dstDoc.Save(ArtifactsDir + "Document.AppendAllDocumentsInFolder.doc");

ExpandedSee Also