merge word documents

Merge Word documents online with .NET REST API.

In our daily life, we witness the free flow of information and every passing day, makes collaboration more paramount. Therefore, the need for an efficient document management has never been so evident. Whether you’re a student skimming through research papers, a professional handling complex reports, or a team working together on a project, the ability to seamlessly merge Word documents stands as a crucial feature. Therefore, this article delves into the essential need for merging Word documents, uncovering the advantages it brings to various aspects of modern life.

REST API to Merge Word Files

Simplify the process of merging Word files using the Aspose.Words Cloud SDK for .NET. This powerful SDK offers a seamless solution to effortlessly combine and merge multiple Word documents into a cohesive and professionally formatted output. Furthermore, the Cloud SDK provides a reliable method to merge Word documents without the hassle of manual intervention.

The first step in SDK utilization is to add its reference to .NET solution. Therefore, search Aspose.Words-Cloud in NuGet packages manager and click the Add Package button. Furthermore, please visit cloud dashboard and obtain your personalized client credentials.

Merge Word Documents into One with C# .NET

Please follow the instructions given below to combine word documents online using C# .NET.

Now, let’s explore some details related to above stated code snippet.

var config = new Configuration { ClientId = clientID, ClientSecret = clientSecret };
WordsApi wordsApi = new WordsApi(config);

Firstly, create an instance of WordsApi class where we pass the client credentials as arguments.

ar FileReference = new FileReference(secondDocuemnt);

Create FileReference object where we provide a stream instance holding a second Word document.

var requestDocumentListDocumentEntries0 = new DocumentEntry()
    FileReference = FileReference,
    ImportFormatMode = "KeepSourceFormatting"

Create DocumentEntry object where we pass file reference of second word file and specify to hold the document formatting.

var requestDocumentListDocumentEntries = new List<DocumentEntry>()

Create List instance where we pass previously created DocumentEntry object.

var appendRequest = new AppendDocumentOnlineRequest(firstDocuemnt, requestDocumentList, destFileName: resultantFile);

Create an instance of AppendDocument where we provide first Word file stream, list of documents to be appended and the name of the resultant file as arguments.

var responseCode = wordsApi.AppendDocumentOnline(appendRequest);

Finally, call the API to initiate the document merge operation.

Combine Word Documents using cURL Commands

Experience the dynamic collaboration, allowing you to seamlessly merge multiple Word documents into a single, cohesive file using a powerful combination of Aspose.Words Cloud and cURL commands. By crafting a cURL command that interacts with the Aspose.Words Cloud API, eliminates the manual effort of copy-pasting content and ensures that your merged document maintains its formatting, styles, and overall structure.

Now, the first step in this approach is to generate a JWT access token by executing the following command:

curl -v "" \
 -X POST \
 -d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Accept: application/json"

Once we have the JWT token, please execute the following command to merge the Word documents into single unified output. Please note, the following command expects both the input Word files to be already available in cloud storage.

curl -v -X PUT "" \
-H  "accept: application/json" \
-H  "Authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{\"DocumentEntries\":[{\"Href\":\"SampleMailMergeTemplate.docx\",\"ImportFormatMode\":\"KeepSourceFormatting\"}],\"ApplyBaseDocumentHeadersAndFootersToAppendingDocuments\":true}"


In conclusion, the ability to merge Word files serves as a cornerstone of efficient document management and collaboration. With two dynamic approaches at your disposal—leveraging Aspose.Words Cloud SDK for .NET and harnessing the potential of cURL commands—you have the flexibility to choose the method that best suits your technical expertise and preferences. Nevertheless, both pathways lead to enhanced document organization and collaboration, ensuring that your merged documents maintain their structure, styles, and overall professionalism.

We highly recommend visiting the following blogs: