Example usage for com.lowagie.text Font BOLD

List of usage examples for com.lowagie.text Font BOLD

Introduction

In this page you can find the example usage for com.lowagie.text Font BOLD.

Prototype

int BOLD

To view the source code for com.lowagie.text Font BOLD.

Click Source Link

Document

this is a possible style.

Usage

From source file:jm.nom.clas.Carnet.java

public void imprimir(HttpServletResponse response, ResultSet rsCarnets, String path) {
    response.setContentType("application/pdf");
    response.setHeader("Pragma", "no-cache");
    response.setHeader("Expires", "Mon, 01 Jan 2001 00:00:01 GMT");
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Cache-Control", "must-revalidate");
    response.setHeader("Cache-Control", "no-cache");

    /*try{//from ww w.j  a va2s. co m
        rsCarnets = objEmpleado.getCarnets(id);
        if(rsCarnets.next()){
            id_sucursal = ((rsCarnets.getString("id_sucursal")!=null) ? rsCarnets.getString("id_sucursal") : "");
            id_instalacion = ((rsCarnets.getString("id_instalacion")!=null) ? rsCarnets.getString("id_instalacion") : "");
            serie_factura = ((rsCarnets.getString("serie_factura")!=null) ? rsCarnets.getString("serie_factura") : "");
            num_factura = ((rsCarnets.getString("num_factura")!=null) ? rsCarnets.getString("num_factura") : "");
            razon_social = ((rsCarnets.getString("razon_social")!=null) ? rsCarnets.getString("razon_social") : "CONSUMIDOR FINAL");
            fecha_emision = ((rsCarnets.getString("fecha_emision")!=null) ? Fecha.ISOaSQL(rsCarnets.getString("fecha_emision")) : "");
            direccion = ((rsCarnets.getString("direccion")!=null) ? rsCarnets.getString("direccion") : "");
            vendedor = ((rsCarnets.getString("vendedor")!=null) ? rsCarnets.getString("vendedor") : "");
            total = ((rsCarnets.getString("total")!=null) ? rsCarnets.getString("total") : "0.00");
            de_activo = ((rsCarnets.getString("de_activo")!=null) ? rsCarnets.getBoolean("de_activo") : false);
            rsCarnets.close();
        }
    }catch(Exception ie){
        ie.printStackTrace();
    }*/
    try {
        /* inicio PDF */
        Document document = new Document(PageSize.A4.rotate());// paso 1
        document.setMargins(-47, 0, 38, 0); /*Izquierda, derecha, tope, pie */

        PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream()); // paso 2
        writer.setPageEvent(new Carnet(this._dir));
        document.open(); // paso 3

        //writer.addJavaScript("this.print(false);", false); // Para enviar a la impresora automticamente.

        /* todo el cuerpo del doc es el paso 4 */

        //PdfPTable tbl = new PdfPTable(new float[]{40f,60f});
        PdfPTable tbl = new PdfPTable(4);
        int i = 0;
        try {
            //rsCarnets = objEmpleado.getCarnets(id);
            while (rsCarnets.next()) {
                PdfPTable tbl1 = new PdfPTable(1);
                PdfPTable tbl2 = new PdfPTable(new float[] { 90f, 5f, 5f });
                String foto = ((rsCarnets.getString("padre_nombre") != null)
                        ? rsCarnets.getString("padre_nombre")
                        : "");
                //_dir="C:\\Users\\SoulGael\\Documents\\NetBeansProjects\\trunk\\saitel\\build\\web\\img\\luis.jpg";

                tbl1.addCell(Addons.setCeldaPDFBottom(" ", Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT,
                        0, 26, 0));
                tbl1.addCell(Addons.setLogoCarnet(_dir + foto, 79, 103));
                //tbl1.addCell(Addons.setLogoCarnet(_dir,79,103));
                String nombre = ((rsCarnets.getString("nombre") != null) ? rsCarnets.getString("nombre") : "");
                String apellidos = ((rsCarnets.getString("apellido") != null) ? rsCarnets.getString("apellido")
                        : "");
                String cargo = ((rsCarnets.getString("cargo") != null) ? rsCarnets.getString("cargo") : "");
                ;
                String[] nombresArray = nombre.split(" ");
                String[] apellidosArray = apellidos.split(" ");
                String n_completos = nombresArray[0] + " " + apellidosArray[0];
                String CI = ((rsCarnets.getString("dni") != null) ? rsCarnets.getString("dni") : "");
                ;
                String sangre = ((rsCarnets.getString("tipo_sangre") != null)
                        ? rsCarnets.getString("tipo_sangre")
                        : "");
                ;
                String carnet = ((rsCarnets.getString("carnet") != null) ? rsCarnets.getString("carnet") : "");
                //String carnet="A,B,C,D,E,F,G";
                Color A = Color.WHITE;
                Color B = Color.WHITE;
                Color C = Color.WHITE;
                Color D = Color.WHITE;
                Color E = Color.WHITE;
                Color F = Color.WHITE;
                Color G = Color.WHITE;

                String[] carnetArray = carnet.split(",");
                for (int j = 0; j < carnetArray.length; j++) {
                    if (carnetArray[j].equals("A")) {
                        A = Color.ORANGE;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    if (carnetArray[j].equals("B")) {
                        B = Color.ORANGE;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    if (carnetArray[j].equals("C")) {
                        C = Color.ORANGE;
                        ;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    if (carnetArray[j].equals("D")) {
                        D = Color.ORANGE;
                        ;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    if (carnetArray[j].equals("E")) {
                        E = Color.ORANGE;
                        ;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    if (carnetArray[j].equals("F")) {
                        F = Color.ORANGE;
                        ;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    if (carnetArray[j].equals("G")) {
                        G = Color.ORANGE;
                        ;
                        j++;
                        if (j > carnetArray.length - 1)
                            j = carnetArray.length - 1;
                    }
                    break;
                }

                tbl1.addCell(Addons.setCeldaPDFBottom(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_CENTER, 0,
                        0, 0));
                tbl1.addCell(Addons.setCeldaPDFBottom(n_completos, Font.ITALIC, 13, Font.BOLD,
                        Element.ALIGN_CENTER, 0, 0, 0));
                tbl1.addCell(Addons.setCeldaPDFBottom(cargo, Font.ITALIC, 12, Font.BOLD, Element.ALIGN_CENTER,
                        0, 0, 0));
                tbl1.addCell(Addons.setCeldaPDFBottom(CI, Font.ITALIC, 12, Font.BOLD, Element.ALIGN_CENTER, 0,
                        0, 0));
                tbl1.addCell(Addons.setCeldaPDFBottom(sangre, Font.ITALIC, 12, Font.BOLD, Element.ALIGN_CENTER,
                        0, 0, 0));

                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 7, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(Addons.setCeldaPDFCarnet("  LICENCIA INTERNA DE ", Font.ITALIC, 9, Font.BOLD,
                        Element.ALIGN_CENTER, 0, 0, 3));
                tbl2.addCell(Addons.setCeldaPDFCarnet("  PREVENCION DE RIESGOS", Font.ITALIC, 9, Font.BOLD,
                        Element.ALIGN_CENTER, 0, 0, 3));
                tbl2.addCell(Addons.setCeldaPDFCarnet("   Con la induccin recibida y aprobada usted",
                        Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(Addons.setCeldaPDFCarnet("   est autorizado para:", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(Addons.setCeldaPDFCarnet("      a. Trabajo de Oficina.", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 2, 0, A));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));

                tbl2.addCell(Addons.setCeldaPDFCarnet("      b. Trabajo de Marketing y propaganda", Font.ITALIC,
                        8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 2, 0, B));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));

                tbl2.addCell(Addons.setCeldaPDFCarnet("      c. Trabajo de mantenimiento y limpieza",
                        Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 2, 0, C));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));

                tbl2.addCell(Addons.setCeldaPDFCarnet("      d. Trabajo de instalaciones menores a los ",
                        Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0,
                        0, 2));
                tbl2.addCell(Addons.setCeldaPDFCarnet("      ocho metros sobre el nivel.", Font.ITALIC, 8,
                        Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 0, 0, D));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnet("      (Domicilios, postes, cableado)", Font.ITALIC, 8,
                        Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0,
                        2, 2));

                tbl2.addCell(Addons.setCeldaPDFCarnet("      e. Trabajo de instalaciones, antenas,",
                        Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0,
                        0, 2));
                tbl2.addCell(Addons.setCeldaPDFCarnet("      infraestructura mayores a los ocho", Font.ITALIC,
                        8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 0, 0, E));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnet("      metros sobre el nivel", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_CENTER, 0,
                        2, 2));

                tbl2.addCell(Addons.setCeldaPDFCarnet("      f. Planes de emergencia y contingencia",
                        Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 2, 0, F));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));

                tbl2.addCell(Addons.setCeldaPDFCarnet("      g. Planes de rescate", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_LEFT, 0, 2, 0));
                tbl2.addCell(Addons.setCeldaPDFCarnetOpciones(" ", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 1, 2, 0, G));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 2, 0));

                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 8, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(
                        Addons.setCeldaPDFCarnet(" ", Font.ITALIC, 10, Font.BOLD, Element.ALIGN_LEFT, 0, 0, 3));
                tbl2.addCell(Addons.setCeldaPDFCarnet("Ing. FREDDY ROSERO", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE));
                tbl2.addCell(Addons.setCeldaPDFCarnet("GERENTE", Font.ITALIC, 8, Font.BOLD,
                        Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE));
                tbl2.addCell(Addons.setCeldaPDFCarnet("Fecha de Expedicin: Mayo 2015", Font.ITALIC, 5,
                        Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE));
                tbl2.addCell(Addons.setCeldaPDFCarnet("Fecha de Caducidad: Mayo 2016", Font.ITALIC, 5,
                        Font.BOLD, Element.ALIGN_CENTER, 0, 0, 3, Color.BLUE));
                /* tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("nombres")!=null) ? rsCarnets.getString("nombres") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("rol")!=null) ? rsCarnets.getString("rol") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1));
                        
                tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("dni")!=null) ? rsCarnets.getString("dni") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1));
                tbl1.addCell(Addons.setCeldaPDF(((rsCarnets.getString("tipo_sangre")!=null) ? rsCarnets.getString("tipo_sangre") : ""), Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_LEFT, 1));
                        
                String idcarnet=(rsCarnets.getString("id_empleado")!=null) ? rsCarnets.getString("id_empleado") : "";*/

                tbl.addCell(Addons.setCeldaPDF(tbl1, 0, 0));
                tbl.addCell(Addons.setCeldaPDF(tbl2, 0, 0));
                if (i % 2 != 0) {
                    tbl1.addCell(
                            Addons.setCeldaPDF(" ", Font.ITALIC, 10, Font.BOLD, Element.ALIGN_LEFT, 0, 16, 3));
                }
                i++;
            }
            if (i % 2 != 0) {
                tbl.addCell(" ");
                tbl.addCell(" ");
            }

            /*Archivo archivo = new Archivo(_ip, _puerto, _db, _usuario, _clave);
                //path = path.substring(0, path.lastIndexOf("/"));
                String carnet = path + "/img/" + archivo.getArchivo(_dir, "vta_empleado", idcarnet, "padre_nombre", "foto");
                archivo.cerrar();
                Image imagen = null;
                try{
                    imagen = Image.getInstance(carnet);
                    imagen.scaleAbsolute(50, 70);
                    PdfPCell celdaImg = new PdfPCell(imagen);
                    celdaImg.setBorderWidth(0);
                    celdaImg.setPadding(0);
                    tbl.addCell(celdaImg);
                    document.add(tbl1);
                }catch(Exception e){
                    tbl.addCell(" ");
                }*/

        } catch (Exception e) {
            e.printStackTrace();
        }
        document.add(tbl);

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

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

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 {/*from www  .j a  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));

        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 */
}

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 {//  w  w w.j  a va 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 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  v a  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));

        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 {//from   w  ww .  j  a va2 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));

        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 {//from  w  w  w.  ja  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 */

        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 w  w  w.  ja  v  a 2 s  . 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 */
}

From source file:jm.Reporte.java

License:GNU General Public License

public void correos(HttpServletResponse response, 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   w w w.j  ava  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));

        PdfPTable tbl_det = new PdfPTable(new float[] { 20, 80 });
        String aux = "";
        String columna1 = "";
        String columna2 = "";
        boolean uno = true;
        try {
            tbl_det.addCell(
                    Addons.setCeldaPDF("SECTOR", Font.TIMES_ROMAN, 8, Font.BOLD, Element.ALIGN_CENTER, 1));
            tbl_det.addCell(Addons.setCeldaPDF("CORREOS ELECTRONICOS", Font.TIMES_ROMAN, 8, Font.BOLD,
                    Element.ALIGN_CENTER, 1));
            while (registros.next()) {
                columna1 = (registros.getString(1) != null) ? registros.getString(1) : "";
                columna2 += ((registros.getString(2) != null) ? registros.getString(2) : "") + ", ";
                if (aux.compareTo(columna1) != 0 && !uno) {
                    tbl_det.addCell(Addons.setCeldaPDF(columna1, Font.TIMES_ROMAN, 8, Font.NORMAL,
                            Element.ALIGN_LEFT, 1));
                    tbl_det.addCell(Addons.setCeldaPDF(columna2.substring(0, columna2.length() - 2),
                            Font.TIMES_ROMAN, 8, Font.NORMAL, Element.ALIGN_LEFT, 1));
                    aux = columna1;
                    columna2 = "";
                }
                uno = false;
            }
            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.web.Addons.java

License:GNU General Public License

public static PdfPTable setCabecera(String logo, String titulo, String ruc, String subtitulo, String direccion,
        String sucursal) {/*from  w ww .  j  ava2 s .  c  o m*/
    PdfPTable encabezado = new PdfPTable(new float[] { 80f, 400f });
    PdfPTable tbl_encab = new PdfPTable(1);
    Image imagelogo = null;
    try {
        imagelogo = Image.getInstance(logo);
        imagelogo.scaleAbsolute(150, 70);
        PdfPCell celdaImg = new PdfPCell(imagelogo);
        celdaImg.setBorderWidth(0);
        celdaImg.setPadding(0);
        encabezado.addCell(celdaImg);
    } catch (Exception e) {
        encabezado.addCell("");
    }
    tbl_encab.addCell(Addons.setCeldaPDF(titulo, Font.HELVETICA, 13, Font.BOLD, Element.ALIGN_CENTER, 0));
    tbl_encab.addCell(Addons.setCeldaPDF(direccion, Font.HELVETICA, 11, Font.NORMAL, Element.ALIGN_CENTER, 0));
    if (ruc.compareTo("") != 0) {
        tbl_encab.addCell(
                Addons.setCeldaPDF("RUC: " + ruc, Font.HELVETICA, 11, Font.NORMAL, Element.ALIGN_CENTER, 0));
    }
    tbl_encab.addCell(Addons.setCeldaPDF(subtitulo, Font.HELVETICA, 10, Font.NORMAL, Element.ALIGN_CENTER, 0));

    encabezado.addCell(Addons.setCeldaPDF(tbl_encab, Element.ALIGN_CENTER, 0));

    encabezado.addCell(Addons.setFilaBlanco(2, 6));

    if (sucursal.compareTo("") != 0) {
        encabezado.addCell(Addons.setCeldaPDF("Sucursal: " + sucursal, Font.HELVETICA, 10, Font.NORMAL,
                Element.ALIGN_LEFT, 0, 0, 2));
    }

    encabezado.addCell(Addons.setCeldaPDF("Fecha de impresin: " + Fecha.getFecha("SQL"), Font.HELVETICA, 10,
            Font.NORMAL, Element.ALIGN_LEFT, 0, 0, 2));

    encabezado.addCell(Addons.setFilaBlanco(2, 4));

    return encabezado;
}

From source file:jm.web.Addons.java

License:GNU General Public License

public static void setEncabezado(PdfWriter writer, Document document, String texto) {
    if (writer.getPageNumber() > 1) {
        try {/*from ww w . j  a  va 2  s.  c om*/
            PdfPTable encabezado = new PdfPTable(1);
            encabezado.setTotalWidth(document.right() - document.left() - 120);
            encabezado.addCell(Addons.setCeldaPDF(texto, Font.HELVETICA, 9, Font.BOLD, Element.ALIGN_LEFT, 0));
            encabezado.writeSelectedRows(0, -1, 60, document.top() + 25, writer.getDirectContent());

            PdfContentByte cb = writer.getDirectContent();
            cb.setLineWidth(2);
            cb.moveTo(60, document.top() + 10);
            cb.lineTo(document.right() - document.left() - 58, document.top() + 10);
        } catch (Exception e) {
            throw new ExceptionConverter(e);
        }
    }
}