Sarah1 (12) [Avatar] Offline
#1
Hi,

The following is from your example RegisterForm1.java:
**************************************************************
PdfPTable table = new PdfPTable(2);
PdfPCell cell;
TextField field;

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

PDFTextField pdfTextField = new PDFTextField(writer);
pdfTextField.setFontSize(12);
pdfTextField.setFieldName("name");
field = pdfTextField.getTextField();

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

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?

Thanks.

Sarah
blowagie (284) [Avatar] Offline
#2
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.