Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » iText »

[iText-questions] help on Two TextFields with the same name

wang yun

2005-06-23


Dear help,

I try to create two text fields with the same name
"CreditCard". I try to set the value "Visa".
But, please see the attaced pdf. "Visa" doesn't
apppear
when I open test.pdf. As I click into the box, "Visa"
does come out.

I need that "Visa" to show at the opening pdf.

Thanks for help.




Document document = new Document(PageSize.A4, 50, 50,
50, 50);
PdfWriter writer = PdfWriter.getInstance(document, new
FileOutputStream("test.pdf"));
       
document.open();
PdfFormField ff = PdfFormField.createTextField(writer,
false,false,0);
ff.setFieldName("CreditCard");
ff.setValueAsName("Visa");

TextField app1 = new TextField(writer, new
Rectangle(100, 700, 100 + 200, 700 + 20), null);
PdfFormField field1 = app1.getTextField();
       
TextField app2 = new TextField(writer, new
Rectangle(100, 650, 100 + 200, 650 + 20), null);
PdfFormField field2 = app2.getTextField();
     
ff.addKid(field1);
ff.addKid(field2);

writer.addAnnotation(ff);
   
document.close();

Attachment: test.pdf
©2008 junlu.com - Jax Systems, LLC, U.S.A.