MigraDoc: Setting font for a document

允我心安 提交于 2019-12-10 11:27:22

问题


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";

Then the MigraDoc code itself:

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

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.


回答1:


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

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

Code looks OK.

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

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



来源:https://stackoverflow.com/questions/19275073/migradoc-setting-font-for-a-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!