Hello,
We need to capture all font substitutions when converting a PPTX to PDF. However, setting a IWarningCallback
while converting a PPTX to PDF does not seem to work.
This behavior can be seen in the latest Aspose Slides for Java version 20.5, the attached NonExistingFonts.pptx file and the following Java code:
final String pptxFile = [PATH] + "NonExistingFonts.pptx";
final String pdfFile = pptxFile.replace(".pptx", ".pdf");
final IWarningCallback warningCallback = new IWarningCallback() {
@Override
public int warning(IWarningInfo warning) {
System.out.println("* * * * * Got Warning Callback:\n " +
warning.getDescription());
return ReturnAction.Continue;
}
};
// Load the PPTX
Presentation ppt = new Presentation(pptxFile);
// Save the PPTX as PDF
System.out.println("\nCallback output from Presentation SAVE (as PDF):");
PdfOptions saveOptions = new PdfOptions();
saveOptions.setWarningCallback(warningCallback);
ppt.save(pdfFile, SaveFormat.Pdf, saveOptions);
System.out.println("\nCompleted saving of: " + pdfFile);
The above produces the following output in the console:
Callback output from Presentation SAVE (as PDF):
Completed saving of: NonExistingFonts.pdf
Since the PPTX uses two non-existing fonts we are expecting them to be reported via the callback mechanism.
Workaround:
We’ve found that if the callback is added to the LoadOptions
- the font substitutions will be reported.
We can apply the workaround using the same sample code from above - but instead load the Presentation using LoadOptions
with a callback as such:
System.out.println("Callback output from Presentation LOAD:");
LoadOptions loadOptions = new LoadOptions();
loadOptions.setWarningCallback(warningCallback);
Presentation ppt = new Presentation(pptxFile, loadOptions);
When this modified version is run, the following is the new output:
Callback output from Presentation LOAD:
* * * * * Got Warning Callback:
The locking behavior of BlobManagementOptions.PresentationLockingBehavior is set to LoadAndRelease_Legacy_TemporaryDefault, which will be removed in version 17.10, and the default locking behavior will changed. Please consider KeepSourceLocked or LoadAndRelease options to choose the behavior most suitable for you.
Callback output from Presentation SAVE (as PDF):
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 1 to {Jokerman,Juice ITC,Niagara Engraved,Harrington,Playbill,Colonna MT,Bodoni MT Poster Compressed}
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 1 to {Jokerman,Juice ITC,Niagara Engraved,Harrington,Playbill,Colonna MT,Bodoni MT Poster Compressed}
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 1 to {Jokerman,Juice ITC,Niagara Engraved,Harrington,Playbill,Colonna MT,Bodoni MT Poster Compressed}
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 2 to {Arial,Cambria Math,MS Gothic,Gulim,Arial Unicode,SimSun,Segoe UI Symbol}
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 2 to {Arial,Cambria Math,MS Gothic,Gulim,Arial Unicode,SimSun,Segoe UI Symbol}
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 2 to {Arial,Cambria Math,MS Gothic,Gulim,Arial Unicode,SimSun,Segoe UI Symbol}
* * * * * Got Warning Callback:
Font will be substituted from Bad Font 2 to {Arial,Cambria Math,MS Gothic,Gulim,Arial Unicode,SimSun,Segoe UI Symbol}
Completed saving of: NonExistingFonts.pdf
Unfortunately, we cannot use this workaround at this time. It would be preferable that the callback feature work with SaveOptions
without requiring the callback on the LoadOptions
.
Environment Details:
- Aspose Slides for Java 20.5
- Java version 1.8.0_211
- Windows 10 OS (but also reproducible under Linux).
File description in the NonExistingFonts.zip (24.5 KB) attachment:
- NonExistingFonts.pptx: Presentation used by the sample code. Note that it constrains 2 non-existing fonts.
Thank you!