Print Page | Close Window

checkbox values

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2559
Printed Date: 29 Apr 25 at 11:39AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: checkbox values
Posted By: toran
Subject: checkbox values
Date Posted: 09 Mar 13 at 1:38AM
I am processing pdf document from different origins, programmatically filling out form field values. The problem I have is filling out checkboxes.  Possible variants that I came across are "1/0", or "Off/On", or "Yes/No". 

My question is:

how to find what values makes checkbox field being "check" and "uncheck"?

There is an API function GetFormFieldDefaultValue that in case of "Off/On" will return "Off", but it is unclear if "DefaultValue" for checkbox is a value for "unchecked" or "checked" checkbox? 




Replies:
Posted By: Chumly
Date Posted: 28 Apr 13 at 3:26PM
Hello,
The PDF Spec seems to show that the output can be whatever the designer of the form wishes to use.
There is no set value.
You will need to either control the source pdf files, or code for each variant you find.
:(


Posted By: AndrewC
Date Posted: 29 Apr 13 at 2:19AM
The SubNames from QPL can be used to determine the correct values.  According to the PDF specification "Off" should always be the off state.

Here is some code that attempts to turn on all Checkboxes on a form.  You can modify this code to meet your needs.

            QP.LoadFromFile("formfields.pdf", "");

            for (int i = 1; i < QP.FormFieldCount(); i++)
            {
                int fType = QP.GetFormFieldType(i);
                string fName = QP.GetFormFieldTitle(i);
                int sc;

                switch (fType)
                {
                    case 1:     // Text
                        QP.SetFormFieldValue(i, "ABDCEF");
                        break;

                    case 3:
                    case 4:
                    case 5:
                        sc = QP.GetFormFieldSubCount(i);

                        for (int j = 1; j <= QP.GetFormFieldSubCount(i); j++)
                        {
                            string value = QP.GetFormFieldSubName(i, j);

                            if (value != "Off")
                                QP.SetFormFieldValue(i, value);
                        }
                        break;

                    case 7:     // Parent
                        break;
                }
            }




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk