tenho uma classe que efetua a impressão de tickets (A4, Bobina térmica 80mm) mandando a impressão direto, para a impressão em folha A4 está funcionando perfeitamente, o problema e para impressão do ticket, no Ireport ele está perfeito, porém quando eu mando direto ele não respeita a margem que necessito a esquerda, sendo assim ele corta o ticket e não exibe de forma correta, sei que o problema está na linha printRequestAttributeSet.add(new MediaPrintableArea(1.764f, 5.997f, 78.67f, 900, 79));
porém não caminho mais, ele altera tamanho e altura, mas as margens ele não altera. eis o código:
public boolean imprimir(JasperPrint jp, String impressora) {
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
boolean retorno = false;
try {
//1 - FOLHA A4
//2 - TICKET
if (tipo == 1) {
printRequestAttributeSet.add(MediaSizeName.ISO_A4);
} else {
printRequestAttributeSet.add(new MediaPrintableArea(1.764f, 5.997f, 78.67f, 900, 79));
}
printServiceAttributeSet.add(new PrinterName(impressora, null));
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();
retorno = true;
} catch (Exception e) {
retorno = false;
Logger.getLogger(Estoque.class.getName()).log(Level.SEVERE, null, e);
}
return retorno;
}