Created
December 10, 2025 10:38
-
-
Save aspose-com-gists/96d10b758d73067c675195853a4610ed to your computer and use it in GitHub Desktop.
Convert PPT to PDF with Aspose.Slides for Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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