Getting Warning Callbacks for Fonts Substitution in Aspose.Slides

Getting Warning Callbacks for Fonts substitution

Aspose.Slides for C++ 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.

C#


 class HandleFontsWarnings : Aspose.Slides.Warnings.IWarningCallback

{

    public int warning(IWarningInfo warning)

    {

        Console.WriteLine(warning.getWarningType()); // 1 - WarningType.DataLoss

        Console.WriteLine(warning.getDescription()); // "Font will be substituted from X to Y"

        return ReturnAction.Continue;

    }

}

//Setting Warning Callbacks

LoadOptions lo = new LoadOptions();

lo.WarningCallback=new HandleFontsWarnings();

//Instantiate the presentation

Presentation presentation = new Presentation(path+"1.ppt", lo);

//Generating slide thumbnail

foreach(ISlide slide in presentation.Slides)

{

	Image image = slide.getThumbnail();

}