logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Guest Posted: Friday, November 4, 2016 1:11:16 AM(UTC)
 
Do you mean the ListBox is empty? And you want to add a new items to it?

As I know the library does not support adding of new items through Interactive Forms class library.
But we found a workaround for similar task.
Please look at code below. The main idea is use the Root dictionary of the document.

Code:

var acroForms = pdfViewer1.Document.Root["AcroForm"] as PdfTypeDictionary;
var fields = acroForms["Fields"] as PdfTypeArray;
var combo = (fields[4] as PdfTypeIndirect).Direct as PdfTypeDictionary;
var options = combo["Opt"] as PdfTypeArray;

options.Add(PdfTypeString.Create("USD", true));
options.Add(PdfTypeString.Create("Pounds", true));
options.Add(PdfTypeString.Create("Yen", true));
options.Add(PdfTypeString.Create("Euro", true));
Guest Posted: Friday, November 4, 2016 12:46:14 AM(UTC)
 
Message was deleted by a User. | Reason: Not specified
Guest Posted: Thursday, November 3, 2016 6:38:57 PM(UTC)
 
interactiveForms.Fields[4].SelectedItem(0,true); would select the first element in that listbox control right?


How do you put multiple values in a listbox control so that it ends up giving the user multiple choices in the listbox to choose from?

i.e. if the listbox takes an xml to populate multiple values, I would it to be something like this

interactiveForms.Fields[4].value = "<currency>
<Text="USD" Value=1/>
<Text="Pounds" Value=2/>
<Text="Yen" Value=3/>
<Text="Euro" Value=4/>
</currency>";



or is there a different method to populate the items in a listbox control?

Guest Posted: Thursday, November 3, 2016 4:43:33 PM(UTC)
 
Code:

interactiveForms.Fields[4].SelectItem(0, true);
mukesh Posted: Thursday, November 3, 2016 1:37:25 PM(UTC)
 
Thanks for your response.

I looked at it. It seems like that PdfField.Options property is read only property.

What I want to do is populate the listbox/dropdown with certain values dynamically. for example to populate a text field we can just do

field.Value = "100";

how do I populate list box that contains the following options for the user to choose...

1. USD
2. Pounds
3. Yen
4. Euro
Guest Posted: Thursday, November 3, 2016 3:32:07 AM(UTC)
 
Looks like you need to use the PdfField.Options Property
https://pdfium.patagames...7e-fb1a-4f70f104f826.htm
mukesh Posted: Tuesday, November 1, 2016 10:00:09 PM(UTC)
 
I have the following code to populate other fields but don't know how to populate multiple values in a field that is of dropdown type.
Code:

            var _fillForms = new PdfForms();
            using (var _doc = Patagames.Pdf.Net.PdfDocument.Load("c:\temp.pdf", _fillForms))
            {
                var interactiveForms = _doc.FormFill.InterForm;
                foreach (var field in interactiveForms.Fields)
                {
                    try
                    {
                        if (field.FieldType == Patagames.Pdf.Enums.FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD)
                        {
                            field.Value = "TextField populated";
                        }
                        else if (field.FieldType == Patagames.Pdf.Enums.FormFieldTypes.FPDF_FORMFIELD_LISTBOX)
                        {
                            string val;
                            // need to populate the listbox with valid Currency types i.e. US Dollars, British Pounds, Euro etc.
                            field.Value = ??


                        }
                    }
                    catch (Exception ex)
                    {
                        //Log ("Problem populating PDF ",ex);
                    }
                }

                _doc.Save("C:\temp.pdf", Patagames.Pdf.Enums.SaveFlags.NoIncremental);
                _doc.Dispose();
            }
        }