开发者

iText encoding problem

开发者 https://www.devze.com 2022-12-08 11:37 出处:网络
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

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开发者_StackOverflow 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.


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.


Try using InputStreamReader with appriopriate charset name.

0

精彩评论

暂无评论...
验证码 换一张
取 消