问题
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