noon Posted August 11, 2006 Share Posted August 11, 2006 Hi, Our J2EE software is based on Spring Framework and we use the Jasper Reports as reporting tool. All the reports (single paged PDF-forms) have been designed by using Ireport. However I have problem with Jasper Reports PDF rendering. The PDFs are rendered perfectly when the application is run on Tomcat (on Windows). The problems starts when I install the application on Oracle 10g (on AIX UNIX). The problem is that the PDF looks a bit differend. Biggest difference is the space between lines + some other. When the space between the rows is larger than on the original, the text doesn't fit to the text field on the report form. One solution is ofcourse to enlarge the text fields, but on every situation it's not possible. Does anybody have any idea why these PDFs renders differently? Link to comment Share on other sites More sharing options...
teodord Posted August 11, 2006 Share Posted August 11, 2006 Hi, Those rendering differences are caused by missing fonts on the AIX machine.If for instance you have used fontName="Arial", it works perfect on Windows, but on AIX, since Arial does not exists, some other default font is used, with different font metrics, hence the various side effects.The recommended way to deal with fonts on crossplatform applications is to make sure you rely on some TTF files that you ship with your application and install them on-the-fly using the Font.createFont() method.You would also be referencing thos TTF files in the pdfFontName attribute in JRXML. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
noon Posted August 14, 2006 Author Share Posted August 14, 2006 Thanks Teodor for replying. I'll try what you suggested. I'll post again if I managed to find a proper solution. Link to comment Share on other sites More sharing options...
maldoror Posted July 30, 2007 Share Posted July 30, 2007 Hello all, I'm having exactly the same problem in AIX, and I do have the TTF files embedded in the report. Has the above suggested solution worked? Thanks mal Link to comment Share on other sites More sharing options...
forhitesh Posted January 23, 2009 Share Posted January 23, 2009 Hi Teodor, Can you please elaborate this issue and give some sample code for resolving this issue? Link to comment Share on other sites More sharing options...
bulut Posted January 23, 2009 Share Posted January 23, 2009 HiI also met with this problem. My problem was like yours.The problem was the report i viewed on windows/tomcat server behaves different on linux/oracle app. server.And i found the reason of this problem was the fonts that i used in my report. The font u selected in design time should be available on linux machine. And jvm must know this fonts. For example if you use Arial your report behaves different. Becasue Arial doesnt exists on linux. For solution u can try these1-) Choose a font which already exists on linux for fontName attribute for every fieled in report. (For example Lucida Bright)2-) Make available the font you used for linux. Post Edited by bulut bulut at 01/23/09 15:31 Link to comment Share on other sites More sharing options...
pablodc Posted March 2, 2009 Share Posted March 2, 2009 Hi, I have solved this problem using a method like the one posted in this reply. fontmap is a static HashMap in the class used later in the PDF exporter in this way: pdfexporter.setParameter(JRExporterParameter.FONT_MAP, FontRegister.fontMap); FontRegister is the class that contains the registerFont method. Take in consideration that this method needs java 1.6 due to the use of "registerFont" method to dinamically register the font. If you report design contain in the pdfFontName attribute a value like "font.ttf" the font.ttf must be placed in the webapp classpath: WEB-INF/lib or WEB-INF/classes (just place de fonts in the root, not in subfolders). If the weapp have a a custom font dir you must indicar in the pdfFontName (again, if the value is a ttf font file) the full path to this font. i.e: /home/user/fonts/arial.ttf Hope this helps someone. Forgive my bad english (is not my native language as you can read). Code: private boolean registerFont(String fontsdir, String fontfile) { FileInputStream fis = null; boolean retval = false; String fullfontpath = fontsdir + File.separator + fontfile; FontKey key; PdfFont font; try { _log.info(sessionid +"registering in AWT"); fis = new FileInputStream(fullfontpath); Font customFont = Font.createFont(Font.TRUETYPE_FONT, fis); ge.registerFont(customFont); _log.info(sessionid +"registering en iText"); FontFactory.register(fullfontpath); _log.info(sessionid + "se logro registrar la tipografia <" + customFont.getFontName() + "> correspondiente a la familia <" + customFont.getFamily() + ">"); /** * actualizamos el parametro FONT_MAP que luego utilizara la clase * ReportExporter al exportar el reporte al formato PDF. */ key = new FontKey(customFont.getFontName(), false, false); font = new PdfFont(fullfontpath, "Cp1252", true); fontMap.put(key, font); retval = true; } catch (FontFormatException ex) { _log.error(sessionid + "se produjo un error al registrar la " + "tipografia <" + ex + ">"); ex.printStackTrace(); } catch (IOException ex) { _log.error(sessionid + "se produjo un error de E/S <" + ex + ">"); ex.printStackTrace(); } catch (Exception e) { _log.error(sessionid + "se produjo un error generico <" + e + ">"); e.printStackTrace(); } finally { try { fis.close(); } catch (IOException ex) { _log.error(sessionid + "se produjo un error al cerrar el " + "inputstream de la tipografia <" + ex + ">"); ex.printStackTrace(); } } return retval; } Link to comment Share on other sites More sharing options...
richkatz Posted October 24, 2009 Share Posted October 24, 2009 Hi Teodor, How is pdfFontName supposed to relate to the registered font name?This is just not quite working - or making sense yet. When running on Linux, I can't get the fonts to register, but even when I do, how do I refer to them in the JRXML?First, I get this exception which I can find exactly NO WHERE on the Internet:ExceptionConverter: com.lowagie.text.DocumentException: Table 'name' does not exist in /home/tomcat/webapps/ourproject/WEB-INF/classes/arial.ttf When it can't find or load the font it gets: loadFont exception: ExceptionConverter: com.lowagie.text.DocumentException: Table 'name' does not exist in /home/tomcat/webapps/kcpt/WEB-INF/classes/arial.ttfThe "loadFont exception" comes from the code: loadFont(gfp+"arial.ttf","arial.ttf"); loadFont(gfp+"ariali.ttf","ariali.ttf"); loadFont(gfp+"arialbd.ttf","arialbd.ttf"); loadFont(gfp+"arialbi.ttf","arialbi.ttf"); public boolean loadFont(String fontLocation, String fontName) { boolean ret=false; try { FontFactory.register(fontLocation, fontName); ret=true; } catch (Exception de) { logger.warn(" loadFont exception: ", de); } return ret; }I am running in Tomcat on Linux. And the font f iles are there in the classes directory: arial.ttf, arialbd.ttf, and araili.ttf and arialbi.ttf Second about the pdfFontName. I refer to these in the JRXML as pdfFontName= what?What I tried is: <staticText> <reportElement x="12" y="24" width="550" height="21"/> <textElement textAlignment="Center"> <font fontName="Arial" size="11" isBold="true" isUnderline="true" pdfFontName="arialbd.ttf"/> </textElement> <text><![CDATA[iI. CRITICAL FUNCTIONS]]></text> </staticText>That FAILS -- completely.So, I went back to: <staticText> <reportElement x="12" y="24" width="550" height="21"/> <textElement textAlignment="Center"> <font fontName="Arial" size="11" isBold="true" isUnderline="true" pdfFontName="Helvetica-Bold"/> </textElement> <text><![CDATA[iI. CRITICAL FUNCTIONS]]></text> </staticText>This gets some other font (probably because it can't find the font its trying to register). Many thanksRegards, Richard Katz Link to comment Share on other sites More sharing options...
mkdasg Posted July 27, 2010 Share Posted July 27, 2010 Hi, I want to generate one simple Jasper Report using Spring Framework 3.0I am using Glassfish 2.1 as my webserver and its a web application rendering the report.The application generates report but its a blank pdf or blank html page. Can you help me? Thanks in Advance 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