Skip to content

Instantly share code, notes, and snippets.

@blog-aspose-cloud
Last active October 17, 2022 17:52
Show Gist options
  • Save blog-aspose-cloud/4caac65c20990e23c4823a8437bfecc1 to your computer and use it in GitHub Desktop.
Save blog-aspose-cloud/4caac65c20990e23c4823a8437bfecc1 to your computer and use it in GitHub Desktop.
Merge PowerPoint Presentations

Combine PowerPoint using Java


This Gist shares details on how to combine PowerPoint using Aspose.Slides Cloud SDK for Java.

In following code snippet, we are going to load the PowerPoint presentations from local drive and cloud storage and merge powerpoint presentations using mergeAndSaveOnline(…) method. The resultant PowerPoint is then stored in Cloud storage. For complete details, please visit Combine PowerPoint in Java.

Combine PowerPoint

Important Links

Home | Product Page | Docs | API Reference | Cloud Dashboard | Code Samples | Source Code | Blog | Free Support | Free Trial

try
{
// Get ClientID and ClientSecret from https://dashboard.aspose.cloud/
String clientId = "7ef10407-c1b7-43bd-9603-5ea9c6db83cd";
String clientSecret = "ba7cc4dc0c0478d7b508dd8ffa029845";
// create an instance of SlidesApi
SlidesApi slidesApi = new SlidesApi(clientId,clientSecret);
// Collect the presentations to merge.
FileInfo fileInfo = new FileInfo();
// read input presentation
fileInfo.setData(Files.readAllBytes(Paths.get("TemplateCV.pptx")));
// set the name of source PowerPoint
fileInfo.setName("TemplateCV.pptx");
// Create a Array List of FileInfo object
List<FileInfo> files = new ArrayList<FileInfo>();
// add FileInfo object to Array list
files.add(fileInfo);
// Prepare information for the first presentation to merge.
PresentationToMerge presentation1 = new PresentationToMerge();
// read PowerPoint from local drive
presentation1.setSource(PresentationToMerge.SourceEnum.REQUEST);
// set the path for first PowerPoint file
presentation1.setPath("TemplateCV.pptx");
// specify the slides of PowerPoint which we need to merge
presentation1.setSlides(Arrays.asList(1, 2));
// Prepare information for the first presentation to merge.
PresentationToMerge presentation2 = new PresentationToMerge();
presentation2.setPath("Presentation1.pptx");
// set password details if PowerPoint is password protected
///presentation2.setPassword("my_password");
// specify the source as Cloud storage
presentation2.setSource(PresentationToMerge.SourceEnum.STORAGE);
// Prepare information for the first presentation to merge.
PresentationToMerge presentation3 = new PresentationToMerge();
// path of PowerPoint as web URL
presentation3.setPath("https://github.com/aspose-slides-cloud/aspose-slides-cloud-java/blob/master/TestData/test-unprotected.pptx");
presentation3.setSlides(Arrays.asList(1));
// set path value as URL
presentation3.setSource(PresentationToMerge.SourceEnum.URL);
// Prepare the merge request.
OrderedMergeRequest request = new OrderedMergeRequest();
// set the merge order for PowerPoint presentations
request.setPresentations(Arrays.asList(presentation1, presentation2));//, presentation3));
// call the API to combine PowerPoint and save output in Cloud storage
slidesApi.mergeAndSaveOnline("Merged.pptx", files, request, "internal"); // mergeOnline(files, request, null);
System.out.println("Merge PowerPoint successful !");
}catch(Exception ex)
{
System.out.println(ex);
}
Learn how to combine multiple powerpoints into one unified Presentation using Java Cloud SDK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment