  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Subject: How to get the Chinese charactors when using HTMLWorker? | Subject: How to get the Chinese charactors when using HTMLWorker? 2007-10-09 - By scott
Back Hello,Paulo
When I was trying to get a pdf file from an html page I have a problem which is as follow:
BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.RED); Paragraph para = new Paragraph("",fontChinese); StringReader sr = new StringReader(sb.toString()); ArrayList p = HTMLWorker.parseToList(sr, null); for (int k = 0; k < p.size(); ++k) para.add((Element) p.get(k));
Although I had set the font to be fontChinese,there is no Chinese charactor in the generated pdf file.
Why?Does the HTMLWorker support Chinese fonts?
Thank you! Scott 2007-10-9
<HTML><HEAD><TITLE>Mail</TITLE> <META content="KsDHTMLEDLib.ocx, FreeWare HTML Editor 1.164.2, ?Kurt Senfer" name=GENERATOR> <META http-equiv=Content-Type content="text/html; charset=GB2312"></HEAD> <BODY style="FONT-SIZE: 9pt; FONT-FAMILY: ??" leftMargin=5 topMargin=5 #ffffff> <DIV><FONT face="Lucida Console" color=#800000 size=2>Hello,Paulo</FONT></DIV> <DIV><FONT face="Lucida Console" color=#800000 size=2></FONT> </DIV> <DIV><FONT face="Lucida Console" color=#800000 size=2>When I was trying to get a pdf file from an html page I have a problem which is as follow:</FONT></DIV> <DIV><FONT face="Lucida Console" size=2></FONT> </DIV> <DIV> </DIV> <DIV><FONT size=2><FONT face="Lucida Console"> BaseFont bfChinese = BaseFont.<I>createFont</I>(<SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">"STSongStd-Light"</SPAN>< /FONT></FONT><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">,</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 4"> </SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">"UniGB-UCS2-H"</SPAN> <SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">, BaseFont.</SPAN><I><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #0000c0; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">NOT_EMBEDDED</SPAN></I> <SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">);</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN>Font fontChinese = </SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">new</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"> Font(bfChinese, 12, Font.</SPAN><I><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #0000c0; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">NORMAL</SPAN></I><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">, Color.</SPAN><I><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #0000c0; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">RED</SPAN></I><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">);</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN>Paragraph para = </SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">new</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"> Paragraph(</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #2a00ff; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">""</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">,fontChinese);</SPAN> <SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN>StringReader sr = </SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">new</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"> StringReader(sb.toString());</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN>ArrayList p = HTMLWorker.<I>parseToList</I>(sr, </SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">null</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">);</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 2"> </SPAN></SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">for</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"> (</SPAN><B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: #7f0055; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt">int</SPAN></B><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"> k = 0; k < p.size(); ++k)</SPAN><SPAN lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Lucida Console'; mso-bidi-font-family: 'Lucida Console'; mso-font-kerning: 0pt"><o:p></o:p></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><SPAN style="mso-tab-count: 3"> </SPAN>para.add((Element) p.get(k));</SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"></SPAN> </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"></SPAN> </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000>Although I had set the font to be fontChinese,there is no Chinese charactor in the generated pdf file.</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000></FONT></SPAN> </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000>Why?Does the HTMLWorker support Chinese fonts?</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000></FONT></SPAN> </P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000>Thank you!</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000>   ; </FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000>   ; Scott</FONT></SPAN></P> <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none" align=left><SPAN lang=EN-US style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Lucida Console'; mso-bidi -font-family: 'Lucida Console'; mso-font-kerning: 0pt"><FONT color=#800000>   ; 2007-10 -9</FONT></SPAN></P><!--AID_SENDTO_BEGIN--></DIV></BODY></HTML>
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ __ ____ ____ ____ ____ ____ ____ ____ ____ ____ iText-questions mailing list iText-questions@(protected) https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
|
|
 |