st.loadTagStyle("body", "encoding", "Identity-H");
Paulo
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On
> Behalf Of Lil Lily
> Sent: Friday, December 14, 2007 9:12 AM
> To: [email protected]
> Subject: [iText-questions] HTML with Chinese characters to PDF
>
> 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
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
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/