Issue
When I send the jasper report to print, the printer shows the document name as "jasper report-report name" (When there is a printing que, document name is also "jasper report" ). How can I change it to another name?
Solution
Using JasperReports API
If you are using JasperReports API you should set report name with help of JasperPrint.setName(java.lang.String name) method.
The sample:
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();
Using iReport (editing report template)
You can set report name in report template with help of
name
attribute:<jasperReport .. name="Sample report name to print" ..>
Answered By - Alex K
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.