Getting Warning Callbacks for Fonts Substitution in Aspose.Slides

Contents
[ ]

Aspose.Slides for Java provides a simple API methods to receive warning callbacks during the rendering process. Follow the steps below to configure the warning callbacks:

  1. Create a custom callback class to receive the callbacks.
  2. Set the warning callbacks using using LoadOptions class
  3. Load the presentation file that is using a font for text inside that is unavailable on your target machine.
  4. Generate the slide thumbnail to see the effect.
//Setting Warning Callbacks
LoadOptions lo = new LoadOptions();
lo.setWarningCallback(new HandleFontsWarnings());
//Instantiate the presentation
Presentation presentation = new Presentation("Test.ppt", lo);
//Generating slide thumbnail
for(ISlide slide : presentation.getSlides()){
BufferedImage image = slide.getThumbnail();
class HandleFontsWarnings implements IWarningCallback
{
public int warning(IWarningInfo warning)
{
System.out.println(warning.getWarningType()); // 1 - WarningType.DataLoss
System.out.println(warning.getDescription()); // "Font will be substituted from X to Y"
return ReturnAction.Continue;
}
}