UseTargetMachineFonts

HtmlFixedSaveOptions.UseTargetMachineFonts property

标志指示是否必须使用目标机器的字体来显示文档。 如果将此标志设置为真的FontFormatExportEmbeddedFonts属性不起作用, 也不起作用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);

也可以看看