|
|
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));
|
|
|
Message was deleted by a User. | Reason: Not specified
|
|
|
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?
|
|
|
Code:
interactiveForms.Fields[4].SelectItem(0, true);
|
|
|
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
|
|
|
|
|
|
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();
}
}
|
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close