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