UseTargetMachineFonts
HtmlFixedSaveOptions.UseTargetMachineFonts property
标志指示是否必须使用来自目标计算机的字体来显示文档。 如果此标志设置为真的
,FontFormat
和ExportEmbeddedFonts
属性没有效果, 也ResourceSavingCallback
不会针对字体触发。 默认为错误的
.
public bool UseTargetMachineFonts { get; set; }
例子
显示将文档保存为 HTML 时如何仅使用目标计算机的字体。
Document doc = new Document(MyDir + "Bullet points with alternative font.docx");
HtmlFixedSaveOptions saveOptions = new HtmlFixedSaveOptions
{
ExportEmbeddedCss = true,
UseTargetMachineFonts = useTargetMachineFonts,
FontFormat = ExportFontFormat.Ttf,
ExportEmbeddedFonts = false,
};
doc.Save(ArtifactsDir + "HtmlFixedSaveOptions.UsingMachineFonts.html", saveOptions);
string outDocContents = File.ReadAllText(ArtifactsDir + "HtmlFixedSaveOptions.UsingMachineFonts.html");
if (useTargetMachineFonts)
Assert.False(Regex.Match(outDocContents, "@font-face").Success);
else
Assert.True(Regex.Match(outDocContents,
"@font-face { font-family:'Arial'; font-style:normal; font-weight:normal; src:local[(]'☺'[)], " +
"url[(]'HtmlFixedSaveOptions.UsingMachineFonts/font001.ttf'[)] format[(]'truetype'[)]; }").Success);
也可以看看
- class HtmlFixedSaveOptions
- 命名空间 Aspose.Words.Saving
- 部件 Aspose.Words