how to print on custom paper with jasper report and java

I have an invoice in jasper with a custom paper size of 21 x 19 cm.

This invoice is printed on a dot-matrix printer EPSON LX-300 and it has the custom form paper created and configured in windows.

To print the invoice i use the following code:

    // buscamos la impresora seleccionada en las impresoras indicadas
    PrinterJob job = PrinterJob.getPrinterJob();
    PrintService[] servicios = PrintServiceLookup.lookupPrintServices(null, null);
    
    // luego de instalar la imrpesora vuelvo a buscar
    job = PrinterJob.getPrinterJob();
    servicios = PrintServiceLookup.lookupPrintServices(null, null);
    
    
    job.setPrintService(servicios[0]);
    
    //configuramos la impresion
    PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
    printRequestAttributeSet.add(new Copies(numeroCopias));
    printRequestAttributeSet.add(OrientationRequested.PORTRAIT);
    
    PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
    
    // configuramos el servicio de impresion
    JRPrintServiceExporter exporter = new JRPrintServiceExporter();
    
    exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, servicios[servicioSeleccionado]);
    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);
    
    // imprimos el informe
    exporter.exportReport();

the problem is when i print the invoice it print without the page size configured, like in A4, so the second copy is between the following two pages, but if i print from a notepad it print ok

how can i fix this?

 

gm.kusanagi's picture
Joined: May 24 2013 - 9:18am
Last seen: 9 years 8 months ago

Did you solve your problem?

garrizano - 6 years 2 months ago

0 Answers:

No answers yet
Feedback