J'essaie d'ajouter un formulaire à un pdf en utilisant iText 7
.iText7 setValue méthode ne fonctionne pas
Je continue d'obtenir une erreur lorsque j'essaie de définir la valeur du champ. Je n'ai pas pu trouver d'informations à partir du documentation de la méthode addKid()
. Est-ce que quelqu'un sait comment contourner cette erreur?
Voici un échantillon du code J'utilise:
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
}
Merci pour la clarification. Fait sens maintenant :) – Elliot