In want to add interactive formfields like checkboxes to a newly created multiple page PDF, in the example from iText the code looks like this:
PdfContentByte canvas = writer.getDirectContent();
Rectangle rect = new Rectangle(180, 806 * 40, 200, 788 * 40);
RadioCheckField checkbox = new RadioCheckField(writer, rect, "box1", "Yes");
PdfFormField field = checkbox.getCheckField();
writer.addAnnotation(field);
ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, new Phrase("checkbox1", normal), 210, 790 * 40, 0);
But this uses absolute positions and I don't know the position because the content before the field has optional images and text parts, where I don't know how many lines they take. I am also using Chapters and Sections, so I would like to use something like this:
Section section = chap.addSection(new Paragraph("sectionTitel",header2));
section.add(new Paragraph("line before field"));
//add FormField
section.add(field);
section.add(new Paragraph("line after field"));
Have you an idea how to do something like this or how to get the position from the line before ?