Fatal exception occurs when converting PPT to PDF

90691621935178_.pic_hd.png (99.4 KB)

public String conversionFile(ConversionDTO conversionDTO){
final String targetPath = conversionDTO.getTargetPath();
String savePath = null;
final String srcPath = conversionDTO.getSrcPath();
log.info(">>>>开始解析ppt>>>"+srcPath);
savePath = targetPath + conversionDTO.getFileName();
final Presentation pres = new Presentation(srcPath);
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setDefaultRegularFont(FileConvertConstant.DEFAULT_FONT);
pdfOptions.setWarningCallback(new HandleFontsWarnings());

    final IFontsManager fontsManager = pres.getFontsManager();
    // 获取ppt里面所有的字体
    IFontData[] embeddedFonts = fontsManager.getFonts();
    FontsLoader.loadExternalFonts(new String[]{FileConvertConstant.FONT_PATH});
    try {
        if(embeddedFonts.length > 0){
            for (IFontData embeddedFont : embeddedFonts) {
                final String fontName = embeddedFont.getFontName();

                // 如果ppt中字体在本地不存在
                if(!FontConfig.getLocalFontsSets().contains(fontName)){
                    log.warn("font :{} lost ",fontName);
                    set.add(fontName);
                    // 最后指定默认的
                    fontsManager.replaceFont(embeddedFont, new FontData(FileConvertConstant.DEFAULT_FONT));
                }
            }
        }
    }catch (Exception e){
        log.warn(e+"");
    }

    if (!CollectionUtils.isEmpty(set)){
        conversionDTO.setLoseFontLists(Lists.newArrayList(set));
        set.clear();
    }

    pres.save(savePath, SaveFormat.Pdf,pdfOptions);
    log.info(">>>解析成功>>>"+savePath);
    return savePath;
}

@zyx,
Thank you for the query. Unfortunately, I cannot use your code example to investigate this case. Please share and specify the following:

  • a standalone code example reproducing the issue without your application code
  • the presentation file you converted to PDF format
  • the version of Aspose.Slides you used
  • the version of the operating system on which the error appears
  • the version of JDK you used

But first, please check the issue with the latest version of Aspose.Slides.

@Test
public void testPdf(){
final String targetPath = “/Users/zyx/Desktop/”;
String savePath = null;
final String srcPath = “/Users/zyx/Downloads/67467-批量使用1-38.pptx”;
savePath = targetPath + “test.pdf”;
final Presentation pres = new Presentation(srcPath);
PdfOptions pdfOptions = new PdfOptions();
pres.save(savePath, SaveFormat.Pdf,pdfOptions);

}

https://tezign-assets.oss-cn-beijing.aliyuncs.com/1a3a3af79cec141766d7a0602e821c85.pptx

image.png (79.0 KB)

com.aspose aspose-slides 21.4 jdk16

image.png (69.4 KB)

@zyx,
Thank you for the additional information. I logged the issue in our tracking system with ID SLIDESJAVA-38546. Our development team will investigate this case. I will inform you of any progress.

The issues you have found earlier (filed as SLIDESJAVA-38546) have been fixed in this update.