Adriano Leite Ribero wrote:
> Hello to everybody! Last week I post a problem about pointing at
> fields, you can read about it in the text below. If anyone could
> kindly write a little example code...
I've already sent you the example to add JavaScript
to a field of which you know the object number a while
ago. With this code snippet, you can parse the form
and find out which object number corresponds with
which field:
PdfReader reader = new PdfReader("learning_agreement.pdf");
PdfDictionary catalog = reader.getCatalog();
PdfDictionary form =
(PdfDictionary)PdfReader.getPdfObject((PdfObject)catalog.get(PdfName.ACROFORM));
PdfArray fields =
(PdfArray)PdfReader.getPdfObject((PdfObject)form.get(PdfName.FIELDS));
PdfDictionary field;
PdfObject ref;
PdfName key;
for (Iterator i = fields.listIterator(); i.hasNext(); ) {
ref = (PdfObject)i.next();
System.out.println("Field: " + ref);
field = (PdfDictionary)PdfReader.getPdfObject(ref);
for (Iterator j = field.getKeys().iterator(); j.hasNext(); ) {
key = (PdfName)j.next();
System.out.print(key + ": ");
System.out.println(field.get(key));
}
}
br,
Bruno
-------------------------------------------------------------------------
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/