Print Page | Close Window

Value not in Combobox Formfield

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=2205
Printed Date: 20 May 24 at 9:12AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Value not in Combobox Formfield
Posted By: zero_g
Subject: Value not in Combobox Formfield
Date Posted: 01 Apr 12 at 6:30PM
Hello,
I have a given PDF File, which contains a Combobox into a Formfield. By using Adobe Reader or so the user can select an item. The Formfield has the name "84.0". and the Elements "B" , "E" and "K1". If I try to write a Value into the Combobox Formfield
 
QP.SetFormFieldValueByTitle("84.0", "B")
 
the field remains empty.
Is that way the right one for accessing Combobox designed Formfields?
 
Thanks for helping.
 
Tom



Replies:
Posted By: AndrewC
Date Posted: 04 Apr 12 at 4:19AM
That should work but I would need to see the PDF before making further comments as the display values can be different from the stored values.

You could try the following code that should list the possible values

            for (int i = 1; i <= QP.FormFieldCount(); i++)
            {
                string title = QP.GetFormFieldTitle(i);
                string s = QP.GetFormFieldValue(i);

                int type = QP.GetFormFieldType(i);

                string txt = String.Format("{0}: Type={1} : Name={2} : Value='{3}'\n", i, type, title, s);
                OutputTxt.AppendText(txt);

                if (type == 3 || type == 4 || type == 5) // checkbox, radio, choicebox
                {
                    int sc = QP.GetFormFieldSubCount(i);
                    for (int j = 1; j <= sc; j++)
                    {
                        string sfn = QP.GetFormFieldSubName(i, j);
                        OutputTxt.AppendText("Subfield" + j.ToString() + " : " + sfn + "\n");

                        string sn = QP.GetFormFieldSubName(i, j);
                        // QP.SetFormFieldValue(i, sn);
                    }
                }
            }



Posted By: zero_g
Date Posted: 04 Apr 12 at 8:43AM
Hello AndrewC,
indeeed I developed a similar codefragment for testing whether there is a combobox. But I failed when I tried to write a value into the combobox.
After I translated the c code into vb.net maybe I can report some more.
 
Thanks
Tom


Posted By: zero_g
Date Posted: 04 Apr 12 at 10:40AM
Hello AndrewC,
i solved the problem. Here is my little code
 
While (TotalFormFields > 0)

Dim titel As String = QP.GetFormFieldTitle(TotalFormFields)

Dim typ As Integer = QP.GetFormFieldType(TotalFormFields)

If titel = "84.0" Then

If typ = 5 Then

QP.setformfieldvalue(totalformfields,"E") ' works very wellQP.SetFormFieldValueByTitle("84.0", "E") ' does not work (I dont know why)

End If

End If

QP.FlattenFormField(TotalFormFields)

QP.DeleteFormField(TotalFormFields)

TotalFormFields = TotalFormFields -1End While

Tom


Posted By: zero_g
Date Posted: 04 Apr 12 at 10:56AM
Sorry had to correct my last post. This code produces only empty Formfields, because the FlattenFormField and DeleteFormField kills the Value.
Bythe way, the QP.SetFormFieldValueByTitle works also with comboboxes, but one can only write values into the combobox which are valid items of itself. For example B1 is not a valid item, so the Combobox remains empty.
Any solutions for the FlattenFormField and DeleteFormField problem?
 
 
kind regards Tom


Posted By: AndrewC
Date Posted: 04 Apr 12 at 12:03PM
FlattenFormField by definition deletes the FormField so you don't need to call DeleteFormField.

Can you try  

  QP.UpdateAppearanceStream(TotalFormFields);  before you call FlattenFormField.  I suspect the formfields don't have appearance streams.

When a Fieldname contains a '.' dot character it actually a parent + child where '84' is the parent and '0' is the child field name.  Parents can have multiple children.  I haven't tested this 


Posted By: zero_g
Date Posted: 04 Apr 12 at 12:38PM
Unfortunately the QP.UpdateAppearanceStream(TotalFormFields) results in completly empty comboboxes without any content.
I had another solution. I excluded all Formfields with Formfieldstype = 5 from the flattening.

While (TotalFormFields > 0)

Dim typ As Integer = QP.GetFormFieldType(TotalFormFields)

If Not typ = 5 Then

'QP.UpdateAppearanceStream(TotalFormFields)

QP.FlattenFormField(TotalFormFields)

End If

TotalFormFields = TotalFormFields - 1

End While

That works so far. While not using the Deleteformfield Command the PDF Viewer (lets say Nitro or Adobe) ask for "Saving changes Yes/No/Cancel". Ingo gave this tip.
"
Hi Tom!

Flattened or not ... there are still fragments from a form type pdf
inside the content and acrobat is searching for it and gives you
the warning message.

Cheers and welcome here,
Ingo
"

Thats a bit confusing.

 
 
Tom



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