Sarah1 (12) [Avatar] Offline

The following is from your example
PdfPTable table = new PdfPTable(2);
PdfPCell cell;
TextField field;

table.addCell("Your name:");
cell = new PdfPCell();

PDFTextField pdfTextField = new PDFTextField(writer);
field = pdfTextField.getTextField();

cell.setCellEvent(new RegisterForm1(parent, field.getTextField(), 1));

Can I directly add the PDFTextField to PdfPCell? Why I have to do cell.setCellEvent(PdfPCellEvent)?

I just want to create a simple form, do I have to wirte a class which must implement PdfPCellEvent?


blowagie (284) [Avatar] Offline
Re: add text field to PdfPCell problem
> Why I have to do cell.setCellEvent(PdfPCellEvent)?

Because that's the way it works.
You can create most of the other building blocks (Phrase, Paragraph, List,...) without specifying coordinates, but to construct annotations and fields, you need to pass a Rectangle defining the position of the element. That's done in a cell event.