Hi,

for checkboxes and radiobuttons iText only considers the /V (value key):
String value = acroFields.getField(fieldName);

You only see /OFF thus the /V attribute is probably missing in your PDF
since many PDF Tools/Viewers do not set the value for
checkboxes/radiobuttons.
According to the PDF spec the /AS key should contain the correct state.
You can optain it like this:

PdfDictionary dict = entry.getValue().getWidget(0);
PdfName as = dict.getAsName(PdfName.AS);

if(as==null){
 // 'AS' key is missing which e.g. violates the PDF/A-1 spec
}
else{
   System.out.println(PdfName.decodeName(as.toString()));
}

Regards,
TvT

2015-02-09 14:11 GMT+01:00 Thomas Harre <thomas.ha...@abacus.ch>:

> Hi Eveybody
>
> I've got a PDF with 3 Checkboxes.
> One of these Checkboxes is selected, as can be seen in the attached PDF
> and in the attached screenshot.
>
> When I analyse the pdf file with following code i get this result:
>
>  for (Map.Entry<String, AcroFields.Item> entry :
> acroFields.getFields().entrySet()) {
>       String fieldName = entry.getKey();
>       String value = acroFields.getField(fieldName);
>       if (acroFields.getFieldType(fieldName) ==
> AcroFields.FIELD_TYPE_CHECKBOX) {
>         String[] appearanceStates =
> acroFields.getAppearanceStates(fieldName);
>         System.out.println("Checkbox: " + fieldName + " Value:" + value
> +
>             " AvailableValues:" + StringUtil.concatWithDelimiter(",",
> appearanceStates));
>       }
>     }
>
> Result:
> Checkbox: CheckBox_Group1 Value:Off AvailableValues:chk1,Off
> Checkbox: CheckBox_Group2 Value:Off AvailableValues:chk2,Off
> Checkbox: CheckBox_Group3 Value:Off AvailableValues:Off,chk3
>
> So all of the values are "Off".
> Is there something wrong with my pdf file or have I completely
> misunderstood something?
>
> Thanks for your help and kind regards
> Thomas
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming. The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is
> your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> 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
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
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