We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Concat word documents

Hi, I want to know what is the best way to concat:


1. x number of word documents in only one word document.
2. x number of excel, pdf and word documents in one word document

Thank you
Hi Mauricio,

Thanks for your inquiry.
mega15:
1. x number of word documents in only one word document.
You can merge MS Word documents by using Document.AppendDocument method. Please read following documentation links for your kind reference

Appending Documents Overview
Join a Document onto another Document
How the AppendDocument Method Works
Differences between ImportFormat Modes
How to Insert a Document into another Document

Please check the following code snippet for your kind reference.

// The document that the content will be appended to.

Document dstDoc = new Document(MyDir + "Document.doc");

// The document to append.

Document srcDoc = new Document(MyDir + "DocumentBuilder.doc");

// Append the source document to the destination document.

// Pass format mode to retain the original formatting of the source document when importing it.

dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting);

// Save the document.

dstDoc.Save(MyDir + "Document.AppendDocument Out.doc");


mega15:
2. x number of excel, pdf and word documents in one word document
Please note that you can not load Excel and Pdf file in Aspose.Words DOM. First you need to convert Excel and Pdf file into Doc/Docx file format and then use Aspose.Words to join MS Word documents.

Excel to Word file format conversion

Please note that Microsoft Word and Microsoft Excel documents are completely different file formats; so, some features that are available in Microsoft Word are not available in Microsoft Excel and vice versa and it is hard to convert from Word to Excel and from Excel to Word with 100% fidelity.

However, you can convert Excel document to MS Word file format by using attached utility ConverterXls2Doc. Please find the source code of ConverterXls2Doc class in attachment and use this class as follow:

ConverterXls2Doc xls = new ConverterXls2Doc();

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(MyDir + "LargeTable.xlsx");

Document doc = xls.Convert(wb);

doc.Save(MyDir + "out.docx");



Pdf to Word file format conversion

You can convert Pdf to MS Word file format by using Aspose.Pdf. Please use RecognitionMode.Flow to save Word document into flow layout as shown in following code snippet. Please read following documentation links for your kind reference.
http://www.aspose.com/docs/display/pdfnet/Convert+PDF+file+into+DOC+format
http://www.aspose.com/docs/display/pdfnet/DocSaveOptions+Class


Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(MyDir +"in.pdf");

// create DocSaveOptions object

Aspose.Pdf.DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions();

// set the recognition mode as Flow

saveOptions.Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.Flow;

pdfDoc.Save(MyDir + "out.doc", saveOptions);



Thank you Tahir, great help

Hi Mauricio,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.