tjiptomangun Posted December 16, 2010 Share Posted December 16, 2010 Dear all,I currently working on adding currency symbol of some countries to my report. I extend WineTahoma.ttf to add this font. I add thai bath currency symbol unicode_e3f to this ttf, make a jar file (xfont.jar) that its content is this only WineTahoma.ttf , include it as a library in my web application and run it , and the pdf shows. I do this in my SuSE 10.3 box jvm 1.0.6_02 from sun, jasperreport2.0.5, itext 1.3.1 and tomcat.1.6.0.16 (namely 1st.machine).I then copy my war file to another box(2.nd machine) exactly the same as the first machine (OS, jvm, jasperreport,itext and tomcat) and the 3rd.machine (SuSE.10.1 and the rest are the same). I run it and the font does not show, though using acrobatreader menu file->properties->fonts WineTahoma.ttf listed as one of embedded font.I then make a small non web program (means i do not use tomcat), that compile the same jrxml and export it to pdf in 2nd and 3rd machine and the font shows in document.I then working with the font (with fontforge) by copying glyphs from printable char B to unicodee3f , export to WineTahoma.ttf and make the jar file (xfont.jar) run it with my web application in 2nd and 3rd machine and the font does not show. I also modify the printable char B and run it with my web app and ist show.I then summarize that perhaps it is the problem with tomcat that does not recognize unicode, since all standard(printable) character does show.The only different of the 1st to the 2nd and 3rd machine it that 1st machine works with xwindows meanwhile the 2nd and 3rd do not. Does anybody ever find the same problem? Really need your help.I attach my jrxml and my font.Here is the code I use to create this report. getLogger().info("creating paper: " + jasperName); String reportSource = getRealPath(jasperName); JRPdfExporter exporter = new JRPdfExporter(); JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jasperPrint = null; getLogger().info("fill paper: " + jasperName); synchronized (getSqlExecutor()) { jasperPrint = JasperFillManager.fillReport(jasperReport, params, getConn()); } getLogger().info("ceate pdf: " + jasperName); HashMap fontMap = new HashMap(); FontKey key = new FontKey("WineTahoma", true, false); PdfFont font = new PdfFont("WineTahoma.ttf", com.lowagie.text.pdf.BaseFont.IDENTITY_H, true); fontMap.put(key, font); exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRPdfExporterParameter.FONT_MAP, fontMap); exporter.setParameter(JRPdfExporterParameter.CHARACTER_ENCODING, "UTF-8"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos); exporter.exportReport(); currentPaperData =baos.toByteArray(); This is another version of code i use getLogger().info("creating paper: " + jasperName); String reportSource = getRealPath(jasperName); JRPdfExporter exporter = new JRPdfExporter(); JasperReport jasperReport = JasperCompileManager.compileReport(reportSource); JasperPrint jasperPrint = null; getLogger().info("fill paper: " + jasperName); synchronized (getSqlExecutor()) { jasperPrint = JasperFillManager.fillReport(jasperReport, params, getConn()); } getLogger().info("ceate pdf: " + jasperName); /currentPaperData = JasperExportManager.exportReportToPdf(jasperPrint);regards,hb Link to comment Share on other sites More sharing options...
tjiptomangun Posted December 16, 2010 Author Share Posted December 16, 2010 Sorry , the 1st machine is SuSE 11.1. The other is still the same.regards,hb Link to comment Share on other sites More sharing options...
tjiptomangun Posted December 17, 2010 Author Share Posted December 17, 2010 The problem is neither in tomcat or jasper, but in environment variables. I run tomcat in 1st machine using startup.sh, and in 2nd and 3rd machine using service tomcatd start. The SuSE /sbin/service command set LANG to Posix that do not support non ascii character. The solution in by setting Language to english in /etc/init.d/tomcatd.export LANG="en_US.UTF-8"thank you 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