Hi,
I have implemented IWarningCallbacks for aspose.word and aspose.cells to get notified of font substitutions as part of a service that exports to PDF. Here is my implementation for aspose.slides:
private static boolean convertPowerPointToPDF(String fileId, String extension) throws Exception{
String dataDir = Utils.getDataDir();
String[] fontsList = new String[8];
FontsLoader.loadExternalFonts(new String[] { FONTS_PATH });
final IWarningCallback warningCallback = new IWarningCallback() {
@Override
public int warning(IWarningInfo warning) {
System.out.println("* * * * * Got Warning Callback:\n " +
warning.getDescription());
return ReturnAction.Continue;
}
};
//load ppt
com.aspose.slides.LoadOptions loadOptions = new com.aspose.slides.LoadOptions();
loadOptions.setWarningCallback(warningCallback);
com.aspose.slides.Presentation pres = new Presentation(dataDir + fileId + "." + extension, loadOptions);
//save pdf
dataDir = dataDir + fileId.split("\\.")[0] + ".pdf";
com.aspose.slides.PdfOptions saveOptions = new com.aspose.slides.PdfOptions();
saveOptions.setWarningCallback(warningCallback);
pres.save(dataDir, SaveFormat.Pdf, saveOptions);
}
When \testing the code using a presentation that uses a non-existent font, the Callback is only triggered from loadOptions, as the output is:
* * * * * 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.
But no notification that would indicate the callback being triggered by saveOptions, meaning we aren’t getting notified of the actual font substitution.
Any help would be greatly appreciated.
Thanks!