How to merge two PPTs using Java.
SolutionFollowing is the program to merge two PPTs using java.
import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlide; public class MergingMultiplePresentations { public static void main(String args[]) throws IOException { //creating empty presentation XMLSlideShow ppt = new XMLSlideShow(); //taking the two presentations that are to be merged String file1 = "C:/poippt/presentation1.pptx"; String file2 = "C:/poippt/presentation2.pptx"; String[] inputs = {file1, file2}; for(String arg : inputs) { FileInputStream inputstream = new FileInputStream(arg); XMLSlideShow src = new XMLSlideShow(inputstream); for(XSLFSlide srcSlide : src.getSlides()){ //merging the contents ppt.createSlide().importContent(srcSlide); } } String file3 = "C:/poippt/combinedpresentation.pptx"; //creating the file object FileOutputStream out = new FileOutputStream(file3); // saving the changes to a file ppt.write(out); System.out.println("Merging done successfully"); out.close(); } }Input Output
java_apache_poi_ppt
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4