Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/96d10b758d73067c675195853a4610ed to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/96d10b758d73067c675195853a4610ed to your computer and use it in GitHub Desktop.
Convert PPT to PDF with Aspose.Slides for Java
import com.aspose.slides.*;
public class PptToPdfConverter {
public static void main(String[] args) {
// Path to the license file (optional for evaluation)
try {
License license = new License();
license.setLicense("Aspose.Slides.Java.lic");
} catch (Exception e) {
System.out.println("License not found or invalid: " + e.getMessage());
}
// Input PowerPoint file (PPT or PPTX)
String inputPath = "sample.pptx";
// Output PDF file
String outputPath = "sample.pdf";
try (Presentation pres = new Presentation(inputPath)) {
// Configure PDF save options
PdfSaveOptions options = new PdfSaveOptions();
options.setCompressImages(true); // Reduce image size
options.setEmbedFullFonts(true); // Embed all fonts
options.setImageQuality(80); // Set image quality (0-100)
// Save the presentation as PDF
pres.save(outputPath, SaveFormat.Pdf, options);
System.out.println("Conversion completed successfully.");
} catch (Exception ex) {
System.err.println("Error during conversion: " + ex.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment