1T3XT info <info <at> 1t3xt.info> writes:
>
> Cheryl wrote:
> > I need to access the required attribute of a field using itext/java. Can
> > someone tell me know to do this?
>
> Get the field dictionary, and look for the "Ff" key (PdfName.FF; stands
> for "Field flags"). The value corresponding with this key is a number
> that you should treat as a bitset.
>
> If the first bit is on, the field is read-only.
> If the second bit is on, the field is required.
> If the third bit is on, the field mustn't be exported.
>
> In other words: you have to look if the second bit is on.
Thanks for the response. It worked exactly like instructed (once I re-learned
java's binary operators!) Here's the method I wrote:
public static boolean getFieldRequirement(Item item) {
int REQUIRED_BITMASK = 2;
for (int i = 0; i < item.merged.size(); i++) {
PdfDictionary dict = (PdfDictionary)item.merged.get(i);
int num = dict.getAsNumber(PdfName.FF).intValue();
if ((num & REQUIRED_BITMASK) != 0)
return true;
}
return false;
}
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/