Combine PowerPoint Online

Combine PowerPoint | Merge PPT PPTX using Java Cloud SDK

In this article, we are going to discuss the details on how combine multiple PowerPoints into one presentation file. PowerPoints are used for information representations and briefing in corporate culture, as well as they are used by business people and students for slide show preparation. Another aspect of popularity is the creation of tutorials, digital portfolios, basic animations, or photo slide shows creation. However, when teams working in distributed environment, we may have a requirement to merge PowerPoint Presentations. So this article sheds light on details to combine multiple PowerPoints into one Presentation using Java Cloud SDK.

Merge PowerPoint API

In order to programmatically create, edit and export PPT or PPTX to PDF, JPEG, PNG or GIF etc format, we have developed low code API named Aspose.Slides Cloud. Its REST based architecture empowers you to call API routines on any platforms. Now in order to implement the feature to combine PowerPoint presentations in Java application, we have specifically created Aspose.Slides Cloud SDK for Java. So in order to use the SDK, all you need to do is add its reference in pom.xml of maven build project.

<repositories> 
    <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>

<dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-slides-cloud</artifactId>
        <version>22.9.0</version>
    </dependency>
</dependencies>

Once the SDK reference has been added, the next important step is to authenticate with Aspose Cloud. In case you do not have an existing account, please create a free account using valid email address. Then login using newly created account and lookup/create Client ID and Client Secret at Cloud Dashboard. These details are required for authentication purposes in the following sections.

Combine PowerPoint in Java

This section explains the details on how we can merge powerpoint presentations using Java Cloud SDK. Please note that in order to merge PowerPoint, the input PowerPoint can be loaded from local drive, loaded from Cloud storage or even load it directly from web URL. Please follow the instructions specified below.

  • First of all, create an object of SlidesApi object while providing ClientID and Client secret as arguments
  • Secondly, create an object of FileInfo where we provide the data for first PowerPoint
  • Thirdly, create an instance of ArrayList which will hold the list of PPT files to be merged
  • Next step is to create an separate object of PresentationToMerge for each PowerPoint to merge
  • Now in order to load the PowerPoint from local storage, we need to use REQUEST value from PresentationToMerge enumeration
  • In order to specify the particular slides within PowerPoint to be merged, we use setSlides(…) method
  • The next step is toe set the order for presentation files to be merged and for this purpose, we are going to use OrderedMergeRequest object and use its setPresentations(..) method
  • Finally call the mergeAndSaveOnline(…) method to merge powerpoint presentations and save the resultant file in cloud storage
Combine PowerPoint preview

Image1:- Merge PowerPoint Preview

The sample files used in above example can be downloaded from TemplateCV.pptx, Presentation1.pptx and Merged.ppt.

Merge PowerPoint using cURL Commands

The cURL commands are platform independent and can be executed on any platform. So this section shares the details on how to merge PowerPoint presentations using cURL commands. So on of the pre-requisites for this approach, first we need to generate a JWT access token (based on client credentials) while executing the following command.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bb959721-5780-4be6-be35-ff5c3a6aa4a2&client_secret=4d84d5f6584160cbd91dba1fe145db14" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once we have the JWT token, the next step is to merge PowerPoint presentations using following command. Please note that in following command, we are merging the first slide from first presentation and from second presentation, the 1st and 3rd slides are merged. The merge PPTX is saved in cloud storage.

curl -v -X PUT "https://api.aspose.cloud/v3.0/slides/merge?outPath=newResultant.pptx" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"Presentations\": [    {      \"Path\": \"Presentation1.pptx\",      \"Password\": \"string\",      \"Slides\": [        1      ],      \"Source\": \"Storage\"    },    {      \"Path\": \"test-unprotected.pptx\",      \"Password\": \"string\",      \"Slides\": [        1,3      ],      \"Source\": \"Storage\"    }  ]}"

Conclusion

This article has enlightened us on details to combine PowerPoint presentations using Java Cloud SDK. Other than Java code snippet, we have also learned about the details on how to combine multiple powerpoints into one using cURL commands. Furthermore, we highly recommend exploring product Documentation to learn about plethora of amazing features offered by Cloud API. Also, please note that all our Cloud SDKs are published under MIT license, so you may consider downloading the complete source code from GitHub and modify it as per your requirements. In case of any issues, you may consider approaching us for a quick resolution via free product support forum.

Please visit the following links to learn more about: