PDF has become one of the most widely used document formats due to its supported features and its stability and consistency across all platforms. In various cases, the choice is made to save or share the document in PDF format. However, in some cases, it may be necessary to export the content of the PDF into a PowerPoint (PPT/PPTX) presentation.
In this case, you can avoid manual copy/paste by automatically converting PDF to PowerPoint. To handle this situation, in this article, learn how to:
- Convert PDF to PowerPoint PPT or PPTX using Java
- Convert PDF to PPT/PPTX with slideshows to images
- Track PDF to PPT/PPTX conversion progress
Convert PDF to PowerPoint PPT/PPTX using Java
Following are the steps and API reference to convert PDF document to PPTX presentation using Aspose.PDF for Java.
- Create an instance of the Document class.
- Create an object of the PptxSaveOptions class.
- Use Document.save(String) method to convert PDF to PPTX.
The following code sample shows how to convert PDF to PPTX using Java.
// Load PDF document Document pdfDocument = new Document("document.pdf"); PptxSaveOptions pptxOptions = new PptxSaveOptions(); // Convert PDF to PPTX pdfDocument.save("PDF to PPT.pptx", pptxOptions);
PDF document
PPT document
Convert Slideshow to Image Convert PDF to PPTX using Java
Each page of a PDF can be converted into an image in a presentation slide. This feature is useful when you want to avoid optional text in your presentation. Here are the steps to convert PDF to PPTX with images in the slideshow.
- 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 code sample below demonstrates how to convert PDF to PPTX with slides as images.
// Load PDF document Document pdfDocument = new Document("document.pdf"); // Set PPTX save options PptxSaveOptions pptxOptions = new PptxSaveOptions(); pptxOptions.setSlidesAsImages(true); // Save PDF as PPTX pdfDocument.save("PDF to PPT.pptx", pptxOptions);
Track PDF to PowerPoint PPTX Conversion Progress
PDF to PPTX conversion progress can be tracked by defining a custom progress handler using the PptxSaveOptions.setCustomProgressHandler() method. This function can be used to display a progress bar or details about how many pages were processed. The following code example demonstrates how to implement the functionality to track the progress of a conversion.
PptxSaveOptions pptxOptions = new PptxSaveOptions(); pptxOptions.setCustomProgressHandler(new UnifiedSaveOptions.ConversionProgressEventHandler() { @Override public void invoke(UnifiedSaveOptions.ProgressEventHandlerInfo eventInfo) { // Example of how to handle progress events: System.out.println(ProgressEventType.getName(ProgressEventType.class, eventInfo.EventType) + "\t" + eventInfo.Value + " from: \t" + eventInfo.MaxValue); } }); // Load PDF Document pdfDocument = new Document("document.pdf"); // Save PDF as PPTX pdfDocument.save("PDF to PPTX.pptx", pptxOptions);
output result
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