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
å®è°·æ­ç½é¡µï¼è®¯æ¯ï¼å¹¶æé®æ¥æ¾ç¤ºä½
æé语è¨éè¿æä»¬çå好页ã
è°·æ­ç®åæä¾ä¸å语è¨çé¢ï¼
å®è°·æ­ç½é¡µï¼è®¯æ¯ï¼å¹¶æé®æ¥æ¾ç¤ºä½
æé语è¨éè¿æä»¬çå好页ã
è°·æ­ç®åæä¾ä¸å语è¨çé¢ï¼
-------------------------------------------------------------------------
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 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/