[英]How to change color of a text field in pdfclown?
I want to fill in a PDF form. 我想填写一份PDF表格。 I am using library Pdfclown for this.
我正在使用库Pdfclown。
I have a problem changing the color of a TextField
. 我在更改
TextField
的颜色时遇到问题。 I can change font size without problems, but not the color of the text. 我可以毫无问题地更改字体大小,但不能更改文本的颜色。
I put the code where I managed to set values in the PDF form: 我将代码放在我设法以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);
}
}
} }
DefaultStyle
applies itself to TextField
instances like this: DefaultStyle
将自身应用于TextField
实例,如下所示:
...
if(isGraphicsVisibile())
{
composer.beginLocalState();
composer.setLineWidth(lineWidth);
composer.setFillColor(getBackColor());
composer.setStrokeColor(getForeColor());
composer.drawRectangle(frame, 5);
composer.fillStroke();
composer.end();
}
...
( apply(TextField)
in DefaultStyle.java ) (在DefaultStyle.java中
apply(TextField)
)
Thus, you might have to set 因此,您可能必须设置
style.setGraphicsVisibile(true);
before applying your style
to field
. 在将您的
style
应用于field
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.