Yazıcı seç & baskı raporuna
private void PrintReportToPrinter(JasperPrint jp) throws JRException {
// TODO Auto-generated method stub
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
// printRequestAttributeSet.add(MediaSizeName.ISO_A4); //setting page size
printRequestAttributeSet.add(new Copies(1));
PrinterName printerName = new PrinterName("Microsoft XPS Document Writer", null); //gets printer
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(printerName);
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE);
exporter.exportReport();
}
için bir Yöntem oluşturma belirli bir yazıcıda Jasper raporu yazdırmak için Basit Çözüm ise sonra bu yöntemi
/* your code*/
Map parameters = new HashMap();
parameters.put("ckotid", kid);
try {
JasperDesign jsd = JRXmlLoader.load("report\\bill\\check_kot.jrxml");
JasperReport jr = JasperCompileManager.compileReport(jsd);
JasperPrint jp = JasperFillManager.fillReport(jr, parameters, con);
//JasperPrintManager.printPage(jp, 0, false);
//JasperPrint jp =reportEngine.fillReport() ;//it returns stream
PrintReportToPrinter(jp);//call method
olarak adlandırın.
Bu sorunla uğraşan tek kişi olamam ... –