ItextSharp (Itext) - set custom font for paragraph

被刻印的时光 ゝ 提交于 2019-12-08 16:41:56

问题


I am trying to set custom font to Paragraph, but I can't make it work. I tried setting .Font= , but it only works size-wise, but it ignores font. Could you please assist?

Paragraph T = new Paragraph(newTempLine);
iTextSharp.text.Font contentFont = iTextSharp.text.FontFactory.GetFont("Webdings", 12, iTextSharp.text.Font.NORMAL);
T.Font = contentFont;
myDocument.Add(T);

回答1:


Set it in the constructor:

Font contentFont = FontFactory.GetFont(…);
Paragraph para = new Paragraph(newTempLine, contentFont);


来源:https://stackoverflow.com/questions/9145127/itextsharp-itext-set-custom-font-for-paragraph

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