Merge files

GroupDocs.Merger allows to merge two or more documents into single resultant document. The result will contain the content of all source documents with all data, styles and formatting.

Here are the steps to merge several documents:

  • Instantiate Merger object with source document path or InputStream;
  • Call join method and pass next joined document file path or InputStream to it. Repeat this step for every joined document.
  • Call save method specifying file path to save resultant document.

The following code sample demonstrates how to join documents:

String filePath1 = "c:\sample1.docx";
String filePath2 = "c:\sample2.docx";
String filePath3 = "c:\sample3.docx";
String filePathOut = "c:\output\result.docx";

Merger merger = new Merger(filePath1 );

merger.join(filePath2 );
merger.join(filePath3 );
merger.save(filePathOut);

Please learn more about how to merge PDF, Microsoft Word, Microsoft PowerPoint or Open Document documents from the articles listed below:

© Aspose Pty Ltd 2001-2022. All Rights Reserved.