I am having an issue with adding fillable form fields to a table cell.
I can get the first text fields to be fillable on a pdf, but the rest of
the fields are not fillable. There are about 50 iterations through the
loop. Only the first field is editable.
However, when I use the tab key, it appears that the PDF recognizes that
there are more fields to "tab" to, but it just can't find them.
Here is the code:
public class Percent implements PdfPCellEvent {
private static Logger log = Logger.getLogger(Percent.class);
protected PdfWriter writer;
protected PdfFormField parent;
protected String partialFieldName;
public Percent(PdfWriter writer, PdfFormField parent, String name)
{
this.writer = writer;
this.parent = parent;
this.partialFieldName = name;
}
/**
* @see
com.lowagie.text.pdf.PdfPCellEvent#cellLayout(com.lowagie.text.pdf.PdfPCell,
* com.lowagie.text.Rectangle,
com.lowagie.text.pdf.PdfContentByte[])
*/
public void cellLayout(PdfPCell cell, Rectangle rect,
PdfContentByte[] cb) {
log.debug(
"rect.getLeft(0)/rect.getBottom(1)/rect.getRight(0)/rect.getTop(0)" +
rect.getLeft(0) + "/" + rect.getBottom(1) + "/"+ rect.getRight(0) +
"/" + rect.getTop(0));
Rectangle cellRectangle = new Rectangle(rect.getLeft(0),
rect.getBottom(1), rect.getRight(0), rect.getTop(0));
TextField tf = new TextField(writer, cellRectangle,
partialFieldName);
tf.setFontSize(10);
tf.setMaxCharacterLength(3);
tf.setAlignment(Element.ALIGN_CENTER);
tf.setBackgroundColor(Color.YELLOW);
try {
parent.addKid(tf.getTextField());
writer.addAnnotation(parent);
} catch (Exception e) {
log.error("Exception in cellLayout().", e);
}
}
}
Some code that will loop and want to add editable fields to a table
PdfPTable fundFamilyTable = new
PdfPTable(iColumnWidths.length);
Iterator it = details.iterator();
while (it.hasNext()) {
PafFundInfo fund = (PafFundInfo)it.next();
fundFamilyTable.addCell(getPdfName(fund.getFundName(),
fund.getFundFootnote(), BASE_FONT, SUPERSCRIPT_FONT));
fundFamilyTable.addCell(new
Paragraph(fund.getRiskClass().getRiskClassDescription(), SMALLER_FONT));
// fundFamilyTable.addCell(new
Paragraph("__________%", BASE_FONT));
PdfPCell cell = new
PdfPCell(fundFamilyTable.getDefaultCell());
cell.setPadding(CELL_PADDING);
cell.setBorderWidthBottom(0.2f);
PdfFormField field =
PdfFormField.createEmpty(writer);
field.setFieldName(fund.getFundNumber());
cell.setCellEvent(new Percent(writer, field,
fund.getFundNumber()));
fundFamilyTable.addCell(cell);
} //end of while loop for displaying details
//Add the last fund family
mainTable.addCell(fundFamilyTable);
End of code in question.
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and destroy any copies of this
document .
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/