Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MigraDoc: Setting font for a document

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.

like image 490
mkautzm Avatar asked Oct 25 '25 12:10

mkautzm


1 Answers

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.

like image 141
I liked the old Stack Overflow Avatar answered Oct 27 '25 00:10

I liked the old Stack Overflow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!