Déb*_*ora 5 java jasper-reports
当我发送jasper报告进行打印时,打印机将文档名称显示为"jasper report-report name"(当有打印阙时,文档名称也是"jasper report").如何将其更改为其他名称?
例子:
JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
JasperPrint jrPrint = JasperFillManager.fillReport(jasperReport, params, getDataSource());
if (reportName != null && reportName.length() > 0) {
jrPrint.setName(reportName);
}
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A4);
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName("PDFCreator", null));
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jrPrint);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.TRUE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
exporter.exportReport();
Run Code Online (Sandbox Code Playgroud)
您可以借助name
属性在报告模板中设置报告名称:
<jasperReport .. name="Sample report name to print" ..>
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
5335 次 |
最近记录: |