In this article, I’ll show you how to convert PDF to PowerPoint PPT/PPTX programmatically using Java.
The PDF has become one of the most widely used document formats because of its supported features as well as stability and consistency across all the platforms. In various scenarios, you opt to save or share a document in the PDF format. However, in some cases, you may need to export the content of a PDF to a PowerPoint (PPT/PPTX) presentation. In such a situation, you can avoid manual copy/paste by automating PDF to PowerPoint conversion. In order to deal with such a case, we’ll learn how to:
- Convert PDF to PowerPoint PPT or PPTX using Java
- Convert PDF to PPT/PPTX having slides as images
- Track PDF to PPT/PPTX conversion progress
TIP: You may want to try Aspose PDF to PowerPoint Converter, which is a live implementation of the process described in this article.
Java PDF to PPT/PPTX Converter API
Aspose.PDF for Java is a well-known PDF API with an amazing set of PDF manipulation features. Along with PDF manipulation, the API also provides a powerful PDF to PowerPoint converter that lets you convert each page in the PDF document to a slide in the PPT/PPTX presentation. You can download the API’s JAR or install it within your Maven-based application using the following configurations.
<repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>https://repository.aspose.com/repo/</url> </repository>
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-pdf</artifactId> <version>20.7</version> <classifier>jdk17</classifier> </dependency>
Convert PDF to PowerPoint PPT/PPTX using Java
The following are the steps as well as API references to convert a PDF document to PPTX presentation using Aspose.PDF for Java.
- Create an instance of the Document class.
- Create an object of the PptxSaveOptions class.
- Convert PDF to PPTX using Document.save(String) method.
The following code sample shows how to convert a PDF to PPTX using Java.
Convert PDF to PPTX with Slides as Images using Java
You can also convert each page of the PDF to an image within the presentation’s slides. This feature is useful when you want to avoid having the selectable text in the presentation. The following are the steps to convert a PDF to PPTX having images in the slides.
- Initialize the Document class.
- Create an instance of the PptxSaveOptions class.
- Set PptxSaveOptions.setSlidesAsImages(true).
- Save PDF as PPTX using Document.save(String) method.
The following code sample shows how to convert PDF to PPTX having slides as images.
Track PDF to PowerPoint PPTX Conversion Progress
You can also track the PDF to PPTX conversion progress by defining a custom progress handler using PptxSaveOptions.setCustomProgressHandler() method. This feature can be used to show the progress bar or details about how many pages are processed. The following code sample shows how to implement the feature of tracking conversion progress.
SourcePageAnalysed 1 from: 10 TotalProgress 2 from: 100 SourcePageAnalysed 2 from: 10 TotalProgress 5 from: 100 SourcePageAnalysed 3 from: 10 TotalProgress 7 from: 100 SourcePageAnalysed 4 from: 10 TotalProgress 9 from: 100 SourcePageAnalysed 5 from: 10 TotalProgress 12 from: 100 SourcePageAnalysed 6 from: 10 TotalProgress 14 from: 100 SourcePageAnalysed 7 from: 10 TotalProgress 16 from: 100 SourcePageAnalysed 8 from: 10 TotalProgress 18 from: 100 SourcePageAnalysed 9 from: 10 TotalProgress 21 from: 100 SourcePageAnalysed 10 from: 10 TotalProgress 23 from: 100 ResultPageCreated 1 from: 10 TotalProgress 28 from: 100 ResultPageCreated 2 from: 10 TotalProgress 32 from: 100 ResultPageCreated 3 from: 10 TotalProgress 37 from: 100 ResultPageCreated 4 from: 10 TotalProgress 42 from: 100 ResultPageCreated 5 from: 10 TotalProgress 46 from: 100 ResultPageCreated 6 from: 10 TotalProgress 51 from: 100 ResultPageCreated 7 from: 10 TotalProgress 56 from: 100 ResultPageCreated 8 from: 10 TotalProgress 61 from: 100 ResultPageCreated 9 from: 10 TotalProgress 65 from: 100 ResultPageCreated 10 from: 10 TotalProgress 70 from: 100 ResultPageSaved 1 from: 10 TotalProgress 73 from: 100 ResultPageSaved 2 from: 10 TotalProgress 76 from: 100 ResultPageSaved 3 from: 10 TotalProgress 79 from: 100 ResultPageSaved 4 from: 10 TotalProgress 82 from: 100 ResultPageSaved 5 from: 10 TotalProgress 85 from: 100 ResultPageSaved 6 from: 10 TotalProgress 88 from: 100 ResultPageSaved 7 from: 10 TotalProgress 91 from: 100 ResultPageSaved 8 from: 10 TotalProgress 94 from: 100 ResultPageSaved 9 from: 10 TotalProgress 97 from: 100 ResultPageSaved 10 from: 10 TotalProgress 100 from: 100
In this article, you have learned how to programmatically convert PDF to PowerPoint PPT/PPTX using Java. You can implement this feature in Java Swing or any other Java-based applications. In case you may want to learn more about our Java PDF API, consult the documentation.