Search code examples
c#radio-buttonitextradio-grouppdfptable

Adding a radio button in PDFPCell iTextSharp


I am trying to add a radio button in itextsharp's pdfpcell. this is my code:

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);

this creates a text block instead of a radio button. Maybe it is because of using FieldPositioningEvents. I don't know how to create a custom cell event for radio buttons. Is there any simple way to do it?


Solution

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

    some references / examples can be found here Buttons iText Books / Examples Books|iText