hola, podrían ayudarme,
lo que pasa es que quiero imprimir en una impresora termica epson tm-t20,
para esto actualmente estoy haciendo los siguiente.
1. creo el reporte de factura y los guardo en como documento .pdf
2. accedo al archivo pdf y lo envió a la impresora para su impresión
lo que pasa es que al imprimir la factura, no me re dimensiona el alto del archivo y en cambio este se imprime mas pequeño, continuación dejo el código que actualmente estoy usando,
pregunta:
¿como configuro la impresión para que el largo del papel varié según el tamaño de la factura?
Código:
String filePath = "./Facturas/factura_N°_" + numero + ".pdf";
FileInputStream fileInputStream = new FileInputStream(filePath);
byte[] pdfContent = new byte[fileInputStream.available()];
fileInputStream.read(pdfContent, 0, fileInputStream.available());
ByteBuffer buffer = ByteBuffer.wrap(pdfContent);
fileInputStream.close();
final PDFFile pdfFile = new PDFFile(buffer);
PDFPrintPage pages = new PDFPrintPage(pdfFile);
PrinterJob printJob = PrinterJob.getPrinterJob();
PageFormat pageFormat = PrinterJob.getPrinterJob().defaultPage();
printJob.setJobName("");
Book book = new Book();
book.append(pages, pageFormat, pdfFile.getNumPages());
printJob.setPageable(book);
Paper paper = new Paper();
paper.setSize(pagesise.getWidth() , pagesise.getHeight());
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pagesize.getHeight());
paper.getHeight());
pageFormat.setPaper(paper);
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
attributes.add(OrientationRequested.LANDSCAPE);
attributes.add(new MediaPrintableArea(0, 0,(int)paper.getWidth(), (int)paper.getHeight(),MediaPrintableArea.INCH));
printJob.print(attributes);