PPT to PDF in Java: EMF Images Getting Changed after Switching External Font Directory

Hello,
We are trying to upgrade our Aspose Slides for Java to the latest version, but we have hit an issue related to publishing PowerPoint presentation to PDF.
Here are the steps:

  1. Load and register fonts directory with FontManager;
  2. Load PowerPoint presentation containing two EMF images (this is important, the issue did not manifest itself before with PNG images);
  3. Print to PDF using presentation.save(filename, SaveFormat.Pdf, pdfoptions);
  4. Then swap fonts directory (remove one directory and add another);
  5. Configure the new fonts path with Aspose using FontsLoader.loadExternalFonts(customFontsDirs);
  6. Once again print to PDF.

At this point the tables in the created PDF document are getting corrupted.
Note that this does not happen if presentation is saved in native format (using SaveFormat.Pptx)

Environment Details:
Aspose Slides for Java 23.3
Java version 1.8.0_351-b10
Linux 7.4 OS (but also reproducible under Windows 10).

File description in Attachment:

  • Presentation.pptx: the Source Presentation
  • Presentation_test1.pdf
  • Presentation_test2.pdf
  • Sample code to demonstrate the issue
  • font directory containing necessary fonts
  • font2 another font directory

Please note that this issue may be a showstopper that prevents us from upgrading our Slides version.

Thank you in advance.PptToPdfIssue_aspose_23_03.zip (4.1 MB)

@oraspose,
Thank you for contacting support.

I am working on the issues you are encountering and will get back to you as soon as possible.

@oraspose,
Please try using the PdfOptions.setSaveMetafilesAsPng method like this:

options.setSaveMetafilesAsPng(false);

The result will be correct and the output file size will be smaller. output2.pdf (68.7 KB)

Documents: Convert PowerPoint to PDF in Java

Hi Andrey.
Thanks for the quick response.
I have tried setting the option as you suggested, but the result was still the same (corrupted fonts in PDF tables).
Please can you help me understand what else could be missing.
Just to reiterate what I am doing in the sample test program:

  1. Loading customer fonts and registering with Aspose
    FontsLoader.clearCache();
    FontsLoader.loadExternalFonts(customFontsDirs);
  2. Creating PPT presentation
  3. Creating PdfOptions and setting the saveMetafilesAsPng to false:
    PdfOptions options = new PdfOptions();
    options.setSaveMetafilesAsPng(false);
    options.setWarningCallback(new PptToPdfAfterFontsChange().new WarningCallback());
  4. Converting document to PDF:
    doc.save(BASE_DIR + “Presentation_Test1.pdf”, SaveFormat.Pdf, options);
  5. Changing customer fonts directory:
    //===== imitate update customer fonts - change custom fonts directory
    fontPaths.remove(fontPaths.size() - 1);
    fontPaths.add(fontPathCustomer2);
  6. Configure new font paths with Aspose:
    customFontsDirs = fontPaths.toArray(new String[fontPaths.size()]);
    FontsLoader.clearCache();
    FontsLoader.loadExternalFonts(customFontsDirs);
  7. Converting the same document to PDF
    doc.save(BASE_DIR + “Presentation_Test2.pdf”, SaveFormat.Pdf, options);

The second pdf document became smaller than before, but still has the issue - see attached.

Thank you,
Yan
Presentation_Test2.pdf (17.4 KB)

@oraspose,
I will check the issue and get back to you a bit later.

@oraspose,
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-39191

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.