Example usage for com.lowagie.text Document close

List of usage examples for com.lowagie.text Document close

Introduction

In this page you can find the example usage for com.lowagie.text Document close.

Prototype

boolean close

To view the source code for com.lowagie.text Document close.

Click Source Link

Document

Has the document already been closed?

Usage

From source file:jm.Reporte.java

License:GNU General Public License

public void ingresosPeriodos(HttpServletResponse response, ResultSet emisiones, ResultSet recaudos,
        ResultSet xcobrar, ResultSet instalaciones, ResultSet otros) {
    /* 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  ww. j a  v a 2s.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 */

        float[] anchoTabla = new float[] { 25f, 15f, 15f, 15f, 15f, 15f, 20f };

        document.add(Addons.setCabecera(this.logo, this.titulo, this.ruc, this.subtitulo, this.direccion,
                this.sucursal));

        /*PdfPTable tbl_tit = new PdfPTable(1);
        tbl_tit.addCell(Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0));
        tbl_tit.addCell(Addons.setCeldaPDF("SERVIVIO DE INTERNET", Font.TIMES_ROMAN, 10, Font.NORMAL, Element.ALIGN_LEFT, 0));
        document.add(tbl_tit);*/

        document.add(Addons.setCabeceraTabla(new String[] { "PERIODO", "INSTALACIONES", "OTROS INGRESOS",
                "PRE-FACTURADO", "EMITIDO", "POR COBRAR", "SUMATORIA" }, anchoTabla));

        String[][] mat_emisiones = DatosDinamicos.ResultSetToMatriz(emisiones);
        String[][] mat_recaudos = DatosDinamicos.ResultSetToMatriz(recaudos);
        String[][] mat_xcobrar = DatosDinamicos.ResultSetToMatriz(xcobrar);
        String[][] mat_instalaciones = DatosDinamicos.ResultSetToMatriz(instalaciones);
        String[][] mat_otros = DatosDinamicos.ResultSetToMatriz(otros);

        PdfPTable tbl_det = new PdfPTable(anchoTabla);
        int pos = -1;
        float suma = 0;
        String matriz = "";
        for (int i = 0; i < mat_emisiones.length; i++) {
            if (matriz.compareTo(mat_emisiones[i][0]) != 0) {
                tbl_det.addCell(Addons.setCeldaPDF(mat_emisiones[i][0], Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_CENTER, 1, 4, 7));
                matriz = mat_emisiones[i][0];
            }

            tbl_det.addCell(Addons.setCeldaPDF(mat_emisiones[i][1], Font.TIMES_ROMAN, 8, Font.NORMAL,
                    Element.ALIGN_LEFT, 1));

            pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_instalaciones, mat_emisiones[i][1], 1,
                    mat_emisiones[i][0]);
            suma = Float.valueOf(pos != -1 ? mat_instalaciones[pos][2] : "0");
            tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_instalaciones[pos][2] : "0", Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_RIGHT, 1));

            pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_otros, mat_emisiones[i][1], 1,
                    mat_emisiones[i][0]);
            suma += Float.valueOf(pos != -1 ? mat_otros[pos][2] : "0");
            tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_otros[pos][2] : "0", Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_RIGHT, 1));

            tbl_det.addCell(Addons.setCeldaPDF(mat_emisiones[i][2], Font.TIMES_ROMAN, 8, Font.NORMAL,
                    Element.ALIGN_RIGHT, 1));

            pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_recaudos, mat_emisiones[i][1], 1,
                    mat_emisiones[i][0]);
            suma += Float.valueOf(pos != -1 ? mat_recaudos[pos][2] : "0");
            tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_recaudos[pos][2] : "0", Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_RIGHT, 1));

            pos = DatosDinamicos.enMatrizSecuencialSucursal(mat_xcobrar, mat_emisiones[i][1], 1,
                    mat_emisiones[i][0]);
            tbl_det.addCell(Addons.setCeldaPDF(pos != -1 ? mat_xcobrar[pos][2] : "0", Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_RIGHT, 1));

            tbl_det.addCell(Addons.setCeldaPDF(Addons.redondear(String.valueOf(suma)), Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_RIGHT, 1));
        }
        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 ingresosEgresos(HttpServletResponse response, int id_sucursal, String fecha, DataBase objDB,
        String banco, String caja) {
    /* 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 {// ww  w .  j av 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 CASE tipo_cobro WHEN 'e' THEN 'EFECTIVO' WHEN 'c' THEN 'CHEQUE' ELSE '' END AS txt_tipo_cobro,"
                        + "sum(total) as total from vta_comprobante_ingreso where id_sucursal=" + id_sucursal
                        + " and anulado=false and fecha_actual='" + fecha + "' group by txt_tipo_cobro");
        ResultSet retencion = null;

        PdfPTable tbl_det = new PdfPTable(new float[] { 130f, 40f, 60f });

        try {
            float total_ingresos = 0;
            float total_efectivo = 0;
            float ret = 0;
            float total_ret = 0;
            String forma_pago = "";
            float total = 0;
            tbl_det.addCell(Addons.setCeldaPDF("INGRESOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT,
                    0, Color.cyan, 3, 3));
            while (ventas.next()) {
                forma_pago = ventas.getString("txt_tipo_cobro") != null ? ventas.getString("txt_tipo_cobro")
                        : "";
                total = ventas.getString("total") != null ? ventas.getFloat("total") : 0;

                total_ingresos += total;
                if (forma_pago.compareTo("EFECTIVO") == 0) {
                    total_efectivo += 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));
            }

            /* 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
                                + " and F.anulado=false and R.anulado=false 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));
                    total_ret += ret;
                }
            } catch (Exception ex) {
            }

            /*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.setFilaBlanco(3, 10));

            /* gastos */
            tbl_det.addCell(Addons.setCeldaPDF("EGRESOS", 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 CASE tipo_pago WHEN 'e' THEN 'EFECTIVO' WHEN 'c' THEN 'CHEQUE' ELSE '' END AS txt_tipo_pago,sum(total) as total "
                                + "from tbl_comprobante_egreso where id_sucursal=" + id_sucursal
                                + " and anulado=false and fecha_actual='" + 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;
                    }
                }
                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 INGRESOS ", 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 EGRESOS ", 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("   INGRESOS - EGRESOS - RETENCIONES ", Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_LEFT, 0));
            tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_ingresos - total_egreso - total_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("   INGRESOS (EFECTIVO) - EGRESOS (EFECTIVO) - RETENCIONES ",
                    Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0));
            tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(total_efectivo - total_efectivo_pago - total_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));

            ventas.close();
            retencion.close();

            /* transferencias al banco */
            try {
                tbl_det.addCell(Addons.setFilaBlanco(3, 10));
                tbl_det.addCell(Addons.setCeldaPDF("COMPROBANTES DE DIARIO CON BANCOS", Font.TIMES_ROMAN, 8,
                        Font.BOLD, Element.ALIGN_LEFT, 0, Color.cyan, 3, 3));

                ResultSet diarios = objDB.consulta(
                        "select distinct C.detalle, C.total from tbl_comprobante_diario as C inner join tbl_comprobante_diario_detalle as D "
                                + "on C.id_comprobante_diario=D.id_comprobante_diario where C.id_sucursal="
                                + id_sucursal + " and C.anulado=false and fecha_actual='" + fecha + "' "
                                + "and D.id_plan_cuenta in (" + banco + "," + caja + ")");
                while (diarios.next()) {
                    ret = diarios.getString("total") != null ? diarios.getFloat("total") : 0;
                    tbl_det.addCell(Addons.setCeldaPDF(
                            (diarios.getString("detalle") != null ? diarios.getString("detalle") : ""),
                            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));
                }
                diarios.close();
            } catch (Exception ex) {
            }

        } 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 tabular(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 {/* w ww.ja  va2 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 columna1 = "";
        float suma_parcial = 0;
        float suma_total = 0;
        float consumo = 0;
        int alineacion = Element.ALIGN_LEFT;
        try {
            while (registros.next()) {
                columna1 = (registros.getString(1) != null) ? registros.getString(1) : "";
                if (aux.compareTo(columna1) != 0) {
                    if (num > 1) {
                        tbl_det.addCell(Addons.setCeldaPDF("SUBTOTAL:  " + Addons.truncar(suma_parcial),
                                Font.TIMES_ROMAN, 9, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, numCols + 2));
                    }
                    tbl_det.addCell(Addons.setCeldaPDF(columna1, Font.TIMES_ROMAN, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1, 3, numCols + 1));
                    aux = columna1;
                    suma_parcial = 0;
                    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++) {
                    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_parcial = Float.parseFloat(this.formatoNumero.format(suma_parcial)) + consumo;
                suma_total = Float.parseFloat(this.formatoNumero.format(suma_total)) + consumo;
                num++;
                num2++;
            }
            tbl_det.addCell(Addons.setCeldaPDF("SUBTOTAL:  " + Addons.truncar(suma_parcial), Font.TIMES_ROMAN,
                    9, Font.NORMAL, Element.ALIGN_RIGHT, 0, 4, numCols + 2));
            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 tabular(HttpServletResponse response, String[] cabTabla, float[] anchoTabla, ResultSet registros,
        int sumarDesde) {
    /* 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 .  java 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));

        ResultSetMetaData mdata = registros.getMetaData();
        int numCols = mdata.getColumnCount();
        PdfPTable tbl_det = new PdfPTable(anchoTabla);
        int num = 1;
        int num2 = 1;
        String aux = "";
        String columna1 = "";
        int num_sumas = cabTabla.length - sumarDesde;
        float suma_parcial[] = new float[num_sumas];
        float suma_total[] = new float[num_sumas];
        float valor[] = new float[num_sumas];
        int pos = 0;
        try {
            while (registros.next()) {
                columna1 = (registros.getString(1) != null) ? registros.getString(1) : "";
                pos = 0;
                if (aux.compareTo(columna1) != 0) {
                    if (num > 1) {
                        tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES:  ", Font.TIMES_ROMAN, 8, Font.NORMAL,
                                Element.ALIGN_RIGHT, 0, 4, sumarDesde));
                        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(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++) {
                    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[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));
                        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++;
                    }
                }
                num++;
                num2++;
            }
            tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES:  ", Font.TIMES_ROMAN, 8, Font.NORMAL,
                    Element.ALIGN_RIGHT, 0, 4, sumarDesde));
            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, 8, Font.NORMAL,
                    Element.ALIGN_RIGHT, 0, 4, sumarDesde));
            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 tabulares(HttpServletResponse response, String[] cabTabla, float[] anchoTabla,
        ResultSet registros) {//from w  ww  .j a v a 2 s  .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 = "";
        float suma_parcial[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        float suma_total[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        float valor[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        int pos = 0;
        try {
            while (registros.next()) {
                columna1 = (registros.getString(1) != null) ? registros.getString(1) : "";
                pos = 0;
                if (aux.compareTo(columna1) != 0) {
                    if (num > 1) {
                        tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES:  ", Font.TIMES_ROMAN, 9, Font.NORMAL,
                                Element.ALIGN_RIGHT, 0, 4, 5));
                        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(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++) {
                    if (i < 5) {
                        tbl_det.addCell(Addons.setCeldaPDF(
                                ((registros.getString(i) != null) ? registros.getString(i) : ""),
                                Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                    } else {
                        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));
                        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++;
                    }
                }

                num++;
                num2++;
            }
            tbl_det.addCell(Addons.setCeldaPDF("SUBTOTALES:  ", Font.TIMES_ROMAN, 9, Font.NORMAL,
                    Element.ALIGN_RIGHT, 0, 4, 5));
            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, 10, Font.NORMAL,
                    Element.ALIGN_RIGHT, 0, 5, 5));
            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 balanceComprobacion(HttpServletResponse response, String[] cabTabla, float[] anchoTabla,
        ResultSet registros) {//ww  w. j ava  2 s.  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, 60); /*Izquierda, derecha, tope, pie */
    try {
        double sum[] = new double[4];

        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.setCabeceraTablaBalance(cabTabla, anchoTabla));

        PdfPTable tbl_det = new PdfPTable(anchoTabla);
        int num = 1;
        String valor = "";
        int tipo_cuenta = 0;
        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(
                        ((registros.getString("codigo_cuenta") != null) ? registros.getString("codigo_cuenta")
                                : ""),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_det.addCell(Addons.setCeldaPDF(
                        ((registros.getString("nombre_cuenta") != null) ? registros.getString("nombre_cuenta")
                                : ""),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                valor = (registros.getString("sum_debe") != null) ? registros.getString("sum_debe") : "0.00";
                sum[0] += Double.valueOf(valor);
                tbl_det.addCell(Addons.setCeldaPDF(((Double.valueOf(valor) > 0) ? valor : ""), Font.TIMES_ROMAN,
                        8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                valor = (registros.getString("sum_haber") != null) ? registros.getString("sum_haber") : "0.00";
                sum[1] += Double.valueOf(valor);
                tbl_det.addCell(Addons.setCeldaPDF(((Double.valueOf(valor) > 0) ? valor : ""), Font.TIMES_ROMAN,
                        8, Font.NORMAL, Element.ALIGN_RIGHT, 1));

                tipo_cuenta = (registros.getString("tipo_cuenta") != null) ? registros.getInt("tipo_cuenta")
                        : 0;

                valor = (registros.getString("saldo_deudor") != null) ? registros.getString("saldo_deudor")
                        : "0.00";
                sum[2] += Double.valueOf(valor);
                tbl_det.addCell(Addons.setCeldaPDF(((tipo_cuenta == 0) ? valor : ""), Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_RIGHT, 1));
                valor = (registros.getString("saldo_aceedor") != null) ? registros.getString("saldo_aceedor")
                        : "0.00";
                sum[3] += Double.valueOf(valor);
                tbl_det.addCell(Addons.setCeldaPDF(((tipo_cuenta == 1) ? valor : ""), Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_RIGHT, 1));

                num++;
            }
            registros.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        tbl_det.addCell(
                Addons.setCeldaPDF("TOTALES", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1, 3, 3));
        for (int i = 0; i < sum.length; i++) {
            tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(Addons.redondear(sum[i])), Font.TIMES_ROMAN, 8,
                    Font.NORMAL, Element.ALIGN_RIGHT, 1));
        }
        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 balanceGeneral(HttpServletResponse response, ResultSet registros) {
    String datos[][] = Addons.calcularTotalesBalance(registros, 0, 0);
    Addons.ordenamientoQuicksort(datos, 0, datos.length - 1, 2);

    /* inicio PDF */
    Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate();
    Document document = new Document(orientacion);// paso 1
    document.setMargins(0, 0, 50, 60); /*Izquierda, derecha, tope, pie */
    try {/*from  w  ww .  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));

        int columnas = Addons.maxNivelCodigos(datos) + 2;
        float anchosCols[] = new float[columnas];
        anchosCols[0] = 80f;
        anchosCols[1] = 200f;
        for (int i = 2; i < columnas; i++) {
            anchosCols[i] = 65f;
        }

        PdfPTable tbl_det = new PdfPTable(anchosCols);

        int numCols = 0;
        int nivel = 0;
        int k = 2;
        double sumPasPat = 0;
        double valor = 0;
        try {
            for (int i = 1; i < datos.length; i++) {
                valor = Addons.redondear(Double.valueOf(datos[i][4]));
                if (valor != 0) {
                    nivel = Integer.parseInt(datos[i][5]);
                    int fuente = Font.NORMAL;
                    if (nivel == 1) {
                        fuente = Font.BOLD;
                        if (datos[i][3].toUpperCase().indexOf("PASIVO") >= 0
                                || datos[i][3].toUpperCase().indexOf("PATRIMONIO") >= 0) {
                            sumPasPat += Double.valueOf(datos[i][4]);
                        }
                    }
                    tbl_det.addCell(Addons.setCeldaPDF(datos[i][2], Font.TIMES_ROMAN, 8, fuente,
                            Element.ALIGN_LEFT, 1));
                    tbl_det.addCell(Addons.setCeldaPDF(datos[i][3], Font.TIMES_ROMAN, 8, fuente,
                            Element.ALIGN_LEFT, 1));
                    k = 2;
                    numCols = columnas - 2 - nivel;
                    for (int j = 0; j < numCols; j++) {
                        tbl_det.addCell(
                                Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, fuente, Element.ALIGN_LEFT, 1));
                        k++;
                    }
                    tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(Addons.redondear(valor)),
                            Font.TIMES_ROMAN, 8, fuente, Element.ALIGN_RIGHT, 1));
                    k++;
                    for (int j = k; j < columnas; j++) {
                        tbl_det.addCell(
                                Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, fuente, Element.ALIGN_LEFT, 1));
                    }
                }
            }
            registros.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        tbl_det.addCell(Addons.setCeldaPDF("TOTAL PASIVOS M?S PATRIMONIO ", Font.TIMES_ROMAN, 8, Font.BOLD,
                Element.ALIGN_LEFT, 1, 3, columnas - 1));
        tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(sumPasPat), Font.TIMES_ROMAN, 8, Font.BOLD,
                Element.ALIGN_RIGHT, 1));
        document.add(tbl_det);

        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));

        PdfPTable tbl_firmas = new PdfPTable(2);
        tbl_firmas.addCell(
                Addons.setCeldaPDF("GERENTE", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 0));
        tbl_firmas.addCell(
                Addons.setCeldaPDF("CONTADOR", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 0));
        document.add(tbl_firmas);

    } 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 balanceResultados(HttpServletResponse response, ResultSet registros) {
    String datos[][] = Addons.calcularTotalesBalance(registros, 0, 0);
    Addons.ordenamientoQuicksort(datos, 0, datos.length - 1, 2);

    /* inicio PDF */
    Rectangle orientacion = (this.vertical) ? PageSize.A4 : PageSize.A4.rotate();
    Document document = new Document(orientacion);// paso 1
    document.setMargins(0, 0, 50, 60); /*Izquierda, derecha, tope, pie */
    try {/* ww w.ja v a  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));

        int columnas = Addons.maxNivelCodigos(datos) + 2;
        float anchosCols[] = new float[columnas];
        anchosCols[0] = 80f;
        anchosCols[1] = 200f;
        for (int i = 2; i < columnas; i++) {
            anchosCols[i] = 65f;
        }

        PdfPTable tbl_det = new PdfPTable(anchosCols);

        int numCols = 0;
        int nivel = 0;
        int k = 2;
        double total_ingresos = 0;
        double total_gastos = 0;
        double valor = 0;

        try {
            for (int i = 1; i < datos.length; i++) {
                valor = Addons.redondear(Double.valueOf(datos[i][4]));
                if (valor != 0) {
                    nivel = Integer.parseInt(datos[i][5]);
                    int fuente = Font.NORMAL;
                    if (nivel == 1) {
                        fuente = Font.BOLD;
                        if (datos[i][3].toUpperCase().indexOf("INGRESO") >= 0) {
                            total_ingresos = Double.valueOf(datos[i][4]);
                        }
                        if (datos[i][3].toUpperCase().indexOf("GASTO") >= 0
                                || datos[i][3].toUpperCase().indexOf("EGRESO") >= 0) {
                            total_gastos = Double.valueOf(datos[i][4]);
                        }
                    }
                    tbl_det.addCell(Addons.setCeldaPDF(datos[i][2], Font.TIMES_ROMAN, 8, fuente,
                            Element.ALIGN_LEFT, 1));
                    tbl_det.addCell(Addons.setCeldaPDF(datos[i][3], Font.TIMES_ROMAN, 8, fuente,
                            Element.ALIGN_LEFT, 1));
                    k = 2;
                    numCols = columnas - 2 - nivel;
                    for (int j = 0; j < numCols; j++) {
                        tbl_det.addCell(
                                Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, fuente, Element.ALIGN_LEFT, 1));
                        k++;
                    }
                    tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(valor), Font.TIMES_ROMAN, 8, fuente,
                            Element.ALIGN_RIGHT, 1));
                    k++;
                    for (int j = k; j < columnas; j++) {
                        tbl_det.addCell(
                                Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, fuente, Element.ALIGN_LEFT, 1));
                    }
                }
            }
            registros.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        tbl_det.addCell(Addons.setCeldaPDF("RESULTADO DEL EJERCICIO ", Font.TIMES_ROMAN, 8, Font.BOLD,
                Element.ALIGN_LEFT, 1, 3, columnas - 1));
        tbl_det.addCell(Addons.setCeldaPDF(Addons.truncar(Addons.redondear(total_ingresos - total_gastos)),
                Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_RIGHT, 1));
        document.add(tbl_det);

        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));
        document.add(new Paragraph(" "));

        PdfPTable tbl_firmas = new PdfPTable(2);
        tbl_firmas.addCell(
                Addons.setCeldaPDF("GERENTE", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 0));
        tbl_firmas.addCell(
                Addons.setCeldaPDF("CONTADOR", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_CENTER, 0));
        document.add(tbl_firmas);

    } 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 importaciones(HttpServletResponse response, 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 {//  ww  w. 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));

        try {
            String[] cabTabla = new String[] { "#", "Nro. FACTURA", "RAZON SOCIAL", "F. EMISION", "SUBTOTAL",
                    "DESCUENTO", "IVA", "TOTAL" };
            float[] anchoTabla = new float[] { 15f, 80f, 160f, 60f, 70f, 70f, 70f, 70f };
            ResultSet facturas = null;
            String id_dau = "-1";
            int num = 1;
            while (registros.next()) {
                /* MAESTRO */
                PdfPTable tbl_maestro = new PdfPTable(new float[] { 35f, 140f, 50f, 140f });
                id_dau = (registros.getString("id_dau") != null) ? registros.getString("id_dau") : "-1";

                tbl_maestro.addCell(Addons.setCeldaPDF("ADUANA - CONTRIBUYENTE", Font.TIMES_ROMAN, 8, Font.BOLD,
                        Element.ALIGN_LEFT, 1, 3, 4));

                tbl_maestro.addCell(Addons.setCeldaPDF("Nmero: ", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_maestro.addCell(Addons.setCeldaPDF(
                        ((registros.getString("num_dau") != null) ? registros.getString("num_dau") : ""),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_maestro.addCell(Addons.setCeldaPDF("Fecha/Hora TX: ", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_maestro.addCell(Addons.setCeldaPDF(((registros.getString("fecha_tx_sql") != null)
                        ? registros.getString("fecha_tx_sql")
                        : "") + " - "
                        + ((registros.getString("hora_tx") != null) ? registros.getString("hora_tx") : ""),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));

                tbl_maestro.addCell(Addons.setCeldaPDF("Importador: ", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_maestro.addCell(Addons.setCeldaPDF(
                        ((registros.getString("importador") != null) ? registros.getString("importador") : ""),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_maestro.addCell(Addons.setCeldaPDF("Direccin: ", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_maestro.addCell(Addons.setCeldaPDF(
                        ((registros.getString("direccion") != null) ? registros.getString("direccion") : ""),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                document.add(tbl_maestro);

                PdfPTable tbl_valoresAduana = new PdfPTable(6);
                tbl_valoresAduana.addCell(Addons.setCeldaPDF("VALORES EN ADUANA", Font.TIMES_ROMAN, 8,
                        Font.BOLD, Element.ALIGN_LEFT, 1, 3, 6));

                tbl_valoresAduana.addCell(
                        Addons.setCeldaPDF("Fob USD", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF("Flete USD", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF("Seguro USD", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF("Ajuste USD", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(
                        Addons.setCeldaPDF("CIF USD", Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF("Valor Aduana USD", Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_LEFT, 1));

                tbl_valoresAduana.addCell(Addons.setCeldaPDF(
                        ((registros.getString("fob") != null) ? registros.getString("fob") : "0"),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF(
                        ((registros.getString("flete") != null) ? registros.getString("flete") : "0"),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF(
                        ((registros.getString("seguro") != null) ? registros.getString("seguro") : "0"),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF(
                        ((registros.getString("ajuste") != null) ? registros.getString("ajuste") : "0"),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF(
                        ((registros.getString("cif") != null) ? registros.getString("cif") : "0"),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_valoresAduana.addCell(Addons.setCeldaPDF(
                        ((registros.getString("valor_aduana") != null) ? registros.getString("valor_aduana")
                                : "0"),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                document.add(tbl_valoresAduana);

                PdfPTable tbl_autoliquidacion = new PdfPTable(2);
                float valor_em = (registros.getString("valor_em") != null) ? registros.getFloat("valor_em") : 0;
                float der_especifico = (registros.getString("der_especifico") != null)
                        ? registros.getFloat("der_especifico")
                        : 0;
                float ice = (registros.getString("ice") != null) ? registros.getFloat("ice") : 0;
                float iva = (registros.getString("iva") != null) ? registros.getFloat("iva") : 0;
                float antidumping = (registros.getString("antidumping") != null)
                        ? registros.getFloat("antidumping")
                        : 0;
                float der_consular = (registros.getString("der_consular") != null)
                        ? registros.getFloat("der_consular")
                        : 0;
                float sobretiempo_petr = (registros.getString("sobretiempo_petr") != null)
                        ? registros.getFloat("sobretiempo_petr")
                        : 0;
                float ad_barril_crudo = (registros.getString("ad_barril_crudo") != null)
                        ? registros.getFloat("ad_barril_crudo")
                        : 0;
                float tasa_modernizacion = (registros.getString("tasa_modernizacion") != null)
                        ? registros.getFloat("tasa_modernizacion")
                        : 0;
                float tasa_control = (registros.getString("tasa_control") != null)
                        ? registros.getFloat("tasa_control")
                        : 0;
                float tasa_almacenaje = (registros.getString("tasa_almacenaje") != null)
                        ? registros.getFloat("tasa_almacenaje")
                        : 0;
                float multa = (registros.getString("multa") != null) ? registros.getFloat("multa") : 0;
                float interes = (registros.getString("interes") != null) ? registros.getFloat("interes") : 0;
                float imp_salida_divisa = (registros.getString("imp_salida_divisa") != null)
                        ? registros.getFloat("imp_salida_divisa")
                        : 0;
                float fodinfa = (registros.getString("fodinfa") != null) ? registros.getFloat("fodinfa") : 0;
                float corpei = (registros.getString("corpei") != null) ? registros.getFloat("corpei") : 0;
                float otros = (registros.getString("otros") != null) ? registros.getFloat("otros") : 0;
                float salvaguarda = (registros.getString("salvaguarda") != null)
                        ? registros.getFloat("salvaguarda")
                        : 0;
                float total_autoliquidacion = (registros.getString("total_autoliquidacion") != null)
                        ? registros.getFloat("total_autoliquidacion")
                        : 0;

                tbl_autoliquidacion.addCell(Addons.setCeldaPDF("AUTOLIQUIDACION DE TRIBUTOS", Font.TIMES_ROMAN,
                        8, Font.BOLD, Element.ALIGN_LEFT, 1, 3, 2));

                tbl_autoliquidacion.addCell(Addons.setCeldaPDF("CONCEPTO", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_CENTER, 1));
                tbl_autoliquidacion.addCell(Addons.setCeldaPDF("CANTIDAD A PAGAR", Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_CENTER, 1));

                if (valor_em > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("AD / VALOREM", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(valor_em), Font.TIMES_ROMAN,
                            8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (der_especifico > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("DER. ESPECIFICO", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(der_especifico),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (ice > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("IMP. CONSUMO ESPECIAL", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(ice), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (iva > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("IMP. VALOR AGREGADO", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(iva), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (antidumping > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("DERECHO ANTIDUMPING", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(antidumping),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (der_consular > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("DERECHOS CONSULARES", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(der_consular),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (sobretiempo_petr > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("SOBRETIEMPO PETROLEO", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(sobretiempo_petr),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (ad_barril_crudo > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("ADICIONAL POR BARRIL DE CRUDO",
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(ad_barril_crudo),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (tasa_modernizacion > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("TASA MODERNIZACION", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(tasa_modernizacion),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (tasa_control > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("TASA DE CONTROL", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(tasa_control),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (tasa_almacenaje > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("TASA ALMACENAJE", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(tasa_almacenaje),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (multa > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("MULTAS (ART. 89 Y 91)", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(multa), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (interes > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("INTERESES", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(interes), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (imp_salida_divisa > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("IMP. A LA SALIDA DE DIVISAS",
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(imp_salida_divisa),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (fodinfa > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("FODINFA", Font.TIMES_ROMAN, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(fodinfa), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (corpei > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("CORPEI", Font.TIMES_ROMAN, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(corpei), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (otros > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("OTROS", Font.TIMES_ROMAN, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(otros), Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                if (salvaguarda > 0) {
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF("SALVAGUARDA", Font.TIMES_ROMAN, 8,
                            Font.NORMAL, Element.ALIGN_LEFT, 1));
                    tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(salvaguarda),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                }
                tbl_autoliquidacion.addCell(Addons.setCeldaPDF("TOTAL AUTOLIQUIDACION", Font.TIMES_ROMAN, 8,
                        Font.BOLD, Element.ALIGN_RIGHT, 1));
                tbl_autoliquidacion.addCell(Addons.setCeldaPDF(String.valueOf(total_autoliquidacion),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                document.add(tbl_autoliquidacion);

                /* DETALLE */
                PdfPTable tbl_fact = new PdfPTable(1);
                tbl_fact.addCell(
                        Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_LEFT, 0));
                tbl_fact.addCell(Addons.setCeldaPDF("FACTURAS ADJUNTAS", Font.TIMES_ROMAN, 8, Font.BOLD,
                        Element.ALIGN_LEFT, 0));
                document.add(tbl_fact);
                document.add(Addons.setCabeceraTabla(cabTabla, anchoTabla));
                PdfPTable tbl_det = new PdfPTable(anchoTabla);
                num = 1;
                try {
                    facturas = objDB.consulta(
                            "select F.numero_factura, F.razon_social, toDateSQL(F.fecha_compra), F.subtotal, F.descuento, F.iva_12, F.total_compra "
                                    + "from vta_factura_compra as F inner join tbl_factura_importacion as FI on F.id_factura_compra=FI.id_factura_compra "
                                    + "where FI.id_dau=" + id_dau);
                    while (facturas.next()) {
                        tbl_det.addCell(Addons.setCeldaPDF(String.valueOf(num), Font.TIMES_ROMAN, 8,
                                Font.NORMAL, Element.ALIGN_CENTER, 1));
                        for (int i = 1; i <= 7; i++) {
                            tbl_det.addCell(Addons.setCeldaPDF(
                                    ((facturas.getString(i) != null) ? facturas.getString(i) : ""),
                                    Font.TIMES_ROMAN, 8, Font.NORMAL,
                                    (i <= 3 ? Element.ALIGN_LEFT : Element.ALIGN_RIGHT), 1));
                        }
                        num++;
                    }
                    registros.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                document.add(tbl_det);

                document.add(new Paragraph(" "));

            }

            facturas.close();
            registros.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    } 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 RPLiquidacionIndividual(HttpServletResponse response, ResultSet rsRolPago, DataBase objDB,
        Sucursal objSucursal) {//from   www.j a  v  a 2s .co 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 */

        String id_sucursal = "";
        String dni = "";
        String id_empleado = "";
        String empleado = "";
        String periodo = "";
        String departamento = "";
        String rol = "";
        String dias_laborados = "";
        String num_horas_50 = "";
        String num_horas_100 = "";
        String sbu = "";
        String ing_total_50 = "";
        String ing_total_100 = "";
        String total_ingreso = "";
        String egr_iess = "";
        String total_egreso = "";
        String total_pagar = "";
        try {
            boolean ban = false;
            while (rsRolPago.next()) {
                if (ban) {
                    document.newPage();
                }
                ban = true;

                id_sucursal = (rsRolPago.getString("id_sucursal") != null) ? rsRolPago.getString("id_sucursal")
                        : "";
                dni = (rsRolPago.getString("dni") != null) ? rsRolPago.getString("dni") : "";
                id_empleado = (rsRolPago.getString("id_empleado") != null) ? rsRolPago.getString("id_empleado")
                        : "";
                empleado = (rsRolPago.getString("empleado") != null) ? rsRolPago.getString("empleado") : "";
                periodo = (rsRolPago.getString("periodo_sql") != null) ? rsRolPago.getString("periodo_sql")
                        : "";
                departamento = (rsRolPago.getString("departamento") != null)
                        ? Fecha.ISOaSQL(rsRolPago.getString("departamento"))
                        : "";
                rol = (rsRolPago.getString("rol") != null) ? rsRolPago.getString("rol") : "";
                dias_laborados = (rsRolPago.getString("dias_laborados") != null)
                        ? rsRolPago.getString("dias_laborados")
                        : "";
                num_horas_50 = (rsRolPago.getString("num_horas_50") != null)
                        ? rsRolPago.getString("num_horas_50")
                        : "";
                num_horas_100 = (rsRolPago.getString("num_horas_100") != null)
                        ? rsRolPago.getString("num_horas_100")
                        : "";
                sbu = (rsRolPago.getString("sbu") != null) ? rsRolPago.getString("sbu") : "";
                ing_total_50 = (rsRolPago.getString("ing_total_50") != null)
                        ? rsRolPago.getString("ing_total_50")
                        : "";
                ing_total_100 = (rsRolPago.getString("ing_total_100") != null)
                        ? rsRolPago.getString("ing_total_100")
                        : "";
                total_ingreso = (rsRolPago.getString("total_ingreso") != null)
                        ? rsRolPago.getString("total_ingreso")
                        : "";
                egr_iess = (rsRolPago.getString("egr_iess") != null) ? rsRolPago.getString("egr_iess") : "";
                total_egreso = (rsRolPago.getString("total_egreso") != null)
                        ? rsRolPago.getString("total_egreso")
                        : "";
                total_pagar = (rsRolPago.getString("total_pagar") != null) ? rsRolPago.getString("total_pagar")
                        : "";
                int anio = Fecha.datePart("anio", periodo);
                int mes = Fecha.datePart("mes", periodo);
                String fecha_ini = anio + "-" + mes + "-01";
                String fecha_fin = anio + "-" + mes + "-" + Fecha.getUltimoDiaMes(anio, mes);

                /* MAESTRO */
                PdfPTable tbl_maestro = new PdfPTable(3);

                tbl_maestro.addCell(Addons.setCeldaPDF(this.titulo, Font.TIMES_ROMAN, 10, Font.BOLD,
                        Element.ALIGN_CENTER, 0, 5, 3));

                tbl_maestro.addCell(Addons.setCeldaPDF("Rol de Pago: Liquidacin individual", Font.TIMES_ROMAN,
                        8, Font.NORMAL, Element.ALIGN_LEFT, 0, 3, 3));

                tbl_maestro.addCell(Addons.setCeldaPDF("Nombres: " + empleado, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0, 3, 2));
                tbl_maestro.addCell(Addons.setCeldaPDF("Perodo: " + periodo, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));

                tbl_maestro.addCell(Addons.setCeldaPDF("Sucursal: " + objSucursal.getNombre(id_sucursal),
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0));
                tbl_maestro.addCell(Addons.setCeldaPDF("Departamento: " + departamento, Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_LEFT, 0));
                tbl_maestro.addCell(Addons.setCeldaPDF("Cargo: " + rol, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));

                tbl_maestro.addCell(Addons.setCeldaPDF("Tiempo laborado: " + dias_laborados, Font.TIMES_ROMAN,
                        8, Font.NORMAL, Element.ALIGN_LEFT, 0));
                tbl_maestro.addCell(Addons.setCeldaPDF("H.E. 50%: " + num_horas_50, Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_LEFT, 0));
                tbl_maestro.addCell(Addons.setCeldaPDF("H.E. 100%: " + num_horas_100, Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_LEFT, 0));

                tbl_maestro.addCell(
                        Addons.setCeldaPDF(" ", Font.TIMES_ROMAN, 6, Font.NORMAL, Element.ALIGN_LEFT, 0, 1, 3));
                document.add(tbl_maestro);

                /* DETALLE */

                /* ingresos  */
                PdfPTable tbl_ingresos = new PdfPTable(new float[] { 3, 1 });
                tbl_ingresos.addCell(Addons.setCeldaPDF("INGRESOS", Font.TIMES_ROMAN, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1));
                tbl_ingresos.addCell(
                        Addons.setCeldaPDF("VALOR", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_CENTER, 1));

                tbl_ingresos.addCell(Addons.setCeldaPDF("Sueldo bsico unificado", Font.TIMES_ROMAN, 8,
                        Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl_ingresos.addCell(Addons.setCeldaPDF("+" + sbu, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_RIGHT, 1));

                tbl_ingresos.addCell(Addons.setCeldaPDF("Horas extras 50%", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_ingresos.addCell(Addons.setCeldaPDF("+" + ing_total_50, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_RIGHT, 1));

                tbl_ingresos.addCell(Addons.setCeldaPDF("Horas extras 100%", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_ingresos.addCell(Addons.setCeldaPDF("+" + ing_total_100, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_RIGHT, 1));
                try {
                    ResultSet rsIngresosEmpleado = objDB.consulta(
                            "SELECT * FROM vta_rol_pago_rubro_empleado where tipo=true and anulado=false and id_empleado="
                                    + id_empleado + " and periodo between '" + fecha_ini + "' and '" + fecha_fin
                                    + "';");
                    while (rsIngresosEmpleado.next()) {
                        tbl_ingresos
                                .addCell(Addons.setCeldaPDF(
                                        ((rsIngresosEmpleado.getString("rubro") != null)
                                                ? rsIngresosEmpleado.getString("rubro")
                                                : ""),
                                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                        tbl_ingresos
                                .addCell(Addons.setCeldaPDF(
                                        "+" + ((rsIngresosEmpleado.getString("valor") != null)
                                                ? rsIngresosEmpleado.getString("valor")
                                                : "0.00"),
                                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                    }
                    rsIngresosEmpleado.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                /* egresos  */
                PdfPTable tbl_egresos = new PdfPTable(new float[] { 3, 1 });
                tbl_egresos.addCell(
                        Addons.setCeldaPDF("EGRESOS", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_CENTER, 1));
                tbl_egresos.addCell(
                        Addons.setCeldaPDF("VALOR", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_CENTER, 1));

                tbl_egresos.addCell(Addons.setCeldaPDF("Aporte IESS", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 1));
                tbl_egresos.addCell(Addons.setCeldaPDF("-" + egr_iess, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_RIGHT, 1));
                try {
                    ResultSet rsIngresosEmpleado = objDB.consulta(
                            "SELECT * FROM vta_rol_pago_rubro_empleado where tipo=false and anulado=false and id_empleado="
                                    + id_empleado + " and periodo between '" + fecha_ini + "' and '" + fecha_fin
                                    + "';");
                    while (rsIngresosEmpleado.next()) {
                        tbl_egresos
                                .addCell(Addons.setCeldaPDF(
                                        ((rsIngresosEmpleado.getString("rubro") != null)
                                                ? rsIngresosEmpleado.getString("rubro")
                                                : ""),
                                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                        tbl_egresos
                                .addCell(Addons.setCeldaPDF(
                                        "-" + ((rsIngresosEmpleado.getString("valor") != null)
                                                ? rsIngresosEmpleado.getString("valor")
                                                : "0.00"),
                                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_RIGHT, 1));
                    }
                    rsIngresosEmpleado.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }

                PdfPTable tbl_totales = new PdfPTable(new float[] { 3, 1, 3, 1 });
                tbl_totales.addCell(Addons.setCeldaPDF("TOTAL INGRESOS", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));
                tbl_totales.addCell(Addons.setCeldaPDF("$ " + total_ingreso, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_RIGHT, 0));
                tbl_totales.addCell(Addons.setCeldaPDF("TOTAL EGRESOS", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));
                tbl_totales.addCell(Addons.setCeldaPDF("$ " + total_egreso, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_RIGHT, 0));

                tbl_totales.addCell(Addons.setCeldaPDF("VALOR A RECIBIR:     $ " + total_pagar,
                        Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 0, 3, 4));

                PdfPTable tbl_det = new PdfPTable(2);
                tbl_det.addCell(Addons.setCeldaPDF(tbl_ingresos, Element.ALIGN_LEFT, 0));
                tbl_det.addCell(Addons.setCeldaPDF(tbl_egresos, Element.ALIGN_LEFT, 0));
                document.add(tbl_det);

                document.add(tbl_totales);

                document.add(new Paragraph(" "));
                document.add(new Paragraph(" "));

                PdfPTable tbl_firma = new PdfPTable(1);
                tbl_firma.addCell(Addons.setCeldaPDF("______________________", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));
                tbl_firma.addCell(Addons.setCeldaPDF("Recib conforme", Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));
                tbl_firma.addCell(Addons.setCeldaPDF("C.C.  " + dni, Font.TIMES_ROMAN, 8, Font.NORMAL,
                        Element.ALIGN_LEFT, 0));
                document.add(tbl_firma);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

    } catch (IllegalStateException ie) {
        ie.printStackTrace();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    document.close(); // paso 5
    /* fin PDF */
}