iTextSharp 5.5.6.0 Bug? check box tick mark changes

守給你的承諾、 提交于 2020-01-02 06:28:13

问题


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?


回答1:


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.




回答2:


iTextSharp to get "Tick Mark" in PDF file. Please try the below one

form.SetField("Check Box1", "Yes",true);



回答3:


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.



来源:https://stackoverflow.com/questions/30203307/itextsharp-5-5-6-0-bug-check-box-tick-mark-changes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!