Boas,
necessito centralizar uma impressão em uma A4, pesquisei e não consegui atributos para tal juntamente com o MediaPrintableArea, com isso tentei na mão com as suas dimensões, o que não tive sucesso, alguém tem idéia melhor de como imprimir no centro da página?
Centralizar apenas horizontalmente.
Preciso imprimir cartões de tamanho único, mas o papel fica no meio da impressora, quando imprimo em uma A4, sai do lado esquerdo da página, preciso que saia no meio.
meu código original:
job.setPrintService(services[selectedService]);
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
MediaSizeName mediaSizeName = MediaSizeName.ISO_A4;
printRequestAttributeSet.add(mediaSizeName);
printRequestAttributeSet.add(new MediaPrintableArea(
0f, 0f,
84f,
270f, Size2DSyntax.MM));
printRequestAttributeSet.add(new Copies(1));
JRPrintServiceExporter exporter;
exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
/* We set the selected service and pass it as a paramenter */
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE, services[selectedService]);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, services[selectedService].getAttributes());
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.FALSE);
exporter.exportReport();
Aguardo sugestões,
obrigado
Pedro Eugênio