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!
Value not in Combobox Formfield |
Post Reply |
Author | |
zero_g
Beginner Joined: 19 Jan 12 Location: Germany Status: Offline Points: 12 |
Post Options
Thanks(0)
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
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
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); } } } |
|
zero_g
Beginner Joined: 19 Jan 12 Location: Germany Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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
|
|
zero_g
Beginner Joined: 19 Jan 12 Location: Germany Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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 -1 End WhileTom |
|
zero_g
Beginner Joined: 19 Jan 12 Location: Germany Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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
|
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
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 |
|
zero_g
Beginner Joined: 19 Jan 12 Location: Germany Status: Offline Points: 12 |
Post Options
Thanks(0)
|
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
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store