Conversion of PPTX to PDF in Java: The Generated File Could Not Be Opened

I have tried a few combinations of the code to convert the PPTX file to PDF but the only result I am getting is what I have attached as the ss below
image.jpg (154.2 KB)

Presentation presentation = new Presentation(sourcePath);
presentation.getPresentation().save(targetPath, SaveFormat.PDF);
Presentation presentation = new Presentation(sourcePath);
presentation.save(targetPath, SaveFormat.PDF);
Presentation presentation = new Presentation(sourcePath);

PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setSaveMetafilesAsPng(true);
pdfOptions.setTextCompression(PdfTextCompression.Flate);
pdfOptions.setCompliance(PdfCompliance.Pdf15);

presentation.save(targetPath, SaveFormat.PDF, pdfOptions);
presentation.dispose();

This is the file that I am trying to convert uploaded in pdf format
Free_Test_Data_1MB_PPTX.pptx.pdf (130.5 KB)

I have added this dependency

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>24.7</version>
    <classifier>jdk16</classifier>
</dependency>

@rn.air,
Thank you for contacting support.

I opened the PDF file using Adobe Acrobat Reader and no error messages appeared. We need more details to investigate the case. Please share the following files and information:

  • original presentation file (you can compress the file and upload a ZIP file here)
  • OS version on which the conversion was performed
  • JDK target version in your app project
  • name and version od the application that shows the error message

@andrey.potapov if you remove the.pdf from the end of the pdf file attached above you get the pptx file but I have also provided the info you asked for

Chrome
Error image.png (203.7 KB)
Version 127.0.6533.120 (Official Build) (arm64)

Edge
Error image.png (153.5 KB)
Version image.png (27.6 KB)

Preview application on Mac
Version image.png (30.6 KB)

@rn.air,
Thank you for the additional information. It looks like you are using the SaveFormat class from another Java package because it should be used as SaveFormat.Pdf instead of SaveFormat.PDF. Please check this carefully.
SaveFormat | Aspose.Slides for Java API Reference