It works with my code and my html.

File file = new File("C:\\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, "UTF-8");
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:\\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();


Paulo

----- Original Message ----- From: "nsk clr" <[EMAIL PROTECTED]> To: "Post all your questions about iText here" <[email protected]>
Sent: Wednesday, September 26, 2007 5:45 PM
Subject: Re: [iText-questions] Issue in converting chinese content to pdf


After removing the encoding="utf-8" in the html and using my code, I don't get the ouput like the one you have attached.

It's all jumbled in a single line and with junk characters.

Do I need to change any other basic settings in my system or in pdf?

Thanks

Paulo Soares <[EMAIL PROTECTED]> wrote:

Also remove the encoding in the html that is masking the real font encoding.
I attach the modified html and the resulting pdf.

Paulo

----- Original Message ----- From: "nsk clr"
To: "Post all your questions about iText here"

Sent: Tuesday, September 25, 2007 11:27 PM
Subject: Re: [iText-questions] Issue in converting chinese content to pdf


When I use String userHTML = new String(bytes, "UTF-8");, I get nothing in
the pdf.

Otherwise, in the pdf- document properties, the encoding is shown as ANSI,
inspite of me setting as Identity-H in
st.loadTagStyle("body", "encoding", "Identity-H");

How to set the Identity-H as encoding? Why is it not being set?

Thanks

Paulo Soares wrote:
You must use the right charset. In this case:

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

Paulo

----- Original Message ----- From: "nsk clr"
To:
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

å®sè°·æ­OEç½'页ï¼OE讯息ï¼OEå¹¶æOE?é'®æ¥æ~¾ç¤ºä½ æ?EURéEUR?语è¨EURéEURsè¿?æ^'们çs"偏好页ãEUR'
è°·æ­OEç>®å?æä¾>ä¸<å^-语è¨EURç*OE面ï¼s
å®sè°·æ­OEç½'页ï¼OE讯息ï¼OEå¹¶æOE?é'®æ¥æ~¾ç¤ºä½ æ?EURéEUR?语è¨EURéEURsè¿?æ^'们çs"偏好页ãEUR'
è°·æ­OEç>®å?æä¾>ä¸<å^-语è¨EURç*OE面ï¼s

-------------------------------------------------------------------------
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/



________________________________

Tonight's top picks. What will you watch tonight? Preview the hottest shows <http://us.rd.yahoo.com/tv/mail/tagline/tonightspicks/evt=48220/*http://tv.yahoo.com/> on Yahoo! TV.
定谷歌网页,讯息,并按钮来显示你所选语言通过我们的偏好页。
谷歌目前提供下列语言界面:
定谷歌网页,讯息,并按钮来显示你所选语言通过我们的偏好页。
谷歌目前提供下列语言界面:

-------------------------------------------------------------------------
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