What font are you using for the field?  If you don't supply a Unicode-enabled 
font, then you won't get Unicode text (such as your special characters).

-----Original Message-----
From: Pavol Behul [mailto:pbe...@gmail.com] 
Sent: Monday, March 29, 2010 7:26 AM
To: itext-questions@lists.sourceforge.net
Subject: [iText-questions] FormField, TextField diacritical characters problem.

Hello,

i wrote simple method to add TextField to position, with specified text. 
I have problem, when text is in utf-8 coding with some diacritical 
characters (ľščťžřě).
Acrobat reader render bad these chars, also my Servlet got bad data from 
acro button Submit. Is some possibility how to fix these diacritical 
characters - methods:

ff.setValueAsString(text);

and

tf.setText(text);


Here is my code:


static public void addTextField(PdfStamper stamper,String name, String 
text, Rectangle rect, int page) {
PdfFormField ff = PdfFormField.createTextField(stamper.getWriter(), 
false,false,0);
ff.setFieldName(name);
ff.setValueAsString(text);
TextField tf = new TextField(stamper.getWriter(), rect, null);
tf.setBackgroundColor(Color.gray);
tf.setBorderColor(Color.black);
tf.setBorderWidth(1);
tf.setAlignment(Element.ALIGN_LEFT);
tf.setText(text);
tf.setOptions(TextField.READ_ONLY);
PdfFormField field1 = tf.getTextField();
field1.setFieldFlags(TextField.READ_ONLY);
ff.addKid(field1);
ff.setFieldFlags(PdfFormField.FF_READ_ONLY);
stamper.addAnnotation(ff, page);
}

Regards,
Pavol Behul.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
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/

Reply via email to