Add a TextField, it will work.
Paulo
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Sascha Fuchs
Sent: Monday, March 19, 2007 9:34 AM
To: Post all your questions about iText here
Subject: [iText-questions] Add AcroFields with PdfStamper and
find theyagain with PdfReader
Hello
I try to add hidden AcroFields to existing pdf documents.
// Create Acrofields with number of stamps
PdfFormField stampfield =
PdfFormField.createTextField(stamp.getWriter(),
true, // multiline
false, // password
0); // Maxlength of field - 0 = unlimited
stampfield.setFieldName("my_field");
stampfield.setValueAsString("my_value");
stampfield.setFieldFlags(TextField.HIDDEN);
stamp.addAnnotation(stampfield, 1); //
stamp.getWriter().addAnnotation(stampfield) gaves an exception for wrong
use....
On stamped pdf I can see with text editor that "" with
"my_value" have been written. But if I open the pdf document again with
PdfReader and ..
AcroFields acroFields = inPdf.getAcroFields();
String myvalue = acroFields.getField("my_field"); // returns
null
.. I can not get "my_field".
What did I wrong? How can I get my acrofields?
Maybe a hint: On the book "iText in action", Chapter 15 I found
how to add AcroField with PdfWriter (but there is no example for
PdfStamper); In Chapter 16 I found how to modify existing AcroFields
with PdfStamper (but no example how to add a new field).
Thanks in advance.
Sascha
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/