You just needed to dig a little deeper.

AcroFields.getFieldItem( String ) returns an "AcroFields.Item".  Item's 
"merged", "widgets", and "values" members are all ArrayLists of 
PdfDictionary... for when a field shows up more than once.  This is perfectly 
normal for radio groups, and rare (though valid) for most other field types.

The ArrayLists are kept in parallel, and there's also one AL for the page 
number the widget is found on, one for the tab order in that page, and one for 
widget references.

In many cases you can just grab the first entry out of merged, widgets, or 
values, depending on what you want done.  Not terribly safe if you're dealing 
with forms from 3rd parties however.  You probably want to iterate through all 
the entries in the ArrayLists and treat them accordingly.

The problem with mapping a field name to a PdfDictionary is that you can have 
multiple fields with identical names... those fields share a value, but have 
different widget annotations, so can be displayed in different fonts, point 
sizes, colors, borders, etc.  This makes it necessary to do something like 
AcroFields.Item if you want to cover all your bases.

--Mark Storer 
  Senior Software Engineer 
  Cardiff.com

#include <disclaimer> 
typedef std::Disclaimer<Cardiff> DisCard; 


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> Orcajo
> Sent: Monday, April 30, 2007 9:10 AM
> To: Post all your questions about iText here
> Subject: Re: [iText-questions] getting a field as a PdfDictionary
> 
> 
> Thanks for your fast answwer, but I can't see how to do that with
> AcroFields. I find I can do:
> 
> /**************************************************/
> AcroFields acroFieldsForm = reader.getAcroFields();
> HashMap miFields = acroFieldsForm.getFields();
> /**************************************************/
> 
> and then access to miFields to get the name of a field, but what I
> want is to get a field
> as a PdfDictionary, and there is no method in AcroField (except for
> "getSignatureDictionary") returning a PdfDictionary.
> 
> I need that to add an action to that field, that is, to do 
> something like:
> 
> /**************************************************/
> PdfDictionary field = ? //I need access to a field by its name!
> field.put(PdfName.AA, action);
> /**************************************************/
> 
> Thanks again,
> Jesús.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to