C#: Online Guide
How To: Word SDK
File: Merge Word Files
File: Merge Word Files
  |  
Home ›› XDoc.Word ›› C# Word: Merge Word Files

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


Provide C# Demo Codes for Merging and Appending Word Document




Overview



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.


Related .net document control helps:
asp.net excel file viewer: ASP.NET Excel Document Viewer in C# Control: view office excel files online in ASP.NET web applications
asp.net redact pdf control: ASP.NET Redact PDF Document Control: redact, remove PDF text, images in web browser using C# ASP.NET
asp.net edit pdf text control: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net convert pdf control: ASP.NET Convert PDF Control: Convert, export PDF to Word, HTML, Tiff files in C# ASP.NET
asp.net text file viewer: C# HTML5 Viewer: Load, View, Convert, Annotate and Edit OpenOffice, CSV and Text file
asp.net edit pdf image control: ASP.NET PDF Image Edit Control: online insert, edit PDF images in C#
asp.net open pdf password control: ASP.NET PDF Password Edit Control: online add, remove, update PDF file open password using C#


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.




C# DLLs: Merge Word File



Add references:


  RasterEdge.Imaging.Basic.dll


  RasterEdge.XDoc.Office.Inner.Common.dll


  RasterEdge.Imaging.Drawing.dll


  RasterEdge.Imaging.Processing.dll


  RasterEdge.XDoc.Office.Inner.Office03.dll


  RasterEdge.Imaging.Font.dll


  RasterEdge.XDoc.Word.dll


  RasterEdge.XImage.Raster.Core.dll


  RasterEdge.XImage.Raster.dll


Use corresponding namespaces;


  using RasterEdge.Imaging.Basic;


  using RasterEdge.XDoc.Word;




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);