Created
October 26, 2024 19:16
-
-
Save aspose-cloud-kb/a071236f59cf8d72afd9f02688bd7c23 to your computer and use it in GitHub Desktop.
Merge Presentations with C# REST API. https://kb.aspose.cloud/slides/net/merge-presentations-with-net-rest-api/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using Aspose.Slides.Cloud.Sdk; | |
using Aspose.Slides.Cloud.Sdk.Model; | |
namespace AsposeKbExamples | |
{ | |
public class MergePresentations | |
{ | |
static void Merge() | |
{ | |
SlidesApi api = new SlidesApi("Client ID", "Client secret"); | |
string fileName = "MyPresentation.pptx"; | |
string inputFile1 = "1-NewSales.pptx"; | |
string inputFile2 = "2-NewSales.pptx"; | |
try | |
{ | |
FilesUploadResult result = api.UploadFile(fileName, new MemoryStream(File.ReadAllBytes(fileName))); | |
result = api.UploadFile(inputFile1, new MemoryStream(File.ReadAllBytes(inputFile1))); | |
result = api.UploadFile(inputFile2, new MemoryStream(File.ReadAllBytes(inputFile2))); | |
// Prepare request data for presentations to merge. | |
var request = new PresentationsMergeRequest | |
{ | |
PresentationPaths = new List<string> { inputFile1, inputFile2 } | |
}; | |
// Merge the presentations. | |
var response = api.Merge("MyPresentation.pptx", request); | |
Console.WriteLine("Self Uri Href" + response.SelfUri.Href); | |
// Download created pdf file | |
Stream storageRes = api.DownloadFile(fileName); | |
FileStream fileStream = new FileStream("AfterMerging.pptx", FileMode.Create, FileAccess.Write); | |
storageRes.CopyTo(fileStream); | |
} | |
catch(Exception ex) | |
{ | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment