Frequently Asked Question:
How do I retrieve all the items in a drop down form field?
Question
I have a PDF form with a drop down list field that contains 3 items: Apple, Orange, Peach
How do I extract these three string values from this field using the Quick PDF library?
Answer
This code will display the "Exported Value" of all items available in Choice drop down combos. Currently there is no way to get the actual text displayed in the Combo. I will make a suggestion to the developers.
int ret = QP.LoadFromFile("applespearspeaches.pdf");
int fieldCount = QP.FormFieldCount();
for (int i = 1; i <= fieldCount; i++)
{
string title = QP.GetFormFieldTitle(i);
int type = QP.GetFormFieldType(i);
if (type == 5) // Choice
{
int itemCount = QP.GetFormFieldSubCount(i);
for (int j = 1; j <= itemCount; j++)
{
string s = QP.GetFormFieldSubName(i, j);
MessageBox.Show(title + " : choice" + j.ToString() + " = " + s);
}
}
}
Here is the documentation for the functions I have used.