Merging Multiple PPTs using java Last Updated : 11 Dec, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report To merge multiple PowerPoint Presentation files using Java. To achieve this use a Java Library called Apache POI. Apache POI is a project run by the Apache Software Foundation, and previously a sub-project of the Jakarta Project, provides pure Java libraries for reading and writing files in Microsoft Office formats, such as Word, PowerPoint and Excel. Use Apache guide to install the Apache POI libraries for Windows/Linux Systems. Examples: Input : file1.pptx, file2.pptx Output: merged.pptx Input : file1.pptx file2.pptx file3.pptx Output: merged.pptxInput Files: file1.pptxfile2.pptxOutput File: merged.pptxApproach: Get the current working directory path and list all the presentation filesCreate an empty Presentation Object using XMLSlideShow from apache POI packageIterate through each Presentation File from the list and append slides to the empty Presentation ObjectSave the new merged Presentation FileBelow is the implementation of the above approach: Java // Merging Multiple PPTs using java import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.File; import java.util.*; // importing apache POI environment packages import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlide; public class MergePPT { public static void main(String args[]) throws IOException { // creating empty presentation XMLSlideShow ppt = new XMLSlideShow(); String path = System.getProperty("user.dir"); // getting path of current working directory File file = new File(path); // creating empty file using File object String[] fileList = file.list(); // returns an array of all files from current // working directory ArrayList<String> presentationList = new ArrayList<String>(); for (String str : fileList) { if (str.contains(".pptx")) presentationList.add(str); } // filtering all presentation file paths and // appending to presentationList if (presentationList.isEmpty() == false) { for (String arg : presentationList) { FileInputStream inputstream = new FileInputStream(arg); // getting current presentation file path in // a FileInputStream XMLSlideShow src = new XMLSlideShow(inputstream); // getting all the slides of the // presentation file in a XMLSlideShow // object for (XSLFSlide srcSlide : src.getSlides()) { ppt.createSlide().importContent( srcSlide); // appending each presentation slide to // empty presentation object ppt } } String mergedFile = path + "/merged.pptx"; // creating new file path FileOutputStream out = new FileOutputStream(mergedFile); // creating the file object ppt.write(out); // saving the changes to the new file System.out.println( "All files merged successfully!"); out.close(); } else System.out.println( "No Presentation files found in current directory!"); } } Output: Output Comment More infoAdvertise with us Next Article Formatting Text on a Slide in a PPT using Java Y yasserarafat Follow Improve Article Tags : Java Java Programs Practice Tags : Java Similar Reads Creating Hyperlink on a Slide in a PPT using Java Apache POI is a powerful API that enables the user to create, manipulate, and display various file formats based on Microsoft Office using Java programs. Using POI, one should be able to perform create, modify, and display/read operations on the following file formats. For Example, Java doesnât prov 3 min read Formatting Text on a Slide in a PPT using Java To Format text on a slide in PowerPoint Presentation using Java, use a Java Library called Apache POI. Apache POI is a project run by the Apache Software Foundation, and previously a sub-project of the Jakarta Project provides pure Java libraries for reading and writing files in Microsoft Office for 3 min read How to Concatenate Multiple Strings in Java? In Java programming, there are a lot of ways to concatenate multiple strings. For this, we have taken three or more String values then we concatenate those String values by using different ways. In this article, we have used two different ways, we will explain each method with one example for a bett 2 min read Adding Images to a Table in PDF using Java PDFBox is an open-source library which is written in Java. It helps in the development and conversion of PDF Documents. PDFBox library comes in form of a JAR file. It can create new PDF documents, manipulate existing documents, bookmark the PDF and also extract content from PDF documents. We can use 7 min read Converting the Slides of a PPT into Images using Java To convert PowerPoint slides to images, multiple packages are required like, java.awt because It contains all the classes for creating user interfaces and for painting graphics and images, java.io because It provides a set of input streams and a set of output streams used to read and write data to f 3 min read Adding Paragraphs as Text to a PDF using Java iText is a Java library developed, to access and manipulate PDF files, that is to extract and modify the PDF content. Java allows us to incorporate various fully developed packages and modules in order to work with PDF files. We will see how to create a PDF document and add a paragraph to it using t 4 min read Like