iTextSharp Textfield将字​​体设置为Bold [英] iTextSharp Textfield setting the font to Bold

查看:187
本文介绍了iTextSharp Textfield将字​​体设置为Bold的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于textfield对象,我想将样式更改为粗体。我已经创建了arial字体,因为它不是BaseFont对象的默认字体。显然,TextField对象仅将BaseFont作为有效字体。我想知道如何将我分配给文本字段的字体样式更改为粗体。有没有办法做到这一点?这是我到目前为止的代码

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; 

提前谢谢!

推荐答案

您是否尝试过指定 arialbd.ttf 作为字体名称?我认为无论如何都会得到更好的结果,因为粗体字体会被调整。

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.

(我不知道为什么你不能指定一个<$ c对于TextField,$ c> Font ,诚然......)

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

这篇关于iTextSharp Textfield将字​​体设置为Bold的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆