Appending a List of Word Documents using C# with Aspose.Words REST API

I have a list of document URIs that I want to combine into one document. They’ve already been through a mail merge process I’ve invoked via Aspose.Words.Cloud, and stored out in our Azure storage location.

Is there a simple way I can provide a list of all of the documents I want combined into one final file? Or do I have to append one doc at a time?

Does anyone have a C# example of appending multiple docs?

nevermind I believe I’ve found the solution I need using Aspose.Words.Cloud.Sdk.Model.DocumentEntryList

@bdubose

You can append as many documents as you want in a single API call with POST /words/{name}/appendDocument API. C# example of appending documents is given here: AppendDocumentExample.

@bdubose

As an update please note we have introduced Aspose.Words Cloud storage API methods in API Version V4.0. Now you do not need to use Aspose.Storage Cloud for storage operations any more.

            WordsApi wordsApi = new WordsApi(ClientId, ClientSecret);
            var fileName = "02_pages.docx";
            var documentToAppend = "02_pages_copy.docx";
            var documentToAppend1 = "02_pages_adobe.docx";
            var localFolder = "C:/Temp/";
            string remoteFolder = null;
            string destFileName = "append.docx";

            var body = new DocumentEntryList();
            System.Collections.Generic.List<DocumentEntry> docEntries = new System.Collections.Generic.List<DocumentEntry>();

            DocumentEntry docEntry = new DocumentEntry { Href = documentToAppend, ImportFormatMode = "KeepSourceFormatting" };
            DocumentEntry docEntry1 = new DocumentEntry { Href = documentToAppend1, ImportFormatMode = "KeepSourceFormatting" };
            docEntries.Add(docEntry);
            docEntries.Add(docEntry1);
            body.DocumentEntries = docEntries;

            Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest uploadRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(System.IO.File.OpenRead(localFolder + fileName), fileName);
            wordsApi.UploadFile(uploadRequest);
            uploadRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(System.IO.File.OpenRead(localFolder + documentToAppend), documentToAppend);
            wordsApi.UploadFile(uploadRequest);
            uploadRequest = new Aspose.Words.Cloud.Sdk.Model.Requests.UploadFileRequest(System.IO.File.OpenRead(localFolder + documentToAppend1), documentToAppend1);
            wordsApi.UploadFile(uploadRequest);


            var request = new AppendDocumentRequest(fileName, body, remoteFolder, destFileName: destFileName);
            var actual = wordsApi.AppendDocument(request);
            Console.WriteLine(actual);