Convert PDF to PowerPoint in Java
Contents
[
Hide
]
Aspose.PDF for Java supports exporting PDF pages into editable PowerPoint presentations with slide rendering options. Use PptxSaveOptions to control how PDF pages are mapped into PowerPoint slides.
Convert PDF to PPTX
Use this example when a PDF document should be exported as a standard PowerPoint presentation.
- Open the source PDF in a
Documentinstance. - Create default
PptxSaveOptionsfor editable PowerPoint export. - Call
document.save(outputFile.toString(), saveOptions)so the PDF pages are serialized as a.pptxpresentation. - Save the converted PPTX file.
public static void convertPdfToPptx(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
PptxSaveOptions saveOptions = new PptxSaveOptions();
document.save(outputFile.toString(), saveOptions);
}
System.out.println(inputFile + " converted into " + outputFile);
}
Convert PDF to PPTX with slides as images
Use this example when each PDF page should become an image-based PowerPoint slide.
- Open the source PDF in a
Documentinstance. - Create
PptxSaveOptionsand enablesetSlidesAsImages(true). - Call
document.save(outputFile.toString(), saveOptions)so each PDF page is rendered as an image-backed slide in the presentation. - Save the generated PPTX file.
public static void convertPdfToPptxSlidesAsImages(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
PptxSaveOptions saveOptions = new PptxSaveOptions();
saveOptions.setSlidesAsImages(true);
document.save(outputFile.toString(), saveOptions);
}
System.out.println(inputFile + " converted into " + outputFile);
}
Convert PDF to PPTX with custom image resolution
Use this example when the slide image quality should be controlled during PDF-to-PPTX export.
- Open the source PDF in a
Documentinstance. - Create
PptxSaveOptionsand setsetImageResolution(300)for higher slide image fidelity. - Call
document.save(outputFile.toString(), saveOptions)so rasterized slide content is generated at the requested resolution. - Save the output presentation.
public static void convertPdfToPptxImageResolution(Path inputFile, Path outputFile) {
try (Document document = new Document(inputFile.toString())) {
PptxSaveOptions saveOptions = new PptxSaveOptions();
saveOptions.setImageResolution(300);
document.save(outputFile.toString(), saveOptions);
}
System.out.println(inputFile + " converted into " + outputFile);
}