如何更改Jasper报告打印名称

Déb*_*ora 5 java jasper-reports

当我发送jasper报告进行打印时,打印机将文档名称显示为"jasper report-report name"(当有打印阙时,文档名称也是"jasper report").如何将其更改为其他名称?

Ale*_*x K 7

例子:

    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)