I added a textfield with several kids similar as described here. Did that to use the autofill functionality of PDF... Now my question is how am I able to remove the page reference from the parent element? The data field should not contain a parent reference since it is not related to any page. The widgets should contain those (which I added there however I can't remove the parent /P page reference)
I tried
PdfFormField parent = PdfFormField.createTextField(stamper.getWriter(), false, false, 0);
parent.setFieldName(fieldName);
for (int page = 1; page <= pages; page++) {
TextField textField = new TextField(stamper.getWriter(), new Rectangle(560, 600, 590, 800), null);
PdfFormField pff = textField.getTextField();
parent.addKid(pff);
// add widget to each page
pff.setPlaceInPage(page);
//iText workarounds
field.put(PdfName.P, stamper.getWriter().getPageReference(page));
field.remove(PdfName.FF);
field.remove(PdfName.FT);
}
//in addAnnotation() the page reference is written
stamper.addAnnotation(parent, 1);
//does not work
parent.remove(PdfName.P);
however it didn't work since I guess the page reference is already written. Is there a way to remove it afterwards?