DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

David has posted 34 posts at DZone. View Full User Profile

Merge Multiple Presentation by Passing List of All Files in .NET Apps

  • submit to reddit
SaasposeApp.AppKey = "89**********************";
SaasposeApp.AppSID = "77***********************";
//specify product URI
Product.BaseProductUri = @"";

string[] presentationsList = new string[] { "Presentation2.pptx", "Presentation3.pptx" };
PresentationsList list = new PresentationsList();
list.PresentationPaths = presentationsList;

string strJSON = JsonConvert.SerializeObject(list);

//build URI
string strURI = ""; //Product.BaseProductUri + "/pdf/" + basePdf + "/appendDocument?appendFile=" + newPdf + "&startPage=1&endPage=" + iPageCount.ToString();
string signedURI = Utils.Sign(strURI);

Utils.ProcessCommand(signedURI, "POST", strJSON);

// build URI to download merged presentation
strURI = "";
signedURI = Utils.Sign(strURI);

using (Stream responseStream = Utils.ProcessCommand(signedURI, "GET"))
    //Save output file
    using (Stream fileStream = System.IO.File.OpenWrite("C:\\MergedPresentation.pptx"))
        Utils.CopyStream(responseStream, fileStream);

//Following is the PresentationsList class

/// <summary>
/// represents list of presentations to be merged
/// </summary>
class PresentationsList
    public PresentationsList() { }

    public string[] PresentationPaths { get; set; }

//build URI to upload file to Saaspose
            string strURI = "";
            string signedURI = Sign(strURI);
            UploadFileBinary(localfilepath, signedURI, "PUT");
This technical tip allows developers to merge multiple presentation files   using Saaspose.Slides REST API in your .NET applications. You can pass a list of all the files you want to merge using this example. Developers need to upload all the input files (Presentation1.pptx, Presentation2.pptx and Presentation3.pptx in case of this example) before running this example. Please check Upload File to Saaspose for how to. Some important steps for performing this task are to specify product URI, build URI, build URI to download merged presentation and Save output file.