zol777 Posted June 16, 2008 Share Posted June 16, 2008 My program is going export a JPG image using the following code. It is successfully export a page as JPG but all chinese character is displayed as boxes. Code: It is interesting that If i export the JasperREport as PDF/HTML, the chinese font is displayed correctly.I have looked into some documents. It seem AWT component display chinese character as box if a chinese font is missing JRE/lib. Does it related to my problem?Can any one give me a suggestion for my problem!?My environment:Jasper Report version : 1.3.3 JDK version : 1.4 Platform : Unix Librariies : I have put IText , IText-Asian and iTextAsianCmaps in my classpath according to jasper report's FAQThank you very much! Post edited by: zol777, at: 2008/06/16 13:16 Link to comment Share on other sites More sharing options...
lucianc Posted June 17, 2008 Share Posted June 17, 2008 The Java/AWT font you are using for the text element (via the fontName) attribute doesn't have Chinese glyphs. Make sure that the font given by the fontName attribute is available in the JVM and that it supports Chinese characters. Regards,Lucian Link to comment Share on other sites More sharing options...
zol777 Posted June 17, 2008 Author Share Posted June 17, 2008 Thank you for your kindly reply. but how can I "Make sure that the font given by the fontName attribute is available in the JVM and that it supports Chinese characters" ? Method 1. Install the font involved in JRXML on unix platform (Does restart is required after installation?) OR Method 2. update the font.properties of my JRE using ashttp://www.chinesecomputing.com/programming/java.html does OR Method 3. add the font to my classpath such as java -cp classpath chinesefont.ttf myreport Does any one of above method feasible can achieve "Make sure that the font given by the fontName attribute is available in the JVM and that it supports Chinese characters" ? If No. Pls help to suggest? thx. Link to comment Share on other sites More sharing options...
lucianc Posted June 17, 2008 Share Posted June 17, 2008 I think the best way to find out how to install fonts in Java is to consult the JDK documentation. The font installation mechanism differs from one JDK implementation to another, there is no generic procedure. Usually, JDK implementations automatically use all the fonts installed in the operating system, so the first approach you could take could be to install the required fonts in the OS. I don't know whether you need to restart the system, refer to the OS documentation to find out. If you use a 1.6 JDK, you can also register fonts programmatically via GraphicsEnvironment.registerFont. Regards,Lucian Link to comment Share on other sites More sharing options...
zol777 Posted June 18, 2008 Author Share Posted June 18, 2008 Fonts involved of my JRXML are ONLY from in IText-Asian and iTextAsianCmaps like <reportFont name="Arial_Normal" isDefault="false" fontName="Arial" size="11" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="MSung-Light" pdfEncoding="UniCNS-UCS2-H" isPdfEmbedded="true"/> But when i extract IText-Asian and iTextAsianCmaps, No TTF(font file like file) is included. It seem have some mapping file ONLY. So did the font in my report are using asian font pack of adobe pdf but not from IText-Asian and iTextAsianCmaps? In order to install the required fonts in the OS, should i go to install the asian font pack that using in PDF? If the above assumption is corrected, so if I can read the chinese PDF in my unix after installation those required font that mean my problem is resolved? Moreover, I have read FAQ that API provide that i can convert the file to SVG. So can i convert jasperprint to SVG and then to JPG? In the conversion of jasperprint to SVG, Does it require involve any class from package of java.awt.*? thxPost edited by: zol777, at: 2008/06/18 02:08 Link to comment Share on other sites More sharing options...
andhdo Posted June 25, 2008 Share Posted June 25, 2008 Jpg exporter. [file name=JRImage2Exporter_java.txt size=2467] Post edited by: andhdo, at: 2008/06/24 20:13 Link to comment Share on other sites More sharing options...
andhdo Posted June 25, 2008 Share Posted June 25, 2008 Jpg exporter utils [file name=JRImageUtils_java.txt size=2811] Link to comment Share on other sites More sharing options...
zol777 Posted June 28, 2008 Author Share Posted June 28, 2008 To andhdo: your method will not work since JasperPrintManager.printPageToImage is involved In JasperPrintManager.printPageToImage, call java.awt to draw JasperPrint Object. It is unable to print chinese character in propery manner if java.awt don't support that font Anyway thx to ur help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now