Hi All,

Our goal is to convert an html (with Chinese characters) to a pdf file.  We 
patterned our code on the sample given on this forum but still can't make the 
chinese characters to appear.  

Attached here is a sample of the html file and below is the code snippet.

File file = new File("C:\\html.htm");
int fileLen = (int)file.length();
java.io.FileInputStream fis = new java.io.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:\\sample.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();


Thank you,
Lily

       
---------------------------------
Never miss a thing.   Make Yahoo your homepage.

 
 
To: Recipient
Company: Sample Co
Date: 13 Dec 2007
 
MESSAGE
 
Dear 收人收
 
Please note the following details:
 
Line One
Line Two
 
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
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