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 pdfAfter 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/
- Re: [iText-questions] Issue in converting chinese content t... Paulo Soares
- Re: [iText-questions] Issue in converting chinese cont... nsk clr
- Re: [iText-questions] Issue in converting chinese cont... nsk clr
- Re: [iText-questions] Issue in converting chinese ... Paulo Soares
