Eric Lou wrote:
i've changed the code, make it look into /AP
it seems the values are there, but...how to get them?

You have them:
    /D : Dictionary
        /Off : 204 0 R
        /this#20is#20value#203 : 203 0 R
    /N : Dictionary
        /Off : 202 0 R
        /this#20is#20value#203 : 201 0 R

What's your problem?
See the attached example. What are you missing?
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
import java.io.IOException;
import java.util.Iterator;

import com.lowagie.text.pdf.AcroFields;
import com.lowagie.text.pdf.PdfDictionary;
import com.lowagie.text.pdf.PdfName;
import com.lowagie.text.pdf.PdfReader;


public class RadioButtons {

        public static void main(String[] args) throws IOException {
                PdfReader reader = new PdfReader("aDoc1.pdf");
                AcroFields form = reader.getAcroFields();
                // the easy way
                String[] s = form.getAppearanceStates("Radio Button1");
                for (int i = 0; i < s.length; i++) {
                        System.out.println(s[i]);
                }
                // the hard way
                AcroFields.Item item = form.getFieldItem("Radio Button1");
                PdfDictionary dict;
                PdfDictionary ap;
                PdfName key;
                for (int i = 0; i < item.size(); i++) {
                        System.out.println("Value " + i);
                        dict = item.getMerged(i);
                        ap = dict.getAsDict(PdfName.AP);
                        dict = ap.getAsDict(PdfName.N);
                        for (Iterator it = dict.getKeys().iterator(); 
it.hasNext(); ) {
                                key = (PdfName)it.next();
                                
System.out.println(PdfName.decodeName(key.toString()));
                        }
                        dict = ap.getAsDict(PdfName.D);
                        for (Iterator it = dict.getKeys().iterator(); 
it.hasNext(); ) {
                                key = (PdfName)it.next();
                                
System.out.println(PdfName.decodeName(key.toString()));
                        }
                }
        }
}
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to