保存 Visio 文件时获取警告信息
Contents
[
Hide
]
可能的使用场景
有时用户会尝试保存包含没有本地字体的文本的 diagram。在这种情况下,Aspose.Diagram 在保存 diagram 时抛出警告。您可以通过实施**IWarningCallback**界面与设置**SaveOptions.WarningCallback**财产。
保存 Visio 文件时收到警告
以下示例代码说明了如何在保存 visio 文件时收到警告。代码转换样本 visio 文件哪个抛出**字体替换**保存警告。这个警告然后被捕获**IWarningCallback.Warning()**在控制台上打印警告消息的方法。另请检查下面给出的代码的控制台输出以获得更多理解。
示例代码
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
// For complete examples and data files, please go to https://github.com/aspose-diagram/Aspose.Diagram-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_Intro(); | |
// call the diagram constructor to load diagram from a VSDX file | |
Diagram diagram = new Diagram(dataDir + "sampleFontSubstitution.vsdx"); | |
// create an instance SVG save options class | |
Aspose.Diagram.Saving.SVGSaveOptions so = new Aspose.Diagram.Saving.SVGSaveOptions(); | |
so.WarningCallback = new TestDiagramWarningCallback(); | |
// save Visio drawing | |
diagram.Save(dataDir + "WarningCallback_out.svg", options); | |
public class TestDiagramWarningCallback : Aspose.Diagram.IWarningCallback | |
{ | |
public void Warning(Aspose.Diagram.WarningInfo info) | |
{ | |
if (info.WarningType == Aspose.Diagram.WarningType.FontSubstitution) | |
{ | |
Console.WriteLine("Diagram WARNING INFO: " + info.Description); | |
} | |
} | |
} |
控制台输出
这是使用提供的执行时上述代码的控制台输出样本 visio 文件.
Font substitution: Font [ Athene Logos ]has been substituted by Font[Times New Roman]