我想填写一份 PDF 表格。我正在为此使用库 Pdfclown。
我在更改 a 的颜色时遇到问题TextField
。我可以毫无问题地更改字体大小,但不能更改文本的颜色。
我将代码放在我设法在 PDF 表单中设置值的位置:
public void setPDF(String Valor, String aField) {
Form form = document.getForm();
for (Field field : form.getFields().values()) {
if (aField.equals(field.getName())) {
DefaultStyle style = new DefaultStyle();
style.setForeColor(DeviceRGBColor.get(Color.red));
String newValue = Valor;
field.setValue(newValue);
style.apply(field);
}
}
}