Convert PDF to PowerPoint Presentation in Java

·

1 min read

When working with PDF files, there are times when you may need to convert PDFs to other office file formats based on different needs. If you are going to present a PDF file to your audience, converting it to PowerPint will ensure you have a better presentation. This article will share how to convert a PDF file to an editable PowerPoint document using Spire.PDF for Java.

Install Spire.PDF for Java (2 methods)

Method 1: Download the latest version of the library and unzip it. Then add the Spire.Pdf.jar file to your project as dependency.

Method 2: Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.

<repositories>
    <repository>
        <id>com.e-iceblue</id>
        <name>e-iceblue</name>
        <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.pdf</artifactId>
        <version>9.2.1</version>
    </dependency>
</dependencies>

Sample Code

From version 9.2.1, Spire.PDF for Java supports the conversion of PDF to PowerPoint. The code to implement this feature is fairly simple and you can check the details below.

import com.spire.pdf.FileFormat;
import com.spire.pdf.PdfDocument;

public class PDFtoPowerPoint {
    public static void main(String[] args) {

        //Create a PdfDocument instance
        PdfDocument pdfDocument = new PdfDocument();

        //Load a sample PDF document
        pdfDocument.loadFromFile("Input.pdf");

        //Convert PDF to PowerPoint
        pdfDocument.saveToFile("PDFtoPowerPoint.pptx", FileFormat.PPTX);
    }
}