Syncfusion Feedback

Trusted by the world’s leading companies

Syncfusion Trusted Companies

Overview

The Syncfusion .NET Word Library (DocIO) provides powerful and comprehensive APIs to merge multiple Word documents into a single document. With just a few lines of code, you can streamline the process without relying on Microsoft Word or interop dependencies.

Merge Word documents using C#

This example code shows how to merge Word documents using the Syncfusion .NET Word Library with just few lines of code in C#.

using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
//Open source document stream
using (FileStream sourceStream = new FileStream("SourceDocument.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
    //Load source Word document
    using (WordDocument sourceDocument = new WordDocument(sourceStream, FormatType.Automatic))
    {
        //Open destination document stream
        using (FileStream destinationStream = new FileStream("DestinationDocument.docx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
        {
            //Load destination Word document
            using (WordDocument destinationDocument = new WordDocument(destinationStream, FormatType.Docx))
            {
                //Import the contents of the source document at the end of the destination document
                destinationDocument.ImportContent(sourceDocument, ImportOptions.UseDestinationStyles);
                //Create output file stream
                using (FileStream outputFileStream = new FileStream("Result.docx", FileMode.Create, FileAccess.ReadWrite))
                {
                    // Save the Word document to the output file stream
                    destinationDocument.Save(outputFileStream, FormatType.Docx);
                }
            }
        }
    }
}

Key features of merging Word documents

Merge with source formatting

Merges the contents from multiple Word documents, retaining the original formatting in the merged document.

Merge with destination formatting

Merges the contents from Word documents and applies the formatting of one of them, designated the destination document.

Merge with numbering restart options

Merges the contents from Word documents and either restarts or continues the list numbering.

Merge text only

Merges only the text from multiple Word documents without keeping the formatting, headers, or footers.

Word document merging references

Discover resources from our knowledge base that enhance your efficiency in merging Word documents in C#:

Merge a Word document with destination document margins in C#

Knowledge base

How to merge a Word document with destination document margins in C#

Remove section breaks when merging Word documents in C#

Knowledge base

How to remove section breaks when merging Word documents in C#

Merge multiple Word documents and retain the destination document’s header and footer in C#

Knowledge base

Merge Word documents and generate a TOC in C#

Knowledge base

How to merge Word documents and generate a TOC in C#

Merge multiple Word documents on the same page in a Word document using C#

Knowledge base

How to merge multiple Word documents on the same page in a Word document using C#

Merge two Word documents without retaining header and footer from the source document in C#

Knowledge base

Syncfusion .NET Word Library Resources

Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.

Frequently Asked Questions

Word file formats such as DOC, DOT, DOCX, DOTX, DOCM, DOTM, as well as Word Processing 2007 XML, Word 2003 XML Document, and other formats such as HTML, text, and Markdown are supported.

Yes, you can merge specific sections from multiple Word documents into a single Word document.

Yes, you can merge multiple Word documents and save the merged document as a PDF, images, or HTML using the .NET Word Library.

Yes, you can automate the merging of a batch of Word documents in C# using the .NET Word Library.

Yes, you can merge documents with various options such as retaining source formatting, applying destination styles and merging text only.

You can access it through the Syncfusion.DocIO.Net.Core NuGet package. Detailed code samples are available in the documentation.

Our Customers Love Us

Having an excellent set of tools and a great support team, Syncfusion® reduces customers’ development time.
Here are some of their experiences.

Rated by users across the globe

Want to create, View, and edit Word documents in C# or VB.NET?

Start a free 30-day evaluation today!
DOWNLOAD FREE TRIAL

No credit card required.

Mobile Free Evaluation Section

Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.

Scroll up icon