MigraDox C# Checkboxes - Wingdings Not Working

非 Y 不嫁゛ 提交于 2019-12-23 05:47:35

问题


I am needing to simulate a checkbox in a PDF I am generating using the MigraDoc library. I stumbled across two sources that offer essentially the same solution (here and here)

However, I am not getting the expected results. Instead I am getting þ for boxes that are supposed to be checked, and ¨ for those that are to be unchecked. What might the issue be?

Snippet of my code

     para = section.AddParagraph();
        para.Style = "ListLevelOne";
         para.AddFormattedText("1 ", "Bold");
         para.AddFormattedText(IsQ1Checked ? "\u00fe" : "\u00A8", new Font("Wingdings"));

回答1:


MigraDoc does not use the font "Wingdings", instead it uses a default font (could be MS Sans or so) and therefore you see the characters from a standard font, not the Wingdings symbol.

The problem is somewhere outside the code snippet you are showing here. Make sure the font Wingdings is installed on the computer.




回答2:


You may want to embed the font and ensure that MigraDoc uses unicode encoding instead of ansi:

private const bool unicode = true;
private const PdfFontEmbedding embedding = PdfFontEmbedding.Always;
//...
var pdfRenderer = new PdfDocumentRenderer(unicode, embedding);

http://www.pdfsharp.net/wiki/migradochelloworld-sample.ashx



来源:https://stackoverflow.com/questions/42977692/migradox-c-sharp-checkboxes-wingdings-not-working

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