aguth Posted May 20, 2009 Share Posted May 20, 2009 I was about to deploy a nice report I've been working on when I found that it renders differently in my Linux development environment than it does on my local Windows environment. I can compile it in either environment, it seems to only be different based on which server is generating the PDF. On Linux: - Some text fields are cut off on the right edge cutting off 1 or 2 characters. - The spacing between rows in the reports is too big. Is is almost like it is double spacing it instead of the nice tight spacing on Windows. My first thought was that it is using a different font, but when I save the PDF and view the Document Properties in Acrobat, I see the exact same settings. I am using the default font that iReport chooses (SansSerif/Helvetica). I have also tried this in two different Linux environments (Ubuntu/Gnome and Redhat without XWindows) with a straight copy of my whole tomcat install and webapp right off the windows box. Linux consistently renders poorly. This is a last minute blocker that is preventing me from using my report. Very sad. I have no idea what to do. Has anyone else experienced this? Thanks!Post Edited by aguth at 05/20/2009 02:00 Link to comment Share on other sites More sharing options...
teodord Posted May 20, 2009 Share Posted May 20, 2009 Hi, The answer to this problem you have is found in this FAQ here:http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/faq.html?group_id=252#FAQ25 Note that since JR 3.1.3, you can make use of font extensions to make sure you ship the required fonts with your reports so that they are available on the machine you are running on.Check the samples shipped with JR under the /demo/samples folder, especially the /demo/samples/fonts one.Also look into the /demo/fonts folder to see what a font extension is made of and how you could package your own font extension. That font extension there, containing two font families: DejaVu Sans and DejaVu Serif, are shipped with iR, in the form of a JAR file called jasperreports-dejavu-fonts.jar. You'd probably want to create a similar JAR for your fonts. I hope this helps.Teodor Link to comment Share on other sites More sharing options...
aguth Posted May 20, 2009 Author Share Posted May 20, 2009 Thanks so much, I should have seen that in the FAQ. Anyways, after switching to a TTF font and including it with the appropriate properties files, the PDF's look identical on both platforms. Link to comment Share on other sites More sharing options...
frblusso Posted May 25, 2009 Share Posted May 25, 2009 HiI have the same problem and i try to understand the solution delivered in the samples/font directory.So i add in the java source directory of my web application the following files: the fonts files : arial.ttf and arialnb.ttf. the fonts.xml files where i define one bean corresponding to my font family :<bean id="arialFamily" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily"> <property name="name" value="TestFontArial"/> <property name="normal" value="arial.ttf"/> <property name="bold" value="arialbd.ttf"/> <property name="pdfEncoding" value="Identity-H"/> <property name="pdfEmbedded" value="true"/> </bean> In the java code I add the 2 lines to make the mapping between the logical nameFontKey keya = new FontKey("TestFontArial", false, false);PdfFont pdfFonta = new PdfFont( "arial.ttf", "Cp1252", false);fontMap.put(keya, pdfFonta); In the reports.jrxml, i define a static text as :<textElement><font fontName="TestFontArial" size="10" isBold="false"/></textElement> then i add the jasperreports_extensions.properties .When i generate on windows or on linux i have still a different pdf document.could you explain me what is the error i make?In the example you give, i do not understand why we have to duplicate the mapping between logical font and ttf file , once in the java code and once in the fonts.xml file?thancks for any informationFrançoise Link to comment Share on other sites More sharing options...
aguth Posted May 25, 2009 Author Share Posted May 25, 2009 I didn't use any font mapping. I just changed the font name in my .jrxml file. <textElement> <font fontName="DejaVu Sans" size="8" isBold="true"/></textElement><text><![CDATA[Date & Time]]></text> Then I put the fonts.xml, jasperreports_extension.properties and all the .ttf files in the WEB-INF/classes folder of my war file. And it worked! Link to comment Share on other sites More sharing options...
frblusso Posted May 26, 2009 Share Posted May 26, 2009 Hithancks a lot for your answer.So i have deleted the mapping code between the font key and the pdffont in my java code.But it seems that the file fonts.xml is not read (in Windows and in linux) because i have no log info about the loading of beans fonts ?is there something to do so that the file jasperreports_extension.properties is taken into account ?regards Link to comment Share on other sites More sharing options...
aguth Posted May 26, 2009 Author Share Posted May 26, 2009 I'm not sure what the issue is - I don't do anything special to indicate where the properties file is. I just put the properties file in the WEB-INF/classes directory, which means it will be found on the classpath. I think as long as it is on the classpath, it should be found. I keep fonts.xml in the same spot. Here is my jasperreports_extension.properties:net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.extensions.SpringExtensionsRegistryFactorynet.sf.jasperreports.extension.fonts.spring.beans.resource=fonts.xmlI see this line in the console output of my tomcat instance once I generate the first report (but not at webapp start time):77047 [http-8080-Processor1] INFO xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:/C:/apache-tomcat/webapps/ReportingApp/WEB-INF/classes/fonts.xml]Make sure you have spring-beans.jar and spring-core.jar in your lib folder too. Link to comment Share on other sites More sharing options...
frblusso Posted May 29, 2009 Share Posted May 29, 2009 Hii finally found what was wrong : in my workspace there was an old version of jasperreports (but not in the classpath!) .SO the fonts.xml is loaded. But the result is only the same on windows and Linux .In my fonts.xml, i put 2 beans, one first with mapping relative to arial font , and a second one with a copy of the mapping of the example /fonts (DejaVu sans) The result is that the result for text using the second bean is the same on Linux and Windows.But for text relative to arial family, the result is not the same, and even it seems that the police mapping is not used in the final report.I fianlly test with only one bean in the fonts.xml , the arial family, and the result is nearly identical : i have a title which appears in local on 3 lines , and on linux only the 2 first lines appears...But for other static texts the text is no more truncated, that's a good thing! Do we have only one bean described in the fonts.xml?regards Link to comment Share on other sites More sharing options...
frblusso Posted June 2, 2009 Share Posted June 2, 2009 Hito conclude on that topic, i would like to have replies from Teodor about those questions :1) to export reports to PDF do we always have to use the solution of describing in a spring file the font in order to be sure to have the same rendering whichever the server environnment is ?2) are there any font name that can be used without this mapping description to export to pdf report?3) In case we use the spring file to describe more thant one font family, I discovered that only the last bean is taken into account . Is it a bug?4) In the solution, we see that the notion of pdfFontname is no more used in jrxml file. If in ireport3.1.4 we add a static text, by default only the font name attribute is put. Does it mean that the attibute pdfFontName is obsolete?I really need answers in order to explain to our teams the necessity to migrate to jasper3.1.5 (we use at the present time 3.1.2).RegardsFrançoise Link to comment Share on other sites More sharing options...
frblusso Posted June 18, 2009 Share Posted June 18, 2009 Hii really need answers to my previous message, specially to the third question : is it possible to declare more than one police font inside fonts.xml? i repeat that in my test it does not work.We have a projet which at the present time produce pdf file in many languages (european, asian, ...) and so the fonts family can be differents from all those languages.regardsFrançoise Link to comment Share on other sites More sharing options...
lucianc Posted June 25, 2009 Share Posted June 25, 2009 frblussoWrote: i really need answers to my previous message, specially to the third question : is it possible to declare more than one police font inside fonts.xml? i repeat that in my test it does not work. We have a projet which at the present time produce pdf file in many languages (european, asian, ...) and so the fonts family can be differents from all those languages. Yes, it's possible. See the demo/fonts/fonts.xml file in the JR distribution, it shows (the part is commented out though) how to specify fonts per locales.Regards,Lucian Link to comment Share on other sites More sharing options...
frblusso Posted June 26, 2009 Share Posted June 26, 2009 hithancks Lucian for your last answer.So for each bean , we have to set a specific locale tag , and the same name value for the property <name> .I have another question about using asian fonts , as said in the FAQ , to use chinese, japanese fonts, I put the iTextAsian.jar and iTextAsianCmaps.jar on my Web application.But how can I specify in the file fonts.xml a japanese or chinese font as there are described with .cmap files anf not ttf fonts?regards Link to comment Share on other sites More sharing options...
lucianc Posted June 29, 2009 Share Posted June 29, 2009 See Teodor's answer here.Regards,Lucian Link to comment Share on other sites More sharing options...
mtaylor Posted October 6, 2009 Share Posted October 6, 2009 I am facing a similar issue and have a question about the locales property.How, specifically, does this property effect PDF generation?<!-- <property name="locales"> <set> <value>en_US</value> <value>de_DE</value> </set> </property>-->is this based on a given locale as input to the exporter? Is it possible to handle the case where there can be multiple languages in a generated report, say english and chinese.In my case, our app is given a locale, but that represents the locale of the person generating the report, not the settings of the data itself. Ideally there would be one font that could handle all languages, or at least many of them [unicode]. Link to comment Share on other sites More sharing options...
azulcm Posted November 27, 2009 Share Posted November 27, 2009 This is great. It works like a charm. I was pulling my hair out with this issue. Besides, with this configuration, you avoid the problem reported in http://jasperforge.org/plugins/mantis/view.php?id=3556 now i don't have to remeber to specify the PDF style (bold, italics, etc) for each field or label.Thanks. Link to comment Share on other sites More sharing options...
marionunes1997 Posted June 13 Share Posted June 13 Hello, the link pointing to a solution on this is no longer available. Me and my team have been having the same issues regarding cut Chinese characters which do not appear in some columns but not others when line break or page break. We've tried everything and when it seems like it is solved, when we go try it on a different environment, the behaviour is different and the problem is not solved. Sometimes white spaces completely disappear along with part of the content too. I cannot follow the link to Teodor's answer as it is no longer available. Any help? Link to comment Share on other sites More sharing options...
lucianc Posted June 13 Share Posted June 13 marionunes1997 I don't think we'll be able to retrace the target of the link posted above. But there are good chances that it wouldn't actually be relevant to your problem, I recommend posting your question in a new thread. Regards, Lucian 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