Hi everyone,
Hi Arashi,
Thanks for contacting support.
In order to accomplish your requirement, you need to specify the item or index of items to be selected using the Selected property of ListBoxField class. Please take a look over the following code snippet.
In case you encounter any issue, please share the resource PDF so that we can test the scenario in our environment.
C#
var pdfDoc = new Document(@"C:\pdftest\sample.pdf");
foreach (Field field in pdfDoc.Form)
{
FindAndSetField(field);
}
pdfDoc.Save(@"C:\pdftest\ToAspose\ToAspose\2013I-9_Filled_NEW.pdf");
pdfDoc.Dispose();
private static void FindAndSetField(Field field)
{
if (field.FullName == "form1[0].#subform[6].State[0]")
{
var chexkboxField = (Aspose.Pdf.InteractiveFeatures.Forms.ListBoxField)field;
foreach(var item in chexkboxField.Options.Cast<Option>())
{
if (item.Value == "CA")
{
try
{
chexkboxField.Selected = item.Index;
}
catch (ArgumentException)
{
}
break;
}
}
}
else if (field.Count > 0)
{
foreach (Field subField in field)
{
FindAndSetField(subField);
}
}
}