hello,

I'm working with forms in pdf files. Each file has a different form and so I
have to analyze each one and get the data entered. I'm using iText 5.3.1 and
Java 6.

In my current flow of code I'm working as follows:
1 - I get the file with form filled in a instance of a ByteArray class.

2 - I create an instance of the class PdfReader using the ByteArray.
       -> PdfReader reader = new PdfReader (baos);

3 - Use the instance of the reader to create an instance of the class
AcroFields, and thus obtain the fields.
       -> AcroFields fields = reader.getAcroFields();

4 - I create an instance of the Map class, and copy the keys of the map to
get the names of the fields present in this pdf file.
       -> Map<String,AcroFields.Item> map = fields.getFields();
       -> ArrayList<String> pdfItemsNames = new ArrayList<String>();
       -> For (int i = 0; i <map.size (); i + +) {
                        String itemName = (String) map.keySet().toArray()[i];
                        pdfItemsNames.add (itemName);
                  }

5 - For each name in the pdfItemsNames ArrayList, I try to get the value and
store in another ArrayList.
       -> ArrayList<String> pdfItemsValues = new ArrayList<String>();
       -> for (int j = 0 j < pdfItemsNames.size (); j + +) {                    
                        
pdfItemsValues.add(fields.getField(pdfItemsNames.get(j)));
                  }

For components: TextField, Drop-down List and List-box the values are
obtained correctly.
Output: //FORMAT-> (type of component - component name in the file ->
value)//
(Drop-down List - P1_DD1 -> TEST1)
(List box - P1_LT1 -> TEST3)
(TextField - P1_TF1 -> ramdom text)

But for the components: Checkbox and Radio Button values are not obtained
correctly. 

When i find a checkbox in pdf, iText returns me the name of the group that
belongs checkbox, not the checkbox object. 
Furthermore, I can only get the value of the first checkbox and is always in
a state "Off".

For the radio button component, the same behavior happens. 
But the value returned by iText is the name of the first radio button. I can
not even get if he was selected or not.

Output: // FORMAT-> (type of component - component name in the file ->
value) //
(checkbox - CheckBox Group1 -> Off)
(radio Button - Group1 Radio Button -> P1_RB1)
(checkbox - CheckBox Group2 -> off)

I need help on how to manipulate these components. 
When I find a checkbox group or a group of radio buttons, how do I know how
many elements there are in the group, and which elements were selected?

In the book, I've read the entire chapter 8. 
In Section 8.2 is an example that is close to what I am asking, however the
pdf I work do not have javascript, only the fields of the forms.

Thanks in advance.



--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/How-to-manipulate-and-get-the-value-of-checkbox-and-radio-button-groups-tp4656269.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
iText-questions mailing list
[email protected]
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