I've been having trouble with checkboxes in some PDF forms. Specifically, in http://www.irs.gov/pub/irs-pdf/f1040.pdf there are some groups of checkboxes (such as near line 1 and after line 77). In these groups with the current poppler head, selecting one of the checkboxes causes all of them to be drawn as selected, which is not the desired behavior.

The attached patch should be a fix for this problem. I've tried to keep it simple.

(Longer-term, I've been wondering if it is better to use the appearance streams in the appearance dictionary for drawing the checkbox states, if available, instead of always regenerating the check ourselves. But that is a larger change, so I've avoided it for the moment.)

--Michael Vrable
Allow grouped checkboxes to be selected individually.

When checkboxes are in a group, they ought to behave like a collection of
radio buttons.  However, when deciding whether to draw a checkbox as
selected or not, the checkbox-drawing code was looking up the value of the
V field in the form dictionary, which is shared among all checkboxes in the
group.  Thus, checkboxes would either all be on or off in unison.

Instead, look up the AS (appearance state) value in each checkbox's
annotation dictionary, so that different checkboxes can be drawn
differently.
---
 poppler/Annot.cc |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 5e62ac4..2f7d8fc 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -2789,10 +2789,8 @@ void AnnotWidget::generateFieldAppearance() {
       }
       // checkbox
     } else {
-      // According to the PDF spec the off state must be named "Off",
-      // and the on state can be named anything, but Acrobat apparently
-      // looks for "Yes" and treats anything else as off.
-      if (Form::fieldLookup(field, "V", &obj1)->isName("Yes")) {
+      if (annot->lookup("AS", &obj1)->isName() &&
+          strcmp(obj1.getName(), "Off") != 0) {
         if (!caption) {
           caption = new GooString("3"); // ZapfDingbats checkmark
         }
_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to