You must use the right charset. In this case:

String userHTML = new String(bytes, "UTF-8");

Paulo

----- Original Message ----- 
From: "nsk clr" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, September 25, 2007 10:06 PM
Subject: [iText-questions] Issue in converting chinese content to pdf


Hi

  I use Itext to convert chinese html to pdf.
  The code is
     File file = new File("C:\\Itext\\chinese.html");
   int fileLen = (int)file.length();
   FileInputStream fis = new FileInputStream(file);
   byte[] bytes = new byte[fileLen];
   fis.read(bytes,0,fileLen);
     String userHTML = new String(bytes);
Document document = new Document();
  FontFactory.register("c:\\windows\\fonts\\ARIALUNI.TTF");
StyleSheet st = new StyleSheet();
st.loadTagStyle("body", "face", "Arial Unicode MS");
st.loadTagStyle("body", "encoding", "Identity-H");
st.loadTagStyle("body", "leading", "12,0");
  StringReader stringReader = new StringReader(userHTML);
PdfWriter.getInstance(document, new 
FileOutputStream("C:\\Swarna\\Itext\\chinese.pdf"));
document.open();
ArrayList p = HTMLWorker.parseToList(stringReader, st);
for (int k = 0; k < p.size(); ++k)
    document.add((Element)p.get(k));
document.close();

  I have attached the input and ouput files.

  Please let me know what to do to get the correct output

  Thanks


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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/

Reply via email to