1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| public static void main(String[] args) throws JRException, IOException {
Utils.UserSession = new Utilisateur();
Utils.UserSession.base = "depottest3";
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(new File("C:/Users/khalil/Documents/report5.jasper"));
String[] codesbarres = {/*"aabarcode", "aabarcode", "950484460",*/ "kiki", "kiki"};
jpList = new ArrayList<>();
for(String codeb : codesbarres){
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("codebarre", codeb);
jpList.add(JasperFillManager.fillReport(jasperReport,
parameters, ConnectDB.getInstance()));
}
print();
}
public static void print() throws JRException{
long start = System.currentTimeMillis();
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
MediaSizeName mediaSizeName = MediaSize.findMedia(50,30,MediaPrintableArea.MM);
printRequestAttributeSet.add(mediaSizeName);
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
printServiceAttributeSet.add(new PrinterName("ZDesigner GK420d", null));
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jpList));
SimplePrintServiceExporterConfiguration configuration = new SimplePrintServiceExporterConfiguration();
configuration.setPrintRequestAttributeSet(printRequestAttributeSet);
configuration.setPrintServiceAttributeSet(printServiceAttributeSet);
configuration.setDisplayPageDialog(false);
configuration.setDisplayPrintDialog(false);
exporter.setConfiguration(configuration);
exporter.exportReport();
} |
Partager