I have an existing PDF that I am filling in programmatically (C#).
There are check boxes on the form. In build 4.4.x they rendered a check mark when selected. In build 5.5.5.0 and 5.5.6.0 they are now a cross symbol. The document has PdfVersion of 54 '6'.
I have tried:
SetFieldProperty(fieldname, "checkboxtype", RadioCheckField.TYPE_CHECK, null);
but with no luck.
Also I searched for the potential property list, but cannot seem to find a list of valid string values. Is the iText in Action -> Table 8.3 a complete listing?
I was having this exact problem. If I manually filled out the PDF form in Adobe it put checkmarks, but if I used iTextSharp, it put crosses. What worked for me to make iTextSharp put checkmarks was using:
SetField("checkbox name", "Yes", true);
The 'true' at the end changed it from a cross to a checkmark. Hope that helps you.
As other comments have stated, casting cannot be done on a PDF that was already created.
On the other hand, if you are filling out an existing PDF you can still change the check type of a CHECKBOX using Adobe Acrobat Pro. First, open the pdf with Adobe Acrobat Pro then click Tools-> Forms-> Edit then double click the field to open up the Field Properties, in this case Check Box Properties, then Options and change the "Check Box Style" to whatever you want.
In your code, use the lines:
AcroFields pdfFormFields = pdfStamper.AcroFields;
pdfFormFields.SetField("checkbox name", "Yes", true);
The "true" flag makes it so that iTextSharp uses the check box style that you chose when using Adobe Acrobat Pro.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With