Hi to all.

  I’m trying to create form field in a PDF using iText. But I don’t know the absolute position of this fields on the final document nor in the final page. I find a way to add Text Fields to a document relatively to the text added to it, but now I need to do the same with CheckBox, Radio Button, List and Combos.

 

  To add Text Fields relatively to a text, I create a Chunk and asociate text field to the Chunk’s annotation, following this : Chunk.setAnnotation (annotation). This works, but when I tried the same way with check boxes, the controls do not appear on the PDF.

 

  Here is the source code than I try:

 

nuevo_elemento = new Chunk (“”);                                                                    // Chunk to set the relative position of the Check Box.

 

            PdfFormField check1 = PdfFormField.createCheckBox(escritor);

            Rectangle rect = new Rectangle(0, 0, 20, 20);                                                    // Position to set the widget

            check1.setFieldName("tarjetaCredito");

            check1.setValueAsName("Off");

            check1.setWidget(rect, PdfAnnotation.HIGHLIGHT_INVERT);

            check1.setAppearanceState("Off");

            check1.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", tpOff2);

            check1.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", tpOn2);

            nuevo_elemento.setAnnotation(check1);                                                            // Associate Check Box (check1) with his content Chunk (nuevo_elemento)

            doc.add (nuevo_elemento);

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to