Hi Team,
We are trying convert PPT document into PDF. But, charts from ppt are not rendered correctly in PDF.
In PDF chart images got distorted dramatically.
Java Version :17
We are using aspose.slides version 25.1
Linux version : 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Wed Sep 11 18:02:00 EDT 2024 x86_64 x86_64 x86_64 GNU/Linux
Attached PPT file here along with few sample images of affected charts from pdf.
please suggest.
File pptFile = new File("pptFilePath");
try (FileInputStream fileInputStream = new FileInputStream(pptFile)) {
logger.info("initilizatize fileInputStream for the ppt document");
Presentation ppt = new Presentation(fileInputStream);
logger.info("initilizatize presensentation object");
ppt.getDocumentProperties().setTitle("SampleTitle");
ppt.save(outputPdfFilePath,SaveFormat.Pdf,pdfOptions); //This ppt.save method takes more 5 mins to execute.
}
catch (Exception e) {
//
}
Issue chart.zip (2.3 MB)
@forasposeissues
Cause
The issue with charts not rendering correctly during the conversion of PPTX to PDF is likely due to several factors, including the handling of metafiles and image quality settings in the conversion process. Distorted images often arise from inadequate resolution settings or how the charts are processed during the export.
Solution
To improve the rendering of charts in your PDF output, you can customize the PdfOptions
used during the conversion. Here are some key settings to consider:
- Set JPEG Quality: Adjust the quality of JPEG images.
- Set Sufficient Resolution: Increase the resolution for images to ensure better quality.
- Save Metafiles as PNG: This can help maintain the quality of vector graphics.
Code
Here’s an updated version of your code that incorporates these options:
File pptFile = new File("pptFilePath");
try (FileInputStream fileInputStream = new FileInputStream(pptFile)) {
logger.info("Initializing fileInputStream for the ppt document");
Presentation ppt = new Presentation(fileInputStream);
logger.info("Initializing presentation object");
// Create PdfOptions and set properties
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setJpegQuality((byte) 90); // Set JPEG quality
pdfOptions.setSufficientResolution(300); // Set DPI for images
pdfOptions.setSaveMetafilesAsPng(true); // Convert metafiles to PNG
ppt.save(outputPdfFilePath, SaveFormat.Pdf, pdfOptions); // Save with options
} catch (Exception e) {
logger.error("Error during conversion: " + e.getMessage());
}
**Next Steps**
1. Test the updated code to see if the chart rendering improves.
2. If issues persist, check the original PPTX file for any specific chart settings or compatibility issues.
3. Explore the Aspose documentation for additional options related to image handling and PDF compliance.
Please implement these changes and let me know the results!
@forasposeissues,
Thanks for the PowerPoint presentation file, screenshots and PDF document.
I reproduced the issue as you mentioned by converting your template PowerPoint presentation file to PDF. I found some charts are not rendered properly as per the screenshots pasted in the document.
We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESJAVA-39687
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.