Jump to content
Changes to the Jaspersoft community edition download ×

font size, tomcat pdf generation


am06

Recommended Posts

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 you

PS: I use the war file without jasperserver installed.

 

Link to comment
Share on other sites

  • 3 months later...
  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

yes I solved it. 

  • do NOT use the .jasper file created with jaspersoft studio
  • compile the .jrxml into a .jasper file with a java program

Here 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.java

and 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

  • 7 months later...
  • 1 month later...
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

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...