List of usage examples for com.lowagie.text Document close
boolean close
To view the source code for com.lowagie.text Document close.
Click Source Link
From source file:jm.Reporte.java
License:GNU General Public License
public void lista(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, int lim) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {/*from w w w . ja va 2s. co m*/ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int alineacion = Element.ALIGN_LEFT; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 1; i <= lim; i++) { //alineacion = (i==lim) ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT; tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, alineacion, 1)); } num++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void lista(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, char sumDesde) { int sumarDesde = Integer.parseInt("" + sumDesde); int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[num_sumas]; float valor = 0; int pos = 0;//from w w w . ja va 2s . c o m /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); pos = 0; for (int i = 1; i <= numCols; i++) { if (i < sumarDesde) { tbl_det.addCell(Addons.setCeldaPDF( ((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } else { valor = (registros.getString(i) != null) ? registros.getFloat(i) : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[pos] = Float.parseFloat(this.formatoNumero.format(sumas[pos])) + valor; pos++; } } num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, sumarDesde)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void sumLista(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {/*from ww w . ja v a 2 s. c o m*/ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; //int num2 = 1; float suma_total = 0; float consumo = 0; int alineacion = Element.ALIGN_LEFT; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); //tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 1; i <= numCols; i++) { alineacion = (i == numCols) ? Element.ALIGN_RIGHT : Element.ALIGN_LEFT; tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, alineacion, 1)); } consumo = (registros.getString(numCols) != null) ? registros.getFloat(numCols) : 0; suma_total = Float.parseFloat(this.formatoNumero.format(suma_total)) + consumo; num++; //num2++; } tbl_det.addCell(Addons.setCeldaPDF("TOTAL: " + Addons.truncar(suma_total), Font.TIMES_ROMAN, 10, Font.NORMAL, Element.ALIGN_RIGHT, 0, 5, numCols + 2)); registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void listaAgrupada(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros) {// w w w.ja v a 2s .c om /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int num2 = 1; String aux = ""; String columna1 = ""; try { while (registros.next()) { columna1 = (registros.getString(1) != null) ? registros.getString(1) : ""; if (aux.compareTo(columna1) != 0) { tbl_det.addCell(Addons.setCeldaPDF(columna1, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 3, numCols + 1)); aux = columna1; num2 = 1; } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= numCols; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } num++; num2++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void activosCustorios(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from w w w.j a va 2 s .c om PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int num2 = 1; String aux = ""; String columna1 = ""; String persona_recibe = ""; String fecha = ""; String id_activo = ""; try { while (registros.next()) { columna1 = (registros.getString(1) != null) ? registros.getString(1) : ""; if (aux.compareTo(columna1) != 0) { tbl_det.addCell(Addons.setCeldaPDF(columna1, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 3, numCols + 2)); aux = columna1; num2 = 1; } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i < numCols; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } id_activo = (registros.getString("id_activo") != null) ? registros.getString("id_activo") : ""; try { ResultSet rsCustodio = objDB.consulta( "select persona_recibe, toDateSQL(max(fecha)) as fecha from tbl_activo_custodio as AC inner join tbl_activo_personalizacion as AP " + "on AC.id_activo_personalizacion=AP.id_activo_personalizacion where AC.eliminado=false and AC.id_activo=" + id_activo + " group by persona_recibe,AP.id_activo_personalizacion order by AP.id_activo_personalizacion desc"); if (rsCustodio.next()) { persona_recibe = (rsCustodio.getString("persona_recibe") != null) ? rsCustodio.getString("persona_recibe") : ""; fecha = (rsCustodio.getString("fecha") != null) ? rsCustodio.getString("fecha") : ""; rsCustodio.close(); } } catch (Exception ex) { ex.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(persona_recibe, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); tbl_det.addCell( Addons.setCeldaPDF(fecha, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); num++; num2++; } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void ventas(HttpServletResponse response, ResultSet registros, DataBase objDB, String iva_vigente) { String[] cabTabla = new String[] { "Nro.", "RUC", "RAZON SOCIAL", "Nro. FAC.", "F. EMI.", "F. PAGO", "IP", "SUBTOTAL", "DESC.", "SUB. 0", "IVA " + iva_vigente, "TOTAL", "DEUDA", "RETENCION" }; float[] anchoTabla = new float[] { 20f, 55f, 90f, 60f, 45f, 40f, 60f, 35f, 30f, 35f, 35f, 35f, 35f, 35f }; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {//from www .j a va 2 s .co m PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); ResultSetMetaData mdata = registros.getMetaData(); int numCols = mdata.getColumnCount(); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; int num2 = 1; String aux = ""; String id_factura_venta = "-1"; String columna2 = ""; float suma_parcial[] = { 0, 0, 0, 0, 0, 0, 0 }; float suma_total[] = { 0, 0, 0, 0, 0, 0, 0 }; float valor[] = { 0, 0, 0, 0, 0, 0, 0 }; int pos = 0; ResultSet retencion = null; try { while (registros.next()) { id_factura_venta = (registros.getString("id_factura_venta") != null) ? registros.getString("id_factura_venta") : "-1"; columna2 = (registros.getString(2) != null) ? registros.getString(2) : ""; pos = 0; if (aux.compareTo(columna2) != 0) { if (num > 1) { tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 7)); for (int j = 0; j < suma_parcial.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(suma_parcial[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); suma_parcial[j] = 0; } } tbl_det.addCell(Addons.setCeldaPDF(columna2, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1, 3, numCols + 1)); aux = columna2; num2 = 1; } //tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num2), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); String ax_anulada = ""; for (int i = 3; i <= numCols; i++) { if (i <= 8) { tbl_det.addCell(Addons.setCeldaPDF( ((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } else { ax_anulada = (registros.getString("anulada") != null) ? registros.getString("anulada") : ""; valor[pos] = (registros.getString(i) != null) ? registros.getFloat(i) : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor[pos]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); if (ax_anulada.compareTo("ANULADA") != 0) { suma_parcial[pos] = Float.parseFloat(this.formatoNumero.format(suma_parcial[pos])) + valor[pos]; suma_total[pos] = Float.parseFloat(this.formatoNumero.format(suma_total[pos])) + valor[pos]; } pos++; } } valor[6] = 0; try { retencion = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_venta where anulado=false and id_factura_venta=" + id_factura_venta + ";"); if (retencion.next()) { valor[6] = (retencion.getString("ret_impuesto_retenido") != null) ? retencion.getFloat("ret_impuesto_retenido") : 0; retencion.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor[6]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); suma_parcial[6] = Float.parseFloat(this.formatoNumero.format(suma_parcial[6])) + valor[6]; suma_total[6] = Float.parseFloat(this.formatoNumero.format(suma_total[6])) + valor[6]; num++; num2++; } tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 7)); for (int j = 0; j < suma_parcial.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(suma_parcial[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 9, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 7)); for (int j = 0; j < suma_total.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(suma_total[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void compras(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) {/* w w w . ja va 2s. co m*/ //int sumarDesde = 6; //int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[6]; float valor = 0; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; String id_factura_compra = ""; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= 6; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } valor = (registros.getString("subtotal") != null) ? registros.getFloat("subtotal") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[0] = Float.parseFloat(this.formatoNumero.format(sumas[0])) + valor; valor = (registros.getString("descuento") != null) ? registros.getFloat("descuento") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[1] = Float.parseFloat(this.formatoNumero.format(sumas[1])) + valor; valor = (registros.getString("subtotal_0") != null) ? registros.getFloat("subtotal_0") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[2] = Float.parseFloat(this.formatoNumero.format(sumas[2])) + valor; valor = (registros.getString("iva_2") != null) ? registros.getFloat("iva_2") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[3] = Float.parseFloat(this.formatoNumero.format(sumas[3])) + valor; id_factura_compra = (registros.getString("id_factura_compra") != null) ? registros.getString("id_factura_compra") : ""; valor = 0; try { ResultSet rs = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_compra where id_factura_compra=" + id_factura_compra + " and documento='f'"); if (rs.next()) { valor = (rs.getString("ret_impuesto_retenido") != null) ? rs.getFloat("ret_impuesto_retenido") : 0; rs.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[4] = Float.parseFloat(this.formatoNumero.format(sumas[4])) + valor; valor = (registros.getString("total_compra") != null) ? registros.getFloat("total_compra") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[5] = Float.parseFloat(this.formatoNumero.format(sumas[5])) + valor; num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 6)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void liquidaciones(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) { //int sumarDesde = 6; //int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[5]; float valor = 0; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {/*from www .j a v a 2 s . com*/ PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; String id_liquidacion_compra = ""; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= 6; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } valor = (registros.getString("subtotal") != null) ? registros.getFloat("subtotal") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[0] = Float.parseFloat(this.formatoNumero.format(sumas[0])) + valor; valor = (registros.getString("subtotal_0") != null) ? registros.getFloat("subtotal_0") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[1] = Float.parseFloat(this.formatoNumero.format(sumas[1])) + valor; valor = (registros.getString("iva_2") != null) ? registros.getFloat("iva_2") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[2] = Float.parseFloat(this.formatoNumero.format(sumas[2])) + valor; id_liquidacion_compra = (registros.getString("id_liquidacion_compra") != null) ? registros.getString("id_liquidacion_compra") : ""; valor = 0; try { ResultSet rs = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_compra where id_factura_compra=" + id_liquidacion_compra + " and documento='l'"); if (rs.next()) { valor = (rs.getString("ret_impuesto_retenido") != null) ? rs.getFloat("ret_impuesto_retenido") : 0; rs.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[3] = Float.parseFloat(this.formatoNumero.format(sumas[3])) + valor; valor = (registros.getString("total_compra") != null) ? registros.getFloat("total_compra") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[4] = Float.parseFloat(this.formatoNumero.format(sumas[4])) + valor; num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 6)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void notasVenta(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros, DataBase objDB) {//w w w . j a va2s. co m //int sumarDesde = 6; //int num_sumas = cabTabla.length - sumarDesde; float sumas[] = new float[2]; float valor = 0; /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try { PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla)); PdfPTable tbl_det = new PdfPTable(anchoTabla); int num = 1; String id_nota_venta_compra = ""; try { while (registros.next()) { tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 1)); for (int i = 2; i <= 6; i++) { tbl_det.addCell( Addons.setCeldaPDF(((registros.getString(i) != null) ? registros.getString(i) : ""), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1)); } id_nota_venta_compra = (registros.getString("id_nota_venta_compra") != null) ? registros.getString("id_nota_venta_compra") : ""; valor = 0; try { ResultSet rs = objDB.consulta( "select ret_impuesto_retenido from tbl_retencion_compra where id_factura_compra=" + id_nota_venta_compra + " and documento='v'"); if (rs.next()) { valor = (rs.getString("ret_impuesto_retenido") != null) ? rs.getFloat("ret_impuesto_retenido") : 0; rs.close(); } } catch (Exception e) { e.printStackTrace(); } tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[0] = Float.parseFloat(this.formatoNumero.format(sumas[0])) + valor; valor = (registros.getString("total_compra") != null) ? registros.getFloat("total_compra") : 0; tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(valor), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1)); sumas[1] = Float.parseFloat(this.formatoNumero.format(sumas[1])) + valor; num++; } tbl_det.addCell(Addons.setCeldaPDF("TOTALES: ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, 6)); for (int j = 0; j < sumas.length; j++) { tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumas[j]), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); } registros.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }
From source file:jm.Reporte.java
License:GNU General Public License
public void cierreCaja(HttpServletResponse response, int id_sucursal_sesion, String fecha, DataBase objDB) { /* inicio PDF */ Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate(); Document document = new Document(orientacion);// paso 1 document.setMargins(0, 0, 50, 80); /*Izquierda, derecha, tope, pie */ try {// w ww . j a v a 2 s . c o m PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2 writer.setPageEvent(new Reporte(this.vertical, this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal, this.rep_pie)); document.open(); // paso 3 /* todo el cuerpo del doc es el paso 4 */ document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion, this.sucursal)); ResultSet ventas = objDB.consulta( "select vendedor,txt_forma_pago,sum(total) as total from vta_factura_venta where id_sucursal=" + id_sucursal_sesion + " and anulado=false and fecha_emision='" + fecha + "' group by vendedor,txt_forma_pago order by vendedor"); ResultSet retencion = null; PdfPTable tbl_det = new PdfPTable(new float[] { 70f, 40f, 120f }); try { String aux = ""; float ingresos = 0; float total_ingresos = 0; float efectivo = 0; float total_efectivo = 0; float ret = 0; float total_ret = 0; String vendedor = ""; String forma_pago = ""; float total = 0; tbl_det.addCell(Addons.setCeldaPDF("VENTAS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); while (ventas.next()) { vendedor = ventas.getString("vendedor") != null ? ventas.getString("vendedor") : ""; forma_pago = ventas.getString("txt_forma_pago") != null ? ventas.getString("txt_forma_pago") : ""; total = ventas.getString("total") != null ? ventas.getFloat("total") : 0; if (aux.compareTo(vendedor) != 0) { if (aux.compareTo("") != 0) { tbl_det.addCell(Addons.setCeldaPDF(" TOTAL ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" EN CAJA ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(efectivo - ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF( "___________________________________________________________________________________________________________", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0, 0, 3)); } tbl_det.addCell(Addons.setCeldaPDF(vendedor, Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 4, 3)); /* retenciones */ try { retencion = objDB.consulta( "select sum(R.ret_impuesto_retenido) as total from tbl_factura_venta as F inner join tbl_retencion_venta as R " + "on R.id_factura_venta=F.id_factura_venta where id_sucursal=" + id_sucursal_sesion + " and F.anulado=false and R.anulado=false and F.vendedor='" + vendedor + "' and ret_fecha_emision='" + fecha + "'"); if (retencion.next()) { ret = retencion.getString("total") != null ? retencion.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF(" RETENCIONES ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); ingresos += ret; total_ret += ret; } } catch (Exception ex) { } aux = vendedor; ingresos = 0; efectivo = 0; } ingresos += total; total_ingresos += total; if (forma_pago.compareTo("EFECTIVO") == 0) { efectivo += total; total_efectivo += total; //total_caja += total; } tbl_det.addCell(Addons.setCeldaPDF(" " + forma_pago, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); } tbl_det.addCell(Addons.setCeldaPDF(" TOTAL ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" EN CAJA ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(efectivo - ret), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setFilaBlanco(3, 10)); /* gastos */ tbl_det.addCell(Addons.setCeldaPDF("PAGOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); String tipo_pago = ""; float total_efectivo_pago = 0; float total_egreso = 0; try { ResultSet pagos = objDB.consulta( "select txt_tipo_pago,sum(abono) as total from vta_factura_compra_pago as f inner join tbl_comprobante_egreso as C on F.id_comprobante_egreso=C.id_comprobante_egreso where C.id_sucursal=" + id_sucursal_sesion + " and fecha_pago='" + fecha + "' group by txt_tipo_pago"); while (pagos.next()) { tipo_pago = pagos.getString("txt_tipo_pago") != null ? pagos.getString("txt_tipo_pago") : ""; float pago = pagos.getString("total") != null ? pagos.getFloat("total") : 0; tbl_det.addCell(Addons.setCeldaPDF(" " + tipo_pago, Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(pago), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell( Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); total_egreso += pago; if (tipo_pago.compareTo("EFECTIVO") == 0) { total_efectivo_pago += pago; //total_caja -= total; } } pagos.close(); } catch (Exception e) { } tbl_det.addCell(Addons.setFilaBlanco(3, 10)); tbl_det.addCell(Addons.setCeldaPDF("TOTALES", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL VENTAS ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_ingresos), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL PAGOS ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_egreso), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" TOTAL EN CAJA ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_efectivo - total_ret - total_efectivo_pago), Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 0)); tbl_det.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0)); ventas.close(); retencion.close(); } catch (Exception e) { e.printStackTrace(); } document.add(tbl_det); } catch (IllegalStateException ie) { ie.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } document.close(); // paso 5 /* fin PDF */ }