【发布时间】:2016-06-03 21:41:21
【问题描述】:
我已经用 Java 制作了一个应用程序。对于应用程序账单收据是必需的,我使用了 JasperReports (.jrxml) 文件。
我在 Java 代码中使用 JasperReports 调用来生成账单。
当我点击打印账单时,打印不正确,尺寸减小。
其实这个问题很奇怪。我在台式电脑上工作,当我从它打印时,打印还可以。但是当我将我的项目移动到其他系统(比如笔记本电脑)时,我得到的打印比原始打印减少了大约 50%。 iReport有什么问题吗?
我用过下面的Java代码:
public static void main(String[] args) throws JRException,
ClassNotFoundException, SQLException {
String reportSrcFile = "F:/Bills/FirstJasperReport.jrxml";
// First, compile jrxml file.
JasperReport jasperReport = JasperCompileManager.compileReport(reportSrcFile);
Connection conn = ConnectionUtils.getConnection();
// Parameters for report
Map<String, Object> parameters = new HashMap<String, Object>();
JasperPrint print = JasperFillManager.fillReport(jasperReport,
parameters, conn);
// Make sure the output directory exists.
File outDir = new File("C:/jasperoutput");
outDir.mkdirs();
// PDF Exportor.
JRPdfExporter exporter = new JRPdfExporter();
ExporterInput exporterInput = new SimpleExporterInput(print);
// ExporterInput
exporter.setExporterInput(exporterInput);
// ExporterOutput
OutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(
"C:/jasperoutput/FirstJasperReport.pdf");
// Output
exporter.setExporterOutput(exporterOutput);
//
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(configuration);
exporter.exportReport();
System.out.print("Done!");
}
如何解决此问题
【问题讨论】:
-
When I click on print bill the print is not proper, size is reduced- 你是什么意思?我认为您的报告模板中存在这个问题
标签: java jasper-reports