MigraDoc:为一个文件设置字体 [英] MigraDoc: Setting font for a document

查看:753
本文介绍了MigraDoc:为一个文件设置字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用不同的字体与MigraDoc,但我有一个很难得到它坚持。目前,我用下面的代码工作:

I'm wanting to use a different font with MigraDoc, but I'm having a hard time getting it to stick. Currently, I'm working with the following code:

我有这样的一个类范围的变量:

I have this as a class-wide variable:

    String tPdfFont = "MonospaceTyperwriter";



然后MigraDoc代码本身:

Then the MigraDoc code itself:

    Document tDoc = new Document();
    MigraDoc.DocumentObjectModel.Style style = tDoc.Styles["Normal"];
    style.Font.Name = tPdfFont;

这特定的字体安装在机器上,但它似乎并没有工作。我觉得我失去了一些东西非常明显的,或我只是completley误会字体的使用。

That particular font is installed on the machine, but it doesn't seem to work. I feel like I'm missing something terribly obvious or am just completley misunderstanding font usage.

推荐答案

请确保你写的字体名称因为它出现在控制面板中的字体列表中。

Make sure you write the font name as it appears in the Font list in the Control Panel.

您确定这是MonospaceTyperwriter,而不是等宽打字机?

Are you sure it's "MonospaceTyperwriter" and not "Monospace Typewriter"?

代码看起来不错。

通常情况下,它可以帮助检查DDL文件,看看是否所有设置都在正确的地方。结果
http://www.pdfsharp.net/wiki/MigraDocDDL.ashx

Often it can help to check the DDL file to see if all settings are at the right places.
http://www.pdfsharp.net/wiki/MigraDocDDL.ashx

随意上传DDL文件,如果你解决不了的问题,无法自己阅读。

Feel free to upload a DDL file if you cannot solve the problem and cannot read it yourself.

这篇关于MigraDoc:为一个文件设置字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆