如何设置PdfWidgetAnnotation的字体名称和字体大小? - 用于Java的iText 7.1.0

时间:2018-01-15 12:13:46

标签: itext7

字段“fName”的2个represantations现在工作正常。但我不知道如何为2个小部件设置字体名称和字体大小。没有字体属性。我尝试了很多,但没有成功。也许可以为文档和所有创建的小部件设置标准字体名称和字体大小?

感谢您的帮助!德克

#with function
clu<- function(fitmodel,clusterby ) {
require(multiwayvcov, quietly = TRUE)
require(lmtest, quietly = TRUE)
a<-cluster.vcov(fitmodel, ~ clusterby)
coeftest(fitmodel, a)
}

clu(fit,foreign)

1 个答案:

答案 0 :(得分:1)

iText7 currently does not allow to configure different fonts and font sizes for widgets of a single text field. However, if having the same appearance is fine, then you can set font and font size for the field itself, right before setting the value. This will propagate to all the child widgets.

PdfFont font = PdfFontFactory.createFont(StandardFonts.COURIER);
field.setFont(font);
field.setFontSize(5);
field.setValue("Dirk");
form.addField(field, page);

Note that this is not the font name per se, but rather it's a PdfFont instance. If the font you are trying to use is not one of the standard fonts, then you have to specify the path to the font file when you are calling PdfFontFactory.createFont.