Convert PowerPoint to PDF using Java – PPT to PDF or PPTX to PDF Conversion

Java PowerPoint PPT PPTX to PDF

PDF (Portable Document Format) has become the most widely and commonly used digital document format. Since PDF format owns the fixed layout, most of the documents are converted to PDF before they are shared. Among the various document conversions to PDF format, PowerPoint to PDF conversion is a popular use case and there should be an automated and time-saving solution to avoid manual conversions specifically when you have to convert a bunch of PowerPoint presentations to PDF. Keeping this in mind, I’ll show you how to convert PowerPoint PPT or PPTX to PDF programmatically in Java with various options provided by Aspose.Slides for Java API.

TIP: Check out a live implementation of the PowerPoint to PDF or PPT to PDF conversion process.

PowerPoint to PDF Conversions in Java

In this article, we will cover the following conversion scenarios using Aspose.Slides for Java:

  • Convert PowerPoint PPT or PPTX to PDF in Java
  • Convert PPT or PPTX to PDF with custom options
  • Convert PPT or PPTX to PDF including hidden slides
  • Convert PPT or PPTX to password-protected PDF
  • Convert specific slide(s) of PPT or PPTX to PDF
  • Convert PPT or PPTX to PDF with access permissions

Installing Aspose.Slides for Java

You can either download Aspose.Slides for Java JAR or add it in your maven-based project using the following repository and dependency information.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>19.12</version>
    <classifier>jdk16</classifier>
</dependency>

Convert PowerPoint PPT or PPTX to PDF in Java

The following are the simple steps to convert your PowerPoint presentation to PDF with default options provided by Aspose.Slides for Java.

  • Load PowerPoint PPT or PPTX file using Presentation object.
  • Call save() method passing the output PDF file name and the output format.

The following code sample shows how to convert a PowerPoint PPTX to PDF in Java with default options.

Convert PowerPoint PPT or PPTX to PDF with Custom Options

Aspose.Slides for Java provides the PdfOptions class to let you customize the PowerPoint to PDF conversion. PdfOptions class lets you specify the JPEG quality, define the behavior of metafiles, set text compression level, PDF compliance level, and other options. The following are the steps to convert a PPT or PPTX file to PDF with customized options.

  • Load PowerPoint PPT or PPTX using Presentation object.
  • Create the object of PdfOptions class.
  • Set/specify the options exposed by the PdfOptions class.
  • Call save() method.

The following code sample shows how to convert PowerPoint PPTX to PDF in Java with customized options.

Convert PowerPoint PPT or PPTX to PDF Including Hidden Slides

There could be the case when the PowerPoint presentation contains the hidden slides. In the default PowerPoint to PDF conversion, Aspose.Slides for Java ignores the hidden slides. However, if you want to include the hidden slides in the converted PDF, you can use PdfOptions.setShowHiddenSlides(true) option.

The following code sample shows how to convert PowerPoint PPTX to PDF including hidden slides in Java.

Convert Specific Slide(s) of PowerPoint Presentation to PDF

Aspose.Slides for Java also allows selecting the slides that you want to include in the resultant PDF document. You can create an array to specify the slides numbers that you want to include in PowerPoint to PDF conversion and pass that to save() method.

The following code sample shows how to convert specific slides of PowerPoint PPTX to PDF in Java.

Convert PowerPoint PPT or PPTX to Password-Protected PDF

You can also convert the PowerPoint presentation to a password-protected PDF to secure your document. You can set the password usingPdfOptions.setPassword(“password”) and pass PdfOptions object to save() method.

The following code sample shows how to convert PowerPoint PPTX to a password-protected PDF in Java.

Convert PowerPoint PPT or PPTX to PDF with Access Permissions

The PDF format allows you to specify different access permissions such as print permission, permission to add or modify text annotations or form fields and so on. In accordance with this feature, Aspose.Slides for Java provides the feature of setting permissions for the PDF document which is converted from the PowerPoint presentation. The PdfAccessPermissions class contains the set of flags for different permission types you can apply in PowerPoint presentation to PDF conversion.

The following Java code sample shows how to convert PowerPoint presentations to PDF with access permissions.

You can download the complete set of source code examples in Java from the GitHub repository. Visit the documentation for more details on the features exposed by Aspose.Slides for Java. In case you would find an issue or have any questions, feel free to let us know via our forum.