am06 Posted May 11, 2014 Share Posted May 11, 2014 Hello,I created a report under Jaspersoft Studio (under OSX). Everything is fine with it, I can change the font size or use custom fonts (preferences->fonts). Rendering the report with "preview" and "export as pdf" are both fine.I render the pdf with the standalone application jasperserver-ws-sample.war under tomcat 7, Ubuntu, and a custom executeReport.jsp:JasperPrint jasperPrint = JasperFillManager.fillReport(dot_jasper_file, hashMap, conn);byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint); Everything is fine (parameters, data filled from sql, layout, pdf) except two things:- whatever the font size in the jasper file, the pdf use font.size=10- default font (SansSerif) render as Helvetiva (I'm fine with this), but custom fonts prevent the pdf generation (seems it doesn't use the jar file containing fonts, created with Jaspersoft Studio and saved in webapp/WEB-INF/lib). I would be happy to change font size (below 10).Thank youPS: I use the war file without jasperserver installed. Link to comment Share on other sites More sharing options...
diyosifova Posted September 11, 2014 Share Posted September 11, 2014 Hi,I'm having a similar issue. I needed Times New Roman font, so I add it as suggested in the comments of this post. And it works fine, but no matter what font size is set in the report, in the export file (pdf or docx), the font size is always the default one - 10.Did you find a solution for your font size problem? Link to comment Share on other sites More sharing options...
am06 Posted September 11, 2014 Author Share Posted September 11, 2014 yes I solved it. do NOT use the .jasper file created with jaspersoft studiocompile the .jrxml into a .jasper file with a java programHere is the list of the files needed by the java program (in ./lib):commons-beanutils-1.8.0.jarcommons-collections-3.2.jarcommons-digester-1.7.jarcommons-logging.jaritext-2.1.7.js2.jarjasperreports-5.5.0.jarmysql-connector-java-5.1.28-bin.jarservlet-api-2.4.jar[/code]The java program is:import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.sql.Connection;import java.sql.SQLException;import java.util.HashMap;import java.util.Map;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JRExporter;import net.sf.jasperreports.engine.JRExporterParameter;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.export.JRPdfExporter;import java.sql.*;/*** You'll need these jar's below:** jasperreports-5.0.1.jar* iText-2.1.7.jar (needed to generate PDF)* jfreechart-1.0.12.jar (needed to graphics and charts)* jcommon-1.0.15.jar (needed to graphics and charts)* commons-beanutils-1.8.2.jar* commons-collections-3.2.1.jar* commons-digester-2.1.jar* commons-logging-1.1.jar*/public class compil_jrxml {public static void main(String[] args) { int count = args.length; try { if (count>0) { String reportName = args[0]; String str[]=reportName.split("\."); String reportName_jasper = str[0] + ".jasper"; // compiles jrxml JasperCompileManager.compileReportToFile(reportName, reportName_jasper); } } catch (Exception e) { throw new RuntimeException("It's not possible to generate the jasper report.", e); } }}[/code]to compile the java program:[/code]javac -classpath ./lib/jasperreports-5.5.0.jar compil_jrxml.javaand finally to compile a .jrxml and h-generate the .jasper:[/code]java -cp .:./lib/jasperreports-5.5.0.jar:./lib/commons-logging.jar:./lib/commons-digester-1.7.jar:./lib/commons-collections-3.2.jar:./lib/servlet-api-2.4.jar:./lib/commons-beanutils-1.8.0.jar:./lib/itext-2.1.7.js2.jar:./lib/mysql-connector-java-5.1.28-bin.jar compil_jrxml report.jrxml Link to comment Share on other sites More sharing options...
diyosifova Posted September 12, 2014 Share Posted September 12, 2014 Thank you very much! It works just fine now. Link to comment Share on other sites More sharing options...
juanzorrillaaa19 Posted April 16, 2015 Share Posted April 16, 2015 I've done the same way, compiling the .jrxml from java and it works. But doing it this way is slower and computational time is lost, so I want to do it from the .jasper but does not work this way. Any solution for this ?? Link to comment Share on other sites More sharing options...
am06 Posted April 16, 2015 Author Share Posted April 16, 2015 you only need to compile the jrxml once. Then you can use the created .jasper as if you created it with jasperstudio and you'll not loose computational time at each report generation. Link to comment Share on other sites More sharing options...
jony404 Posted June 2, 2015 Share Posted June 2, 2015 I just saw this; it's a problem of versions. The most accurate solution is to download the correct version of ireport, if your project is using jasperreports-4.0.6.jar, the you need to download that version if ireport and compile with it. Link to comment Share on other sites More sharing options...
msmeirelles Posted July 29, 2015 Share Posted July 29, 2015 You probally using an older version of jasperreport library in your application. Try to use jasperreports-X.X.X.jar compatible with the version that you use to create teh jasper file. 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