iTextSharp Textfield setting the font to Bold

六月ゝ 毕业季﹏ 提交于 2019-12-04 04:36:29

问题


For a textfield object, I would like to change the style to bold. I have already created the arial font since it is not a default font for the BaseFont object. Apparently the TextField object only takes the BaseFont as a valid font. I was wondering how would I change the style of the font that I have assigned to my textfield to bold. Is there a way to do this? here is my code that I have thus far

TextField txtNewField = new TextField(stamp.Writer, new Rectangle(1, 1, 75, 25), "TxtField"); 
BaseFont arial = BaseFont.CreateFont(@"c:\windows\fonts\arial.ttf", BaseFont.CP1252, BaseFont.NOT_EMBEDDED); 
txtNewField.FontSize = 8; 
txtNewField.Font = arial; 

Thank you in advance!


回答1:


Have you tried specifying arialbd.ttf as the font name? I think that will give better results anyway, as the bold font will have been tuned.

(I'm not sure why you can't just specify a Font for a TextField, admittedly...)



来源:https://stackoverflow.com/questions/3497124/itextsharp-textfield-setting-the-font-to-bold

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