を使用してPDFにフォームを追加しようとしていiText 7
ます。
フィールドの値を設定しようとすると、エラーが発生し続けます。メソッドのドキュメントから情報を見つけることができませんでしたaddKid()
。このエラーを回避する方法を知っている人はいますか?
私が使用しているコードのサンプルは次のとおりです。
PdfTextFormField confField = PdfFormField.createText(pdf);
confField.setFieldName(fieldName);
PdfWidgetAnnotation confCoverAnnot = new PdfWidgetAnnotation(new Rectangle(x, y, width, height));
PdfWidgetAnnotation confAnnot = new PdfWidgetAnnotation(new Rectangle(x2, y2, width2, height2));
for (int i = 1; i<= numPages; i++) {
switch(i) {
case 1:
pdf.getPage(i).addAnnotation(confCoverAnnot);
break;
default:
pdf.getPage(i).addAnnotation(confAnnot);
break;
}
}
/*
Trying to have two different annotations reference the same field value.
Upon using the `setValue()` method, I get: object.must.be.indirect.to.work.with.this.wrapper
Any way to get this to work properly?
*/
form.addField(confField);
confField.addKid(confCoverAnnot);
confField.addKid(confAnnot);
if (value.equals("") != true) {
confField.setValue(value); //error here
}