We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

I am trying to populate a checkbox on a pdf

The code below is not working. I cannot get the checkbox to show a check!


string myInput = ConfigurationManager.AppSettings["PDFPath"];

Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form();
//Open Document
pdfForm.BindPdf(myInput);

pdfForm.FillField("chk-Member-All", true);

string myOutput = ConfigurationManager.AppSettings["OutputPath"];
pdfForm.Save(myOutput);

Hi Nancy,


Thanks for contacting support.

In order to set the value for checkbox, you may consider using following code snippet.

[C#]

Document doc = new Document(@“C:\pdftest\Test.pdf”);<o:p></o:p>

CheckboxField field = doc.Form[“rbTITerm”] as CheckboxField;<o:p></o:p>

field.Value = “Annually”;<o:p></o:p>

doc.Save(@“C:\pdftest\Test_Filled.pdf”);<o:p></o:p>


Furthermore, in order to get list of valid checkbox names, new property AllowedStates was added to CheckboxField.


foreach (string state in field.AllowedStates)<o:p></o:p>

Console.WriteLine(state);


In case the problem still persists, please share the resource PDF form, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Please provide the namespaces for your examples.

Hi Nancy,


Thanks for your feedback. Please check following code snippet with complete object refeneces, hopefully it will help you to accomplish the task.

Aspose.Pdf.Document
doc = new Aspose.Pdf.Document(@“C:\pdftest\Test.pdf”);<o:p></o:p>

Aspose.Pdf.InteractiveFeatures.Forms.CheckboxField field = doc.Form["rbTITerm"] as Aspose.Pdf.InteractiveFeatures.Forms.CheckboxField;

field.Value = "Annually";

doc.Save(@"C:\pdftest\Test_Filled.pdf");


Please feel free to contact us for any further assistnace.


Best Regards,