CheckBoxField behave like Radio button

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.

  1. All CheckBoxField need to have the same name. (How to do this with the API?).
  2. 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);
}

This is how to do it with ADOBE.





There’s just one simple rule to follow when you create mutually

exclusive check boxes. The field names need to be identical and

the export values need to be different. If field names are different,

each box in a group can be checked regardless of the export

value.



That’s what I need to do using the PDF API.



Help please.

Hi,


Thanks for contacting support.

As shared in your other forum thread, the feature is currently not supported and its logged as PDFNEWNET-38173 in our issue tracking system. The development team will further look into the details of this requirement and we will keep you posted with our findings.

I was able to do this by adding javascript to the fields.

Hi,


Thanks for the feedback.

We are glad to hear that your requirement is accomplished by using JavaScript. However we will be working on implementing this feature in Aspose.Pdf for .NET API and will keep you posted with our findings.

The issues you have found earlier (filed as PDFNEWNET-38173) have been fixed in Aspose.Pdf for .NET 11.2.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(2)

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan