public void setField(COSDocument doc, COSString name, COSString value)
{
for (Iterator i = doc.getObjects().iterator(); i.hasNext();)
{
COSObject obj = (COSObject) i.next();
COSBase base = obj.getObject();
if (base instanceof COSDictionary)
{
COSDictionary dict = (COSDictionary) base;
COSBase type = dict.getItem(COSName.TYPE);
if (type != null && type.equals(COSName.getPDFName("Annot")))
{
COSBase subtype = dict.getItem(COSName.getPDFName("Subtype"));
if (subtype != null && subtype.equals(COSName.getPDFName("Widget")))
{
// we found the field
COSBase fname = dict.getItem(COSName.getPDFName("T"));
if (fname != null && fname.equals(name))
{
dict.setItem(COSName.getPDFName("V"), value);
}
}
}