Print Page | Close Window

Setting check box subfield 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=1842
Printed Date: 13 Jul 25 at 5:05PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Setting check box subfield values
Posted By: Revolution1200
Subject: Setting check box subfield values
Date Posted: 26 May 11 at 10:25PM
Hi Folks,

I am currently reviewing QuickPDF for our company, we are looking to automatically fill in H&S forms.

For some reason I am unable to set the value of any of the check boxes on the form.

I have been using the following code to confirm the subfields within VB6

        For loopcounter = 1 To PDFLibrary.FormFieldCount
            currentFieldName = PDFLibrary.GetFormFieldTitle(loopcounter)
            If PDFLibrary.GetFormFieldType(loopcounter) = 4 Then
                If PDFLibrary.GetFormFieldKidCount(loopcounter) > 1 Then
                    Debug.Print PDFLibrary.GetFormFieldKidCount(loopcounter)
                    For subCounter = 2 To PDFLibrary.GetFormFieldKidCount(loopcounter) + 1
                        subFieldIndex = PDFLibrary.GetFormFieldSubTempIndex(loopcounter, subCounter)
                        subFieldName = PDFLibrary.GetFormFieldSubName(loopcounter, subCounter)
                        PDFLibrary.SetFormFieldValue(subFieldIndex, "On"
                    Next
              
                End If
            End If
        Next

I get a valid sub field index, and I can use this to verify that the subfield default value is "Off", I can also use the index to confirm that the subfield is of type 4 for a check box, however when I use the same value to try and set the field using

PDFLibrary.SetFormFieldValue(subFieldIndex, "On")

I get a return value of 0 which seems to mean the library cannot find the field specified?

Is anyone able to share some code where this works?

Kind Regards

Stuart



Replies:
Posted By: Rowan
Date Posted: 27 May 11 at 12:20PM
Hi Stuart,

Can you try using "Yes" with SetFormFieldValue instead of "On"?

PDFLibrary.SetFormFieldValue(subFieldIndex, "Yes")

I did a quick test and Yes works for me but On does not.

Cheers,
- Rowan.


Posted By: Revolution1200
Date Posted: 06 Jun 11 at 4:51PM
Hi Rowan,
 
Thanks for your reply, was pulled of the project for a week or so and this is the first chance I have had to get back to it!!
 
Finally found out that the sub field names are in actual fact the values I need to send to turn then checkbox on - for instance under the question for Sex, there are 2 sub fields Male and Female, to check the Male check, I use PDFLibrary.SetFormFieldValue PDFLibrary.FindFormFieldByTitle("partc q5"), "male"
 
Slightly confusing but got there in the end!!
 
Cheers
 
Stuart


Posted By: AndrewC
Date Posted: 01 Jul 11 at 2:50PM
Here is some code I use to display the possible sub field values required for setting check box and radio boxes.


                    for (int i = 1; i <= QP.FormFieldCount(); i++)
                    {
                        string title = QP.GetFormFieldTitle(i);
                        string hint = QP.GetFormFieldDescription(i);
                        string s = QP.GetFormFieldValue(i);
                        int type = QP.GetFormFieldType(i);
                   
                            if (type == 3 || type == 4)  // Radio or CheckBox
                            {
                                int sc = QP.GetFormFieldSubCount(i);
                                for (int j = 1; j <= sc; j++)
                                {
                                    string sfn = QP.GetFormFieldSubName(i, j);
                                    textBox1.AppendText(sfn);
                                    if (j != sc)
                                        textBox1.AppendText("|");
                                }
                            }



Posted By: Revolution1200
Date Posted: 06 Jul 11 at 7:36PM
Cheers Andrew,
 
That is very similar to what I ended up doing!



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