在PDFPCell iTextSharp中添加单选按钮

时间:2015-12-10 18:32:51

标签: c# radio-button itextsharp radio-group pdfptable

我正在尝试在itextsharp的pdfpcell中添加一个单选按钮。这是我的代码:

var rf1 = new RadioCheckField(writer, new Rectangle(10,10), "cellRadioBox", "Yes");
rf1.Checked = true;
rf1.CheckType = RadioCheckField.TYPE_CHECK;
PdfFormField field = rf1.CheckField;

var radioEvents = new iTextSharp.text.pdf.events.FieldPositioningEvents(writer, rf1.GetRadioGroup(false,true));
radioCell.CellEvent = radioEvents;
table.AddCell(radioCell);

这会创建一个文本块而不是单选按钮。也许是因为使用了FieldPositioningEvents。我不知道如何为单选按钮创建自定义单元格事件。有没有简单的方法呢?

1 个答案:

答案 0 :(得分:0)

Rectangle rect = new Rectangle(10,10);
var rf1 = new RadioCheckField(writer, rect, LANGUAGES[i], "on");
rf1.CheckType = RadioCheckField.TYPE_CHECK;
PdfFormField field = rf1.CheckField;

可在此处找到一些参考/示例Buttons iText图书/示例Books|iText