views:

806

answers:

3

I have encoding problem with iText (http://www.lowagie.com/iText/). I load data from database and insert it as html to pdf with iText, for some reason my non-english (Finnish ä,ö etc) characters don't show up correctly. Following example shows how insert text to html:

 text = "<p>" + data + "</p>";
 HTMLWorker htmlWorker = new HTMLWorker(doc);
 InputStream is = new ByteArrayInputStream(text.getBytes());
 InputStreamReader isr = new InputStreamReader(is);
 htmlWorker.parse(isr);

UPDATE: If have to add that it's working in my Windows Vista system, but not in Linux system.

+1  A: 

Is your default Locale set properly? Make sure that Locale.getDefault() is returning the value it should be. This could be different on windows and linux, if one of them hasn't been set up correctly.

skaffman
Hi, thanx, locale was different on linux server, so it must be that what is causing this problem...
newbie
Just tested, I changed locale and locale changed, but I still get wrong characters
newbie
Hmm.. It was Firefox cache that chached wrong version restartring firefox helped and now everything is ok.
newbie
+1  A: 

Try using InputStreamReader with appriopriate charset name.

cetnar
A: 

Hi, I have the same problem. code is

Chunk text = new Chunk("Ba\u015Far\u0131 Belgesi", font);

unicode chracters does not show up on pdf the output is:

Baar Belgesi

thx

Levent