Andrew Ton wrote:
> Hi all,
> 
> I have a PDF form that has several combo boxes (list boxes). Could you 
> please show me how to get the items selected by the user in those combo 
> boxes? I have searched in iText API and found getListOptionExport(name) 
> and getAppearanceStates(name) of AcroFields but these 2 methods just 
> return all items in a combo box.
> 
> My project is stuck by this issue. I really appreciate your help.

This is not supported yet, but as your project is stuck without it,
I wrote this method that will be added to the AcroFields class in
the next release:

public String[] getListSelection(String name) {
   String[] ret;
   String s = getField(name);
   if (s == null) {
     ret = new String[]{};
   }
   else {
     ret = new String[]{ s };
   }
   Item item = (Item)fields.get(name);
   if (item == null)
     return ret;
   PdfArray values = 
(PdfArray)PdfReader.getPdfObject(((PdfDictionary)item.merged.get(0)).get(PdfName.I));
   if (values == null)
     return ret;
   ret = new String[values.size()];
   String[] options = getListOptionExport(name);
   PdfNumber n;
   int idx = 0;
   for (Iterator i = values.listIterator(); i.hasNext(); ) {
     n = (PdfNumber)i.next();
     ret[idx++] = options[n.intValue()];
   }
   return ret;
}

If this method 'unstuck' your project, there's a PayPal button
on this page: http://www.1t3xt.com/about/
-- 
This answer is provided by 1T3XT BVBA

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to