Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Value not in Combobox Formfield
  FAQ FAQ  Forum Search   Register Register  Login Login

Value not in Combobox Formfield

 Post Reply Post Reply
Author
Message
zero_g View Drop Down
Beginner
Beginner


Joined: 19 Jan 12
Location: Germany
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote zero_g Quote  Post ReplyReply Direct Link To This Post Topic: Value not in Combobox Formfield
    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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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);
                    }
                }
            }

Back to Top
zero_g View Drop Down
Beginner
Beginner


Joined: 19 Jan 12
Location: Germany
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote zero_g Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
zero_g View Drop Down
Beginner
Beginner


Joined: 19 Jan 12
Location: Germany
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote zero_g Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
zero_g View Drop Down
Beginner
Beginner


Joined: 19 Jan 12
Location: Germany
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote zero_g Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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 
Back to Top
zero_g View Drop Down
Beginner
Beginner


Joined: 19 Jan 12
Location: Germany
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote zero_g Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store