How to set the export value of a check box?

I need to add a check box to an existing PDF. I also need set the export value of this check box. I saw that I can get the possible values of an existing check box by looking at the appearance dictionary (/AP), but I don't know how to set the export value for a new checkbox.

With export value I mean the value which is marked in the screenshot

Check box export value

Here is my code to create a check box, but the export value is always empty:

 

PdfFormField checkbox = PdfFormField.createCheckBox(stamper.getWriter());
checkbox.setWidget(fieldVO.rect, PdfAnnotation.HIGHLIGHT_NONE);
checkbox.setFieldName(fieldVO.getNewName());
//TODO set export value
log.info("exportValue is " + fieldVO.getExportValue());
break;
Posted on StackOverflow on Jul 15, 2015 by Al Phaba

In iText7 to create a checkbox you should use: createCheckBox(PdfDocument doc, Rectangle rect, String name, String value)

The value you insert will be the value of  the“Export value” you are asking about.

PdfButtonFormField checkBox1 = PdfFormField.createCheckBox(pdfDoc,new Rectangle(10, 650, 40, 20), "checkbox1", "MyExportValue");

By default the checkbox has two states: “Off” and “Yes”. In our case instead of “Yes” we will have the “MyExportValue”.

Click this link if you want to see how to answer this question in iText 5.



Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now