Getting Warning Callbacks for Fonts Substitution in Aspose.Slides
Contents
[
Hide
]
Aspose.Slides for Java makes it possible to get warning callbacks for fonts substitution in case the used font is not available on machine during rendering process. The warning callbacks are helpful in debugging the issues of missing or inaccessible fonts during rendering process.
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:
- Create a custom callback class to receive the callbacks.
- Set the warning callbacks using using LoadOptions class
- Load the presentation file that is using a font for text inside that is unavailable on your target machine.
- Generate the slide thumbnail to see the effect.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |