Skip to main content
Skip table of contents

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);
//TODO set export value"exportValue is " + fieldVO.getExportValue());
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 “Export value” you are asking about. PdfButtonFormField checkBox1 = PdfFormField.createCheckBox(pdfDoc,new Rectangle(10, 650, 40, 20), "checkbox1", "MyExportValue");

By default 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.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.