OK,
you have found the flag to set the visibility of an annotation.
Now you need the reverse. Given a field you want to know
if it's visible or not.
To do this you need the source snippet I already gave you
(see below) and read the entry PdfName.F from the dictionary
(F = flags). A object of type PdfNumber will be returned.
This object should contain an integer that acts as a bitset.
In class PdfAnnotation, you can find the values of the flags:
public static final int FLAGS_HIDDEN = 2;
public static final int FLAGS_PRINT = 4;
and so on...
You need to compare the integer value of the F entry
with these flags to know is a field is hidden or not.
br,
Bruno

philip89 wrote:

Thanks Bruno,

I was searching without luck!.

I found the following sintax to set the flag
(hidden/visible) :

Hidden:
setFieldProperty("fieldname",
"flags",PdfAnnotation.FLAGS_PRINT |
PdfAnnotation.FLAGS_HIDDEN, null)

Visible:
setFieldProperty("fieldname",
"flags",PdfAnnotation.FLAGS_PRINT, null)

And I also used the following sintax to set the Visibility
property in a text field.

Var
tf: TextField;
form: AcroFields;
begin
reader:=PdfReader.Create(PDFInput);
stamp:=PdfStamper.Create(reader,FileStream.Create(PDFoutput,FileMode.Create));
tf := TextField.Create(stamp.Writer,Rectangle.Create(100,
300, 100 + 100, 300 + 50), fieldName);
tf.Visibility := tf.HIDDEN; //works ok to set the property

Now I need the EXACT sintax to check if a field is or not
visible. (ANY TYPE OF FIELD! : CHECKBOX, RADIOBUTTON, TEXT,
LIST, COMBO)
Thanks,
Philip


philip89 wrote:

Hi There,
I want to know which of the fields (CHECKBOX, RADIOBUTTON
, >TEXT, LIST, COMBO) are visible or not in a PDF file.


<>First let me give you some iText code:

PdfReader reader = new PdfReader(myPdf);
AcroFields fields = reader.getAcroFields();
AcroFields.Item item = fields.getFieldItem(myField);
PdfDictionary dict;
PdfName name;
for (Iterator i = item.merged.iterator(); i.hasNext(); ) {
 dict = (PdfDictionary)i.next();
 for (Iterator it = dict.getKeys().iterator();
it.hasNext(); ) {
   name = (PdfName)it.next();
   System.out.println(name.toString() + ": " +
dict.get(name));
 }
}

With this code, you take a field defined in the String
'myField' from a PDF defined in the String 'myPdf'.
This field can be represented on different pages, using
different widget annotations. All the properties of the
field are bundled in the AcroFields.Item object. For
instance: a radio button field with three radio buttons,
will contain three widget annotation dictionaries and
three field annotation dictionaries. In the code sample,
we loop over all the elements in the 'merged' member
variable. This variable contains the combined dictionaries
(entries from the annotation + field dictionary).

To know if the field is visible or not, you need to check
the entries with visibility flags. You should look this up
in the PDF Reference manual. I don't know the value of the
visibility flag by heart. br,
Bruno




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to