Discussion:
[iText-questions] check if a checkbox is selected
Thomas Harre
2015-02-06 09:23:35 UTC
Permalink
Hi Everybody

I'm struggeling to find a way to find out whether a checkbox is checked
or not and would appreciate a little help.
As far as I could collect from googeling the matter I've figured out
that I'm supposed to compare the value of the AcroField to the
available appearanceStates.
My problem however is that I don't know which one of the
appearanceStates is the one representing the "checked" state.
Is there any way to find that out without looking at the document
manually?

In the attachment there's a PDF document that hast 16 checkboxes with
several combinations of checked/unchecked, differet
export values (1, true, Ja, x) and differences in whether they are
checked by default or not.

With the following java code I extracted the values and available
values

String pdfPath =
getClass().getResource("DemoCheckbox.pdf").getPath();
PdfReader pdfReader = new PdfReader(pdfPath);
AcroFields acroFields = pdfReader.getAcroFields();
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));
}
}

Checkbox: box_1_clear Value: AvailableValues:Off,1
Checkbox: box_1_ticked Value:1 AvailableValues:Off,1
Checkbox: box_1_bydefault_cleared Value:Off AvailableValues:Off,1
Checkbox: box_1_bydefault_ticked Value:1 AvailableValues:Off,1
Checkbox: box_true_clear Value: AvailableValues:true,Off
Checkbox: box_true_ticked Value:true AvailableValues:true,Off
Checkbox: box_true_bydefault_clear Value:Off AvailableValues:true,Off
Checkbox: box_true_bydefault_ticked Value:true
AvailableValues:true,Off
Checkbox: box_ja_clear Value: AvailableValues:Ja,Off
Checkbox: box_ja_ticked Value:Ja AvailableValues:Ja,Off
Checkbox: box_ja_bydefault_clear Value:Off AvailableValues:Ja,Off
Checkbox: box_ja_bydefault_ticked Value:Ja AvailableValues:Ja,Off
Checkbox: star_x_clear Value: AvailableValues:Off,x
Checkbox: star_x_ticked Value:x AvailableValues:Off,x
Checkbox: star_x_bydefault_clear Value:Off AvailableValues:Off,x
Checkbox: star_x_bydefault_ticked Value:x AvailableValues:Off,x

Clearely I cannot rely on the order of the available values.
So from what I can gather the checkbox is always checked if the value
is not 'Off'.
But is this garanteed?
Or is there another possibillity to figure out if the checkbox is
actually checked or not?

Thanks in advance for your help and kind regards
Thomas
iText mailing list
2015-02-06 13:17:21 UTC
Permalink
Post by Thomas Harre
But is this garanteed?
See ISO-32000-1 section 12.7.4.2.3 "Check Boxes": The appearance for the
off state is optional but, if present, shall be stored in the appearance
dictionary under the name Off. Yes should be used as the name for the on
state.

People who are used to reading ISO specifications know that "shall"
means that a normative rule is imposed: no other name, except "Off" is
allowed for the off state.
People who are used to reading ISO specifications also know that
"should" means that a recommendation is being made: it is recommended to
use "Yes" for the on state, but if you use any other name, your PDF is
still valid. (And it is common practice to use names other than "Yes".)

Does this answer your question?

------------------------------------------------------------------------------
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-***@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
Thomas Harre
2015-02-06 14:28:47 UTC
Permalink
Hi

Thanks for your fast reply.

If I have understood you correctly, it is safe to assume a checkbox is
selected, if the value is a value from the available Values but not
"Off".

But to be honest I don't know what is meant by "The appearance for the
off state is optional".
Does this mean it's possible to have checkboxes that can only ever be
selected?

Kind regards
Thomas
Post by Thomas Harre
But is this garanteed?
See ISO-32000-1 section 12.7.4.2.3 "Check Boxes": The appearance for
the
off state is optional but, if present, shall be stored in the
appearance
dictionary under the name Off. Yes should be used as the name for the
on
state.

People who are used to reading ISO specifications know that "shall"
means that a normative rule is imposed: no other name, except "Off" is

allowed for the off state.
People who are used to reading ISO specifications also know that
"should" means that a recommendation is being made: it is recommended
to
use "Yes" for the on state, but if you use any other name, your PDF is

still valid. (And it is common practice to use names other than
"Yes".)

Does this answer your question?

------------------------------------------------------------------------------
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-***@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-***@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
iText mailing list
2015-02-06 15:11:26 UTC
Permalink
Post by Thomas Harre
If I have understood you correctly, it is safe to assume a checkbox is
selected, if the value is a value from the available Values but not
"Off".
Yes, a PDF in which the "Off" appearance doesn't corresponds with the
off state is in violation with the PDF specification.
Post by Thomas Harre
But to be honest I don't know what is meant by "The appearance for the
off state is optional".
Does this mean it's possible to have checkboxes that can only ever be
selected?
No. It means that you can have a check box for which only the appearance
of the on state is defined. In that case, there will be no "Off"
appearance: it will be just blank.

What's the point of this? you might ask.
Imagine a paper form that is scanned. There are already appearances of
check boxes in the PDF because the PDF mimics the paper form completely.
Now somebody adds interactive check boxes that can be selected
interactively. In this case, there's no real need to define an
appearance for the off state: the check boxes are already there. It's
sufficient to create an appearance for the on state.
Now when the check box is toggled between the on and off state, you'll
see the appearance for the on state when checked, and you see nothing
when not checked. In reality you'll always keep seeing the check box of
the scanned image.
Does that make sense?

------------------------------------------------------------------------------
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-***@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
Thomas Harre
2015-02-08 10:41:28 UTC
Permalink
Hi

Thanks a lot. That was of great help to me.

kind regards
Thomas
Post by Thomas Harre
If I have understood you correctly, it is safe to assume a checkbox is
selected, if the value is a value from the available Values but not
"Off".
Yes, a PDF in which the "Off" appearance doesn't corresponds with the
off state is in violation with the PDF specification.
Post by Thomas Harre
But to be honest I don't know what is meant by "The appearance for the
off state is optional".
Does this mean it's possible to have checkboxes that can only ever be
selected?
No. It means that you can have a check box for which only the
appearance
of the on state is defined. In that case, there will be no "Off"
appearance: it will be just blank.

What's the point of this? you might ask.
Imagine a paper form that is scanned. There are already appearances of

check boxes in the PDF because the PDF mimics the paper form
completely.
Now somebody adds interactive check boxes that can be selected
interactively. In this case, there's no real need to define an
appearance for the off state: the check boxes are already there. It's
sufficient to create an appearance for the on state.
Now when the check box is toggled between the on and off state, you'll

see the appearance for the on state when checked, and you see nothing
when not checked. In reality you'll always keep seeing the check box of

the scanned image.
Does that make sense?

------------------------------------------------------------------------------
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-***@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-***@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
Thomas Harre
2015-02-09 13:11:31 UTC
Permalink
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
TvT
2015-02-09 13:46:13 UTC
Permalink
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
Post by Thomas Harre
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.
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));
}
}
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
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/
http://itextpdf.com/themes/keywords.php
Thomas Harre
2015-02-09 13:59:04 UTC
Permalink
Hi,

Thanks, that does the trick.

But what is the difference between the /V and /AS values?
Or what do they even stand for?

kind regards,
Thomas
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
Post by Thomas Harre
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.
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(",",
Post by Thomas Harre
appearanceStates));
}
}
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
------------------------------------------------------------------------------
Post by Thomas Harre
Dive into the World of Parallel Programming. The Go Parallel
Website,
Post by Thomas Harre
sponsored by Intel and developed in partnership with Slashdot Media, is
your
hub for all things parallel software development, from weekly
thought
Post by Thomas Harre
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now.
http://goparallel.sourceforge.net/
Post by Thomas Harre
_______________________________________________
iText-questions mailing list
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/
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-***@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
iText mailing list
2015-02-09 14:16:53 UTC
Permalink
Post by Thomas Harre
Hi,
Thanks, that does the trick.
But what is the difference between the /V and /AS values?
Or what do they even stand for?
A field is described using a field dictionary. The /V key is an entry in
the field dictionary that gives you the value of the field. A field
doesn't necessarily have a visual representation, but if it has, it can
correspond with one or more widget annotations.

An annotation is described using an annotation dictionary. The /AS key
is an entry in the annotation dictionary that selects the applicable
appearance stream from an appearance sub-dictionary.

When a field corresponds with one and only one widget annotation, the
field dictionary and the annotation dictionary are merged. Hence you
have an overlap of keys that seemingly have the same meaning.

In this case, the /AS key refers to the visualization of the field,
whereas the /V key refers to the actual value of the field. In your
case, there's an inconsistency because the value of the field doesn't
correspond with its representation.

By the way: I only just looked at your mail address and I see that it's
the address of a customer.

Two questions:
1. Is there a reason why you prefer using the mailing list over the
issue tracker for customers? In our last board meeting at iText, we
decided that the mailing-list was dead and that we would discontinue it
in favor of using StackOverflow. In your case, wouldn't it be better to
use the support system that is available for customers?
2. Where did you find DemoCheckBoxRadio.pdf? It was created using iText
2.0.1 and that version dates from March 2007. Your company has a license
to use more recent versions of iText.

------------------------------------------------------------------------------
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-***@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
Thomas Harre
2015-02-09 15:09:39 UTC
Permalink
Hi

I was not aware we had access to a issue tracker for customers.
Where do I find this board?

I created the PDF with a freeware tool. I can't even remember where I
downloaded it.
But it seems to me as the /V and /AS values are different the tool
isn't much good.
For me this subject is sorted, as the PDF is inherently inconsistant.

Thank you everybody for your help and kind regards
Thomas
Post by Thomas Harre
Hi,
Thanks, that does the trick.
But what is the difference between the /V and /AS values?
Or what do they even stand for?
A field is described using a field dictionary. The /V key is an entry
in
the field dictionary that gives you the value of the field. A field
doesn't necessarily have a visual representation, but if it has, it can

correspond with one or more widget annotations.

An annotation is described using an annotation dictionary. The /AS key

is an entry in the annotation dictionary that selects the applicable
appearance stream from an appearance sub-dictionary.

When a field corresponds with one and only one widget annotation, the
field dictionary and the annotation dictionary are merged. Hence you
have an overlap of keys that seemingly have the same meaning.

In this case, the /AS key refers to the visualization of the field,
whereas the /V key refers to the actual value of the field. In your
case, there's an inconsistency because the value of the field doesn't
correspond with its representation.

By the way: I only just looked at your mail address and I see that it's

the address of a customer.

Two questions:
1. Is there a reason why you prefer using the mailing list over the
issue tracker for customers? In our last board meeting at iText, we
decided that the mailing-list was dead and that we would discontinue it

in favor of using StackOverflow. In your case, wouldn't it be better to

use the support system that is available for customers?
2. Where did you find DemoCheckBoxRadio.pdf? It was created using iText

2.0.1 and that version dates from March 2007. Your company has a
license
to use more recent versions of iText.

------------------------------------------------------------------------------
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-***@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-***@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
iText mailing list
2015-02-09 15:14:01 UTC
Permalink
Post by Thomas Harre
Where do I find this board?
I'll have our admin sent you more info.

------------------------------------------------------------------------------
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-***@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
TvT
2015-02-09 15:19:38 UTC
Permalink
Hi Thomas,

even if you stop using that tool - please be aware, that there are lots of
other tools out there which doesn't get that right.
So I would check the /AS key anyway...

Regards,
TvT
Post by Thomas Harre
Hi
I was not aware we had access to a issue tracker for customers.
Where do I find this board?
I created the PDF with a freeware tool. I can't even remember where I
downloaded it.
But it seems to me as the /V and /AS values are different the tool
isn't much good.
For me this subject is sorted, as the PDF is inherently inconsistant.
Thank you everybody for your help and kind regards
Thomas
Post by Thomas Harre
Hi,
Thanks, that does the trick.
But what is the difference between the /V and /AS values?
Or what do they even stand for?
A field is described using a field dictionary. The /V key is an entry in
the field dictionary that gives you the value of the field. A field
doesn't necessarily have a visual representation, but if it has, it can
correspond with one or more widget annotations.
An annotation is described using an annotation dictionary. The /AS key
is an entry in the annotation dictionary that selects the applicable
appearance stream from an appearance sub-dictionary.
When a field corresponds with one and only one widget annotation, the
field dictionary and the annotation dictionary are merged. Hence you
have an overlap of keys that seemingly have the same meaning.
In this case, the /AS key refers to the visualization of the field,
whereas the /V key refers to the actual value of the field. In your
case, there's an inconsistency because the value of the field doesn't
correspond with its representation.
By the way: I only just looked at your mail address and I see that it's
the address of a customer.
1. Is there a reason why you prefer using the mailing list over the
issue tracker for customers? In our last board meeting at iText, we
decided that the mailing-list was dead and that we would discontinue it
in favor of using StackOverflow. In your case, wouldn't it be better to
use the support system that is available for customers?
2. Where did you find DemoCheckBoxRadio.pdf? It was created using iText
2.0.1 and that version dates from March 2007. Your company has a license
to use more recent versions of iText.
------------------------------------------------------------------------------
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
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/
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
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/
http://itextpdf.com/themes/keywords.php
mkl
2015-02-09 14:16:21 UTC
Permalink
Thomas,
Post by Thomas Harre
But what is the difference between the /V and /AS values?
Or what do they even stand for?
/AS is specified for annotations in general as

(Required if the appearance dictionary AP contains one or more
subdictionaries; PDF 1.2) The annotation’s appearance state, which selects
the applicable appearance stream from an appearance subdictionary.

/V is specified for form fields as

(Optional; inheritable) The field’s value, whose format varies depending
on the field type. See the descriptions of individual field types for
further information.

For checkboxes the specification furthermore says:

The V entry in the field dictionary (see Table 220) holds a name object
representing the check box’s appearance state, which shall be used to select
the appropriate appearance from the appearance dictionary.

Thus, in case of checkboxes both entries have to have the identical value
(assuming that the "applicable" appearance is also the "appropriate" one and
vice versa).

In case of your document they don't.

Regards, Michael



--
View this message in context: http://itext-general.2136553.n4.nabble.com/check-if-a-checkbox-is-selected-tp4660724p4660738.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
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-***@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/keywo
TvT
2015-02-09 14:22:25 UTC
Permalink
/AS is the appearance state and defined as follows:
The annotation’s appearance state, which selects the applicable appearance
stream from an appearance subdictionary.

For checkboxes the /V attribute is defined:
Holds a name object representing the checkbox’s appearance state, which is
used to select the appropriate appearance from the appearance dictionary.

@MKL
AFAIK which is superior in the case they are different is not defined...

Regards,
TvT
Post by Thomas Harre
Thanks, that does the trick.
But what is the difference between the /V and /AS values?
Or what do they even stand for?
kind regards,
Thomas
mkl
2015-02-09 14:07:59 UTC
Permalink
TvT, Thomas,
Post by Thomas Harre
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.
It's even worse in Thomas' PDF, The field in question has a /V value /Off
and and an /AS appearance state /chk2. Each of these attributes is specified
to select the applicable/appropriate appearance stream from an appearance
subdictionary.

Thus, this PDF is internally inconsistent and the appearance you are shown
is totally up to the PDF viewer you use.

Regards, Michael

PS: Additionally the parent field also has a /V value, /chk2 in this case.
But parent attributes only serve as defaults if the child does not have that
attribute.



--
View this message in context: http://itext-general.2136553.n4.nabble.com/check-if-a-checkbox-is-selected-tp4660724p4660736.html
Sent from the iText - General mailing list archive at Nabble.com.

------------------------------------------------------------------------------
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-***@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
Loading...