Getting Warning Callbacks for Fonts Substitution in Aspose.Slides

Getting Warning Callbacks for Fonts substitution

Aspose.Slides for .NET provides a simple API methods to get the Warning Callbacks during rendering process. All you need is to follow the steps below to configure the Warning Callbacks on your end.:

  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.WarningCallback = new HandleFontsWarnings();

//Instantiate the presentation
Presentation presentation = new Presentation("1.ppt", lo);

//Generating slide thumbnail
foreach (ISlide slide in presentation.Slides)
    Image image = slide.GetThumbnail();
class HandleFontsWarnings : IWarningCallback
    public ReturnAction Warning(IWarningInfo warning)
        Console.WriteLine(warning.WarningType); // 1 - WarningType.DataLoss
        Console.WriteLine(warning.Description); // "Font will be substituted from X to Y"
        return ReturnAction.Continue;