在Aspose.Slides中获取字体替换的警告回调
Contents
[
Hide
]
Aspose.Slides for Java 使得在渲染过程中,如果所使用的字体在机器上不可用,可以获取字体替换的警告回调。这些警告回调有助于调试渲染过程中缺失或不可访问字体的问题。
Aspose.Slides for Java 提供了简单的 API 方法,在渲染过程中接收警告回调。请按照以下步骤配置警告回调:
- 创建一个自定义回调类以接收回调。
- 使用 LoadOptions 类设置警告回调
- 加载一个在目标机器上不可用字体的演示文件。
- 生成幻灯片缩略图以查看效果。
This file contains hidden or 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 hidden or 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; | |
} | |
} |