如何使用Jasper报告触发现金抽屉

时间:2019-12-19 05:32:28

标签: java jasper-reports

我的应用程序使用Jasper Reports生成和打印报告。 Cash Drawer已连接到该打印机,并且应该在Print上触发。我需要在Jasper Reports中配置任何设置吗?这是我的代码示例,可以打印出帐单

PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A4);

PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName(printerName, null));

JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
SimplePrintServiceExporterConfiguration configuration = new 
                                                SimplePrintServiceExporterConfiguration();
configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
configuration.setDisplayPageDialog(false);
exporter.setConfiguration(configuration);
exporter.exportReport();

0 个答案:

没有答案