XDoc.Word
Features
Tech Specs
How-to C#
Pricing

C# Word Library
C# Word - Merge Word Documents in C#.NET


Provide C# Demo Codes for Merging and Appending Word Document





RasterEdge C#.NET Word document merging toolkit (XDoc.Word) is designed to help .NET developers combine Word document files created by different users to one Word file. Thus, C#.NET Word document merge library control can be counted as an efficient .NET doc solution for keeping Word document files organized.

This C# .NET Word document merging control is written in managed C# code and compatible with all .NET developing platforms, like ASP.NET web application and Windows Forms project. Using this Word document concatenating library SDK, C# developers can easily merge and append one Word document to another Word document file, and choose to create a new Word file in .NET class application.

Besides C#.NET Word document merging function, XDoc.Word, a professional third-party .NET document imaging toolkit, also offers other advanced Word document page processing and manipulating functions, such as Word page insertion, Word page deleting, Word document splitting, Word page reordering and Word page image and text extraction. Remarkably, all those C#.NET Word document page processing functions can be implemented independently, without using any Adobe-related software.

Our .NET Word SDK empowers C# programmers to easily merge and append Word files with mature APIs. To be more specific, two or more input Word documents can be merged and appended together according to its loading sequence, and then saved and output as a single Word with user-defined location.


Combine and Merge Multiple Word Files into One Using C#



This part illustrates how to combine three Word files into a new file in C# application. You may also combine more Word documents together.

String inputFilePath1 = Program.RootPath + "\\" + "1.docx";
String inputFilePath2 = Program.RootPath + "\\" + "2.docx";
String inputFilePath3 = Program.RootPath + "\\" + "3.docx";
String outputFilePath = Program.RootPath + "\\" + "Output.docx";
String[] inputFilePaths = new String[3] { inputFilePath1, inputFilePath2, inputFilePath3 };

// Combine three Word files and output.
DOCXDocument.CombineDocument(inputFilePaths, outputFilePath);


Append Word Document in C#



In addition, C# users can append a Word file to the end of a current Word document and combine to a single Word file.

//  get DOCXDocument object from one file
String inputFilePath1 = Program.RootPath + "\\" + "1.docx";
DOCXDocument doc1 = new DOCXDocument(inputFilePath1);
//  get DOCXDocument object from another file
String inputFilePath2 = Program.RootPath + "\\" + "2.docx";
DOCXDocument doc2 = new DOCXDocument(inputFilePath2);

//  append the 2nd document
doc1.AppendDocument(doc2);

//  save the document
String outputFilePath = Program.RootPath + "\\" + "Output.docx";
doc1.Save(outputFilePath);