Op 3/08/2013 16:49, Jason Hamm schreef:
I am using Itext to create a pdf and I cannot get the checkbox to uncheck.
Here is my code:

RadioCheckField bt = new RadioCheckField(writer, new Rectangle(100,
                 100, 200, 200), "radio", "v1");
bt = new RadioCheckField(writer, new Rectangle(300, 300, 400, 400),
                 "check1", "Yes");
bt.setCheckType(RadioCheckField.TYPE_CHECK);
bt.setBorderWidth(BaseField.BORDER_WIDTH_THICK);
bt.setBorderColor(BaseColor.BLACK);
bt.setBackgroundColor(BaseColor.WHITE);
bt.setChecked(false);
PdfFormField ck = bt.getCheckField();
writer.addAnnotation(ck);

You can see that the bt.setChecked(false) is in the code, but the checkbox
is still checked. I looked at the docs and it seems to me that it is
supposed to work this way. What do I not understand?

The problem you're reporting can't be reproduced.
See code and PDF in attachment.

Attachment: checkboxproblem.pdf
Description: Adobe PDF document

package examples.forms;

import java.io.FileOutputStream;
import java.io.IOException;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseField;
import com.itextpdf.text.pdf.PdfFormField;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.pdf.RadioCheckField;

public class CheckboxProblem {

        public static void main(String[] args) throws IOException, 
DocumentException {
                Document document = new Document();
                PdfWriter writer = PdfWriter.getInstance(document, new 
FileOutputStream("checkboxproblem.pdf"));
                document.open();
                RadioCheckField bt = new RadioCheckField(writer, new 
Rectangle(300, 300, 400, 400), "check1", "Yes");
                bt.setCheckType(RadioCheckField.TYPE_CHECK);
                bt.setBorderWidth(BaseField.BORDER_WIDTH_THICK);
                bt.setBorderColor(BaseColor.BLACK);
                bt.setBackgroundColor(BaseColor.WHITE);
                bt.setChecked(false);
                PdfFormField ck = bt.getCheckField();
                writer.addAnnotation(ck);
                document.close();
        }
}
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to