Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/12/2015, 13:18
jd7
 
Fecha de Ingreso: mayo-2013
Mensajes: 11
Antigüedad: 11 años
Puntos: 0
Información imprimir en impresora termica

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);