Home > Code > C# > Merge Multiple Presentation by Passing List of All Files in .NET Apps

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

by sher azam   on Dec 30, 2012   Category: C#   |  Views: 798    |  Points: 25   |  Gold 

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.

Sample Code for Merge multiple presentations

SaasposeApp.AppKey = "89**********************";
SaasposeApp.AppSID = "77***********************";
//specify product URI
Product.BaseProductUri = @"http://api.saaspose.com/v1.0";

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

string strJSON = JsonConvert.SerializeObject(list);

//build URI
string strURI = "http://api.saaspose.com/v1.0/slides/Presentation1.pptx/merge"; //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 = "http://api.saaspose.com/v1.0/storage/file/Presentation1.pptx";
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 = "http://api.saaspose.com/v1.0/storage/file/MyRemoteFileName";
string signedURI = Sign(strURI);
UploadFileBinary(localfilepath, signedURI, "PUT");

Overview: Saaspose.Slides

Saaspose.Slides is a REST based API that allows developers to read, write & modify a PowerPoint presentations in cloud. It is platform independent API & can be used by developers in web, desktop, mobile & cloud applications alike. It provides a rich set of features like creating presentation from scratch, modify various aspect of a presentation & converting a presentation to PDF, XPS, TIFF, SVG, HTML, PNG, JPEG, GIF & BMP formats. It helps you add, modify or extract text from the presentation.

More about Saaspose.Slides

- Homepage of Saaspose.Slides: http://saaspose.com/api/slides

- More Technical Tips by Saaspose.Slides: http://saaspose.com/docs/display/slides/1.2+-+Saaspose.Slides+Examples

- Ask technical questions/queries from Saaspose Support Team: http://saaspose.com/support/contact-us

Contact Information
Aspose Pty Ltd, Suite 163,
79 Longueville Road
Lane Cove, NSW, 2066
Phone: 1.214.329.1520
Fax: 866.810.9465

Post Code  |  Code Snippet Home

User Responses

No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts