How to Change Jasper Report Print Name

When I send a report on jasper for printing, the printer displays the document name as "jasper report report name" (when there is a print queue, the document name is also a "jasper message"). How can I change it to another name?

+4
source share
2 answers

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 a report template)

    You can set the name of the report in the report template using the name attribute:

     <jasperReport .. name="Sample report name to print" ..> 
+6
source

I found this by accident, if you put '/' in front of the name you want, it will remove the string "JasperReports -" from the print name. A.

 JasperPrint jrPrint = JasperFillManager.fillReport(jasperReport, params, getDataSource()); if (reportName != null && reportName.length() > 0) { jrPrint.setName('/'+reportName); } 
+1
source

Source: https://habr.com/ru/post/1381907/


All Articles