Hello everyone! I`m trying to do a method here in my application to create
Radio, checkbox or textfield inside a cell, but i`m not managing to do it.
I managed doing it with a select, but when I try any of those, it doesn`t
work at all.
Here`s my workaround:
Working select method:
public void createSelectBox(Rectangle rectangle, PdfContentByte[] canvas,
String[] options, String[] exportOptions, boolean readOnly)
throws IOException, DocumentException {
PdfWriter pw = canvas[0].getPdfWriter();
TextField tf = new TextField(pw, rectangle,
String.format("option_%s", type));
tf.setChoices(options);
tf.setChoiceExports(exportOptions);
tf.setChoiceSelection(4);
PdfFormField field2 = tf.getComboField();
if (readOnly) {
field2.setFieldFlags(PdfFormField.FF_READ_ONLY);
}
pw.addAnnotation(field2);
}
it is invoked from a switch:
@Override
public void cellLayout(PdfPCell cell, Rectangle rectangle,
PdfContentByte[] canvas) {
try {
switch (type) {
case FIELD_TYPE_CHECKBOX:
createCheckBoxField(rectangle);
break;
case FIELD_TYPE_RADIO:
createField(rectangle, canvas, checked, fieldName,
type, readOnly);
break;
case FIELD_TYPE_SELECT:
createSelectBox(rectangle, canvas, options,
exportOptions, readOnly);
break;
}
} catch (IOException | DocumentException ex) {
throw new ExceptionConverter(ex);
}
}
works just fine. But when I try to do anything like with redio or check, no
success at all:
this is the checkbox atempt:
public void createCheckBoxField(Rectangle rect) throws IOException,
DocumentException {
RadioCheckField rf = new RadioCheckField(writer, new
Rectangle(rect.getLeft(4), rect.getBottom(4),
rect.getRight(4), rect.getTop(4)), fieldName, "");
rf.setChecked(checked);
rf.setBorderColor(GrayColor.GRAYBLACK);
rf.setBackgroundColor(GrayColor.GRAYWHITE);
rf.setCheckType(RadioCheckField.TYPE_CHECK);
formField.addKid(rf.getCheckField());
}
I`m searching all over the internet but not having much of success rate :D
Thanks for the help
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php