kosalendra.singh1 Posted February 5, 2019 Share Posted February 5, 2019 No matter how many times I change or by how much I change the font size, it always stays the same in the generated pdf. Due to this most of data in static fields is getting truncated. All the text on the pdf has the same font size. Any sugestions on how to change the font size. I'm using the following code to generate pdfs.package rponte.report;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 rponte.report.ConnectionFactory;public class ReportGenerator { public static void main(String[] args) { Connection connection = null; try { String reportName = "myreport"; Map<String, String> parameters = new HashMap<String, String>(); parameters.put("ACCOUNT_NO","x"); parameters.put("INVOICE_DATE","z"); parameters.put("SEGMENT_ID","y"); parameters.put("SUBREPORT_DIR","./"); //step1 load the driver class Class.forName("oracle.jdbc.driver.OracleDriver"); //step2 create the connection object connection=DriverManager.getConnection( "jdbc:oracle:thin:@localhost:me","system","oracle"); // compiles jrxml JasperCompileManager.compileReportToFile("Corporate.jrxml"); // fills compiled report with parameters and a connection JasperPrint print = JasperFillManager.fillReport("Corporate.jasper", parameters, connection); // exports report to pdf JRExporter exporter = new JRPdfExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, print); exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, new FileOutputStream(reportName + ".pdf")); // your output goes here exporter.exportReport(); } catch (Exception e) { throw new RuntimeException("It's not possible to generate the pdf report.", e); } finally { // it's your responsibility to close the connection, don't forget it! if (connection != null) { try { connection.close(); } catch (Exception e) {} } } } }[/code] Link to comment Share on other sites More sharing options...
hozawa Posted February 5, 2019 Share Posted February 5, 2019 Font is specified in jrxml file. Be sure the specified font is available in your classpath. 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