Merge DOCX

How to merge DOCX files in C#

GroupDocs.Merger allows developers to merge DOCX files when it’s needed to organize multiple DOCX files into single document or send fewer attachments etc. And you can do this without¬†any third-party software or manual work involved. With GroupDocs.Merger it is possible to combine DOCX documents of any size and structure - all text, images, tables, graphs, forms and other content will be preserved.

The following example demonstrates how to merge DOCX files with several lines of C# code:

  • Create an instance of Merger class and pass source DOCX file path as a constructor parameter. You may specify absolute or relative file path as per your requirements.
  • Add another DOCX file to merge with Join method. Repeat this step for other DOCX documents you want to merge.
  • Call Merger class Save method and specify the filename for the merged DOCX file as parameter.
// Load the source DOCX file
using (Merger merger = new Merger(@"c:\sample1.docx"))
{
    // Add another DOCX file to merge
    merger.Join(@"c:\sample2.docx");
    // Merge DOCX files ans save result
    merger.Save(@"c:\merged.docx");
}

About DOCX File Format

Docx is well-known format for Microsoft Word documents. Introduced from 2007 with the release of Microsoft Office 2007, the structure of this new Document format was changed from plain binary to a combination of XML and binary files. Docx files can be opened with Word 2007 and lateral versions but not with the earlier versions of MS Word which support DOC file extensions.

Code Examples

Please find more use-cases and complete C# sources of our backend and frontend examples and try them for free!

Merge DOCX Live Demo

GroupDocs.Merger for .NET provides an online DOCX Merger App, which allows you to try it for free and check its quality and accuracy.

“Merge DOCX”