I need to add multiple checkboxfield, but only one can be checked. How do I do this please?
I can’t use RadioButtonFields because I need to pass a page to the constructor and I do not know that information when creating the PDF dynamically.
I was able to get that functionality working if I modified the PDF with ADOBE and doing the following.
- All CheckBoxField need to have the same name. (How to do this with the API?).
- Set the Export Value to different values Male, Female, etc…(How to do this with the API?).
Thanks
This is the code that I’m using to add the checkboxfield.
private void AddCheckBoxField(ref Aspose.Pdf.Row row, ref Aspose.Pdf.Cell cell, int controlId, Dictionary dictNameValue, string labelText, string checkValue, List columnWidth, int index)
{
double width = 16;
double height = 12;
Aspose.Pdf.Text.TextFragment label;
string text;
string id = GetStringValue(“ID”, dictNameValue, “IdNotFound”); ;
CheckboxField field = new CheckboxField();
field.PartialName = id;
//field.MappingName = id;
field.Exportable = true;
//field.IsSharedField = true;
field.Width = width;
field.Height = height;
if (!string.IsNullOrEmpty(checkValue))
{
field.Value = checkValue;
}
field.IsInLineParagraph = true;
//Add CheckBox control to the current cell
row.FixedRowHeight = 16;
cell.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F);
cell.Paragraphs.Add(new Aspose.Pdf.Text.TextFragment(" “));
cell.Paragraphs.Add(field);
//Set the Text property
if (string.IsNullOrEmpty(labelText))
{
text = CleanText(GetStringValue(“Text”, dictNameValue, “”));
}
else
{
text = CleanText(labelText);
}
label = new Aspose.Pdf.Text.TextFragment(” " + text);
label.TextState.FontSize = 8;
//Add Label control to a new cell
cell = row.Cells.Add();
cell.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.None, 0.1F);
cell.Paragraphs.Add(label);
}