fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. imprimirFactura();
  14. }
  15.  
  16.  
  17. void imprimirFactura(){
  18.  
  19. PrinterMatrix printer = new PrinterMatrix();
  20.  
  21. Extenso e = new Extenso();
  22.  
  23. e.setNumber(101.85);
  24.  
  25.  
  26. //Definir el tamanho del papel para la impresion aca 25 lineas y 80 columnas
  27. printer.setOutSize(60, 80);
  28. //Imprimir * de la 2da linea a 25 en la columna 1;
  29. // printer.printCharAtLin(2, 25, 1, "*");
  30. //Imprimir * 1ra linea de la columa de 1 a 80
  31. printer.printCharAtCol(1, 1, 80, "=");
  32. //Imprimir Encabezado nombre del La EMpresa
  33. printer.printTextWrap(1, 2, 30, 80, "FACTURA DE VENTA");
  34. //printer.printTextWrap(linI, linE, colI, colE, null);
  35. printer.printTextWrap(2, 3, 1, 22, "Num. Boleta : " + txtVentaNumeroFactura.getText());
  36. printer.printTextWrap(2, 3, 25, 55, "Fecha de Emision: " + dateFechaVenta.getDate());
  37. printer.printTextWrap(2, 3, 60, 80, "Hora: 12:22:51");
  38. printer.printTextWrap(3, 3, 1, 80, "Vendedor. : "+ txtVentaIdVendedor.getText() +" - " + txtVentaNombreVendedor.getText());
  39. printer.printTextWrap(4, 4, 1, 80, "CLIENTE: " + txtVentaNombreCliente.getText());
  40. printer.printTextWrap(5, 5, 1, 80, "RUC/CI.: " + txtVentaRucCliente.getText());
  41. printer.printTextWrap(6, 6, 1, 80, "DIRECCION: " + "");
  42. printer.printCharAtCol(7, 1, 80, "=");
  43. printer.printTextWrap(7, 8, 1, 80, "Codigo Descripcion Cant. P P.Unit. P.Total");
  44. printer.printCharAtCol(9, 1, 80, "-");
  45. int filas = tblVentas.getRowCount();
  46.  
  47. for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
  48. printer.printCharAtCol(filas + 1, 1, 80, "=");
  49. printer.printTextWrap(filas + 1, filas + 2, 1, 80, "TOTAL A PAGAR " + txtVentaTotal.getText());
  50. printer.printCharAtCol(filas + 2, 1, 80, "=");
  51. printer.printTextWrap(filas + 2, filas + 3, 1, 80, "Esta boleta no tiene valor fiscal, solo para uso interno.: + Descripciones........");
  52. }else{
  53. printer.printCharAtCol(25, 1, 80, "=");
  54. printer.printTextWrap(26, 26, 1, 80, "TOTAL A PAGAR " + txtVentaTotal.getText());
  55. printer.printCharAtCol(27, 1, 80, "=");
  56. printer.printTextWrap(27, 28, 1, 80, "Esta boleta no tiene valor fiscal, solo para uso interno.: + Descripciones........");
  57.  
  58. }
  59. printer.toFile("impresion.txt");
  60.  
  61. FileInputStream inputStream = null;
  62. try {
  63. inputStream = new FileInputStream("impresion.txt");
  64. } catch (FileNotFoundException ex) {
  65. ex.printStackTrace();
  66. }
  67. if (inputStream == null) {
  68. return;
  69. }
  70.  
  71. DocFlavor docFormat = DocFlavor.INPUT_STREAM.AUTOSENSE;
  72. Doc document = new SimpleDoc(inputStream, docFormat, null);
  73.  
  74. PrintRequestAttributeSet attributeSet = new HashPrintRequestAttributeSet();
  75.  
  76. PrintService defaultPrintService = PrintServiceLookup.lookupDefaultPrintService();
  77.  
  78.  
  79. if (defaultPrintService != null) {
  80. DocPrintJob printJob = defaultPrintService.createPrintJob();
  81. try {
  82. printJob.print(document, attributeSet);
  83.  
  84. } catch (Exception ex) {
  85. ex.printStackTrace();
  86. }
  87. } else {
  88. System.err.println("No existen impresoras instaladas");
  89. }
  90.  
  91. //inputStream.close();
  92.  
  93. }
  94.  
  95. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:47: error: not a statement
        for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
                               ^
Main.java:47: error: ')' expected
        for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
                                    ^
Main.java:47: error: ';' expected
        for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
                                         ^
Main.java:47: error: ')' expected
        for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
                                                                                                                                                                                                                                                                                                                 ^
Main.java:47: error: not a statement
        for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
                                                                                                                                                                                                                                                                                                                   ^
Main.java:47: error: ';' expected
        for (int i = 0; i < filas; i++) { printer.printTextWrap(9 + i, 10, 1, 80, tblVentas.getValueAt(i,0).toString()+"|"+tblVentas.getValueAt(i,1).toString()+"| "+tblVentas.getValueAt(i,2).toString()+"| "+tblVentas.getValueAt(i,3).toString()+"|"+ tblVentas.getValueAt(i,4).toString()); } if(filas > 15){
                                                                                                                                                                                                                                                                                                                     ^
Main.java:52: error: 'else' without 'if'
        }else{
         ^
7 errors
stdout
Standard output is empty