« Return to Thread: Problem with AcroFields and RadioButton

Problem with AcroFields and RadioButton

by precyz :: Rate this Message:

Reply to Author | View in Thread

I have a proper pdf document with RadioButtons and TextFields inside. I read this document and extract all AcroFilds. After that i put same data to this AcroFields and stored document in a file. My problem is: all Text Fields are fill in properly but i do not know how put (eg.) 'X' to RadioButton. This RadioButton has four options. I use this code to put same data in to AcroFields:

public void putDataToFields(String file_name) {
        PdfReader reader = null;
        HashMap fields = null;
        try {
            reader = new PdfReader(acro_in_path + file_name);
            AcroFields form = reader.getAcroFields();
            fields = form.getFields();
            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(path + "out_" +file_name));
            form = stamper.getAcroFields();
            String key;
            for (Iterator i = fields.keySet().iterator(); i.hasNext();) {
                key = (String) i.next();
                if ("radioButton_name".equalsIgnoreCase(key)) {

                       //this is the place where i want to mark one option for radio button

                }
                else form.setField(key, "Some text");
            }
            stamper.setFormFlattening(true);
            stamper.close();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (DocumentException e) {
            e.printStackTrace();
        }
    }

I'd like to mark for egzample second option. Could someone halp me ?

 « Return to Thread: Problem with AcroFields and RadioButton

LightInTheBox - Buy quality products at wholesale price