user2025463
user2025463

Reputation: 95

Checkbox are not checking using iTextSharp in PDF

Hi I am trying to check the checkboxes in the pdf (which has 4 check boxes) but only first check box is checking and others are not. Below are the fields in pdf form for check boxes

topmostSubform[0].Page1[0].c1_01_0_[0];

topmostSubform[0].Page1[0].c1_01_0_[1];

topmostSubform[0].Page1[0].c1_01_0_[2];

topmostSubform[0].Page1[0].c1_01_0_[3];

When I use the below code

formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[0]", "1"); 

First checkbox is checked in pdf form. But similar way below code doesn't check the other checkboxes

formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[1]", "1");

formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[2]", "1");

formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[3]", "1");

Any ideas? Please help me.

Upvotes: 2

Views: 681

Answers (1)

user2025463
user2025463

Reputation: 95

Finally got the answer. The correct code for other check boxes is

formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[1‌​]", "2");
formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[2]"‌​, "3");
formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[3]"‌​, "4");

String[] checkboxstates = formFields.GetAppearanceStates("topmostSubform[0].Page1[0].c‌​1_01_0_[1]");

by using this we would know what would be the possible value for checkbox is

formFields.SetField("topmostSubform[0].Page1[0].c1_01_0_[1‌​]", checkboxstates[0]); 

Upvotes: 2

Related Questions