Rank: Member
Groups: Registered
Joined: 7/14/2016(UTC) Posts: 20  Thanks: 4 times
|
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();
}
}
Edited by moderator Wednesday, August 9, 2017 7:24:36 PM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Guest
Groups: Guests
Joined: 1/5/2016(UTC) Posts: 162
Was thanked: 5 time(s) in 5 post(s)
|
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 7/14/2016(UTC) Posts: 20  Thanks: 4 times
|
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
|
|
|
|
|
|
Rank: Guest
Groups: Guests
Joined: 1/5/2016(UTC) Posts: 162
Was thanked: 5 time(s) in 5 post(s)
|
Code:
interactiveForms.Fields[4].SelectItem(0, true);
|
|
|
|
|
|
Rank: Guest
Groups: Guests
Joined: 1/5/2016(UTC) Posts: 162
Was thanked: 5 time(s) in 5 post(s)
|
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?
|
|
|
|
|
|
Rank: Guest
Groups: Guests
Joined: 1/5/2016(UTC) Posts: 162
Was thanked: 5 time(s) in 5 post(s)
|
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));
Edited by user Friday, November 4, 2016 1:12:30 AM(UTC)
| Reason: Not specified
|
 1 user thanked Guest for this useful post.
|
|
|
|
Forum Jump
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.
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