Example usage for com.itextpdf.text BaseColor LIGHT_GRAY

List of usage examples for com.itextpdf.text BaseColor LIGHT_GRAY

Introduction

In this page you can find the example usage for com.itextpdf.text BaseColor LIGHT_GRAY.

Prototype

BaseColor LIGHT_GRAY

To view the source code for com.itextpdf.text BaseColor LIGHT_GRAY.

Click Source Link

Usage

From source file:PrefichaPDF.java

public static void drawRectangle(PdfContentByte content, float x, float y, float width, float height) {
    content.saveState();//  w ww .  j  a  va 2s  .  c o  m
    PdfGState state = new PdfGState();
    content.setGState(state);
    content.setRGBColorFill(232, 232, 232);
    content.setColorStroke(BaseColor.LIGHT_GRAY);
    //        content.setr
    content.setLineWidth((float) .5);
    content.rectangle(x, y, width, height);
    content.fillStroke();
    content.restoreState();
}

From source file:PrefichaPDF.java

public static void drawRectangleSC(PdfContentByte content, float x, float y, float width, float height) {
    content.saveState();/*from w w  w . j a va2 s. com*/
    PdfGState state = new PdfGState();
    //        state.setFillOpacity(0.6f);
    content.setGState(state);
    content.setRGBColorFill(0xFF, 0xFF, 0xFA);
    content.setColorStroke(BaseColor.LIGHT_GRAY);
    content.setLineWidth((float) .5);
    content.rectangle(x, y, width, height);
    content.fillStroke();
    content.restoreState();
}

From source file:PrefichaPDF.java

public static void drawRectangleText(PdfContentByte content, float x, float y, float width, float height) {
    content.saveState();//from  w w w.  j a v a2s  .c om
    PdfGState state = new PdfGState();
    content.setGState(state);
    content.setRGBColorFill(0, 230, 255);
    content.setColorStroke(BaseColor.LIGHT_GRAY);
    content.setLineWidth((float) .5);
    content.rectangle(x, y, width, height);
    content.fillStroke();
    content.restoreState();
}

From source file:alessandrafx.MarcoVentanaController.java

@FXML
private void generarReporteMenusal(MouseEvent event) {

    try {/*from   w w w .  ja v a2  s  .co  m*/
        FileChooser fileChooser = new FileChooser();
        fileChooser.setInitialFileName("Reporte.pdf");
        File file = fileChooser.showSaveDialog(null);
        file.getParentFile().mkdir();

        Document document = new Document();
        try {
            try {
                PdfWriter.getInstance(document, new FileOutputStream(file));
            } catch (FileNotFoundException ex) {
                Logger.getLogger(VentanaEgresoController.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (DocumentException ex) {
            Logger.getLogger(VentanaEgresoController.class.getName()).log(Level.SEVERE, null, ex);
        }

        document.open();
        PdfPTable table = new PdfPTable(3);
        PdfPCell cell = new PdfPCell(new Phrase("Factura emitida el " + new Date()));
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);

        SistemaAleMC sistema = new SistemaAleMC();
        Double balanceMonetario = 0.0;

        //Para salidas de dinero
        ArrayList<Capital> capitales = sistema.getRegistrosCapitalTipo('S');
        cell = new PdfPCell(new Phrase("Gastos y pagos realizados"));
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        //Agrega los registros de salidas de dinero
        Double totalEgreso = 0.0;
        if (capitales.isEmpty()) {
            cell = new PdfPCell(new Phrase(" --- "));
            cell.setColspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(" --- "));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        }
        for (Capital capital : capitales) {
            cell = new PdfPCell(new Phrase(capital.getMotivo().toString()));
            cell.setColspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(capital.getMonto().toString()));
            balanceMonetario -= Double.valueOf(capital.getMonto());
            totalEgreso -= Double.valueOf(capital.getMonto());
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        }
        cell = new PdfPCell(new Phrase("TOTAL DE EGRESOS"));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(totalEgreso.toString()));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cell);

        //Para Pago de mensualidades
        capitales = sistema.getRegistrosCapitalTipo('M');
        cell = new PdfPCell(new Phrase("Pagos de mensualidad recibidos"));
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        //Agrega los registros de pago de mensualidades de los alumnos
        Double totalIngresoMen = 0.0;
        if (capitales.isEmpty()) {
            cell = new PdfPCell(new Phrase(" --- "));
            cell.setColspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(" --- "));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        }
        for (Capital capital : capitales) {
            cell = new PdfPCell(new Phrase(capital.getMotivo().toString()));
            cell.setColspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(capital.getMonto().toString()));
            balanceMonetario += Double.valueOf(capital.getMonto());
            totalIngresoMen += Double.valueOf(capital.getMonto());
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        }
        cell = new PdfPCell(new Phrase("TOTAL DE MENSUALIDADES"));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(totalIngresoMen.toString()));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cell);

        //Para Pago de anualidades
        capitales = sistema.getRegistrosCapitalTipo('A');
        cell = new PdfPCell(new Phrase("Pagos de anualidades recibidos"));
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        //Agrega los registros de pago de anualidades de los alumnos
        Double totalIngresoAnu = 0.0;
        if (capitales.isEmpty()) {
            cell = new PdfPCell(new Phrase(" --- "));
            cell.setColspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(" --- "));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        }
        for (Capital capital : capitales) {
            cell = new PdfPCell(new Phrase(capital.getMotivo().toString()));
            cell.setColspan(2);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table.addCell(cell);
            cell = new PdfPCell(new Phrase(capital.getMonto().toString()));
            balanceMonetario += Double.valueOf(capital.getMonto());
            totalIngresoAnu += Double.valueOf(capital.getMonto());
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            table.addCell(cell);
        }
        cell = new PdfPCell(new Phrase("TOTAL DE ANUALIDADES"));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT);
        table.addCell(cell);
        cell = new PdfPCell(new Phrase(totalIngresoAnu.toString()));
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cell);

        //PARA EL BALANCE MONETARIO
        capitales = sistema.getRegistrosCapitalTipo('A');
        cell = new PdfPCell(new Phrase("Total"));
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cell);
        //Agrega la celda del total monetario
        if (balanceMonetario == (Double) 0.0) {
            cell = new PdfPCell(new Phrase("No hubieron movimientos este mes"));
        } else {
            cell = new PdfPCell(new Phrase(balanceMonetario.toString()));
        }
        cell.setColspan(3);
        cell.setBackgroundColor(BaseColor.WHITE);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(cell);

        try {
            document.add(table);
        } catch (DocumentException ex) {
            Logger.getLogger(VentanaEgresoController.class.getName()).log(Level.SEVERE, null, ex);
        }
        document.close();
        Alert alerta = new Alert(Alert.AlertType.INFORMATION);
        alerta.setTitle("Corre a ver tu PDF!");
        alerta.setHeaderText(null);
        alerta.setContentText("El PDF ha sido generado, puedes revisarlo");
        alerta.showAndWait();

    } catch (Exception e) {
        Alert alerta = new Alert(Alert.AlertType.INFORMATION);
        alerta.setTitle("Lo sentimos");
        alerta.setHeaderText(null);
        alerta.setContentText("La ubicacin seleccionada no es vlida y por tanto, no se generar el PDF");
        alerta.showAndWait();
    }
}

From source file:Almacen.Conciliacion.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
     // TODO add your handling code here:
     try {// ww  w.  j  av  a2 s .c  o m
         javax.swing.JFileChooser archivo = new javax.swing.JFileChooser();
         archivo.setFileFilter(new ExtensionFileFilter("pdf document (*.pdf)", new String[] { "PDF" }));
         String ruta = null;

         if (archivo.showSaveDialog(null) == archivo.APPROVE_OPTION) {
             ruta = archivo.getSelectedFile().getAbsolutePath();
             if (ruta != null) {
                 Session session = HibernateUtil.getSessionFactory().openSession();
                 ArrayList datos = new ArrayList();
                 Query query = session.createSQLQuery(
                         "select compania.nombre, orden.tipo_nombre, orden.modelo, orden.no_serie, clientes.nombre as nombres,orden.id_orden \n"
                                 + "from orden inner join compania on compania.id_compania=orden.id_compania inner join clientes on clientes.id_clientes=orden.id_cliente\n"
                                 + "where orden.id_orden=" + Integer.parseInt(orden) + "");
                 query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
                 datos = (ArrayList) query.list();

                 //
                 PDF reporte = new PDF();
                 reporte.Abrir2(PageSize.LEGAL.rotate(), "CONCILIACIN", ruta + ".pdf");
                 BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
                 float[] nuevos = new float[] { 40, 40, 25, 40, 145, 20, 50, 50, 50, 50, 50, 50, 100, 50, 20 };
                 com.itextpdf.text.Font font = new com.itextpdf.text.Font(
                         com.itextpdf.text.Font.FontFamily.HELVETICA, 7, com.itextpdf.text.Font.NORMAL);
                 com.itextpdf.text.Font font1 = new com.itextpdf.text.Font(
                         com.itextpdf.text.Font.FontFamily.HELVETICA, 7, com.itextpdf.text.Font.NORMAL);
                 BaseColor contenido = BaseColor.WHITE;
                 BaseColor contenido1 = BaseColor.DARK_GRAY;
                 int centro = com.itextpdf.text.Element.ALIGN_CENTER;
                 int izquierda = com.itextpdf.text.Element.ALIGN_LEFT;
                 int derecha = com.itextpdf.text.Element.ALIGN_RIGHT;

                 reporte.inicioTexto();
                 reporte.agregaObjeto(reporte.crearImagen("imagenes/empresa300115.jpg", 730, -90, 45));
                 reporte.contenido.setFontAndSize(bf, 20);
                 reporte.contenido.setColorFill(BaseColor.BLACK);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_CENTER,
                         "CONCILIACIN PARA FACTURACIN", 395, 577, 0);

                 reporte.contenido.setFontAndSize(bf, 12);
                 reporte.contenido.setColorFill(BaseColor.BLACK);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "COMPAIA:", 38, 540, 0);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "TIPO DE UNIDAD:", 38, 520, 0);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "MODELO:", 38, 500, 0);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "SERIE VIN:", 38, 480, 0);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "CLIENTE:", 38, 460, 0);

                 reporte.contenido.roundRectangle(170, 540, 410, 0, 0);
                 reporte.contenido.roundRectangle(170, 520, 410, 0, 0);
                 reporte.contenido.roundRectangle(170, 500, 410, 0, 0);
                 reporte.contenido.roundRectangle(170, 480, 410, 0, 0);
                 reporte.contenido.roundRectangle(170, 460, 410, 0, 0);

                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ORDEN DE TRABAJO SET.", 605, 540,
                         0);
                 reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ORDEN DE SURTIDO", 620, 480, 0);

                 for (int i = 0; i < datos.size(); i++) {
                     java.util.HashMap map = (java.util.HashMap) datos.get(i);
                     reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, map.get("nombre").toString(),
                             171, 540, 0);
                     reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                             map.get("tipo_nombre").toString(), 171, 520, 0);
                     reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, map.get("modelo").toString(),
                             171, 500, 0);
                     reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, map.get("no_serie").toString(),
                             171, 480, 0);
                     reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, map.get("nombres").toString(),
                             171, 460, 0);
                     reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, map.get("id_orden").toString(),
                             657, 520, 0);
                 }
                 reporte.contenido.roundRectangle(640, 520, 80, 0, 0);
                 reporte.contenido.roundRectangle(640, 460, 80, 0, 0);

                 reporte.finTexto();

                 reporte.agregaObjeto(new Paragraph(" "));
                 reporte.agregaObjeto(new Paragraph(" "));
                 reporte.agregaObjeto(new Paragraph(" "));

                 reporte.agregaObjeto(new Paragraph(" "));
                 reporte.agregaObjeto(new Paragraph(" "));

                 reporte.agregaObjeto(new Paragraph(" "));
                 reporte.agregaObjeto(new Paragraph(" "));

                 PdfPTable tabla = reporte.crearTabla(nuevos.length, nuevos, 100, Element.ALIGN_CENTER);
                 cabecera(reporte, bf, tabla, "", 2);
                 DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");

                 int num_r = t_datos.getRowCount();
                 for (int i = 0; i < num_r; i++) {
                     for (int j = 0; j < 4; j++) {
                         int renglon = 0;
                         switch (j) {
                         case 0:
                             renglon = 8;
                             break;
                         case 1:
                             renglon = 10;
                             break;
                         case 2:
                             renglon = 11;
                             break;
                         case 3:
                             renglon = 12;
                             break;
                         }
                         if ((Double.parseDouble(t_datos.getValueAt(i, renglon).toString()) > 0
                                 && t_datos.getValueAt(i, 9).toString().compareTo("N") == 0)
                                 || ((Double.parseDouble(t_datos.getValueAt(i, renglon).toString()) > 0
                                         && renglon >= 10))
                                 || (renglon == 8
                                         && Double.parseDouble(t_datos.getValueAt(i, 10).toString()) <= 0
                                         && Double.parseDouble(t_datos.getValueAt(i, 11).toString()) <= 0
                                         && Double.parseDouble(t_datos.getValueAt(i, 12).toString()) <= 0)) {
                             if (renglon == 8 && t_datos.getValueAt(i, 9).toString().compareTo("-") == 0)
                                 contenido = BaseColor.WHITE;
                             else
                                 contenido = BaseColor.LIGHT_GRAY;

                             if ((boolean) t_datos.getValueAt(i, 3) == true
                                     || (boolean) t_datos.getValueAt(i, 4) == true) {
                                 //columna0
                                 if (t_datos.getValueAt(i, 5) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 5).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna1
                                 if (t_datos.getValueAt(i, 6) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 6).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna2
                                 tabla.addCell(reporte.celda(t_datos.getValueAt(i, renglon).toString(), font,
                                         contenido, centro, 0, 1, Rectangle.RECTANGLE));

                                 //columna3
                                 if (t_datos.getValueAt(i, 14) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 14).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna4
                                 tabla.addCell(reporte.celda(t_datos.getValueAt(i, 2).toString(), font,
                                         contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                                 //columna5
                                 if (renglon == 8 && t_datos.getValueAt(i, 9).toString().compareTo("-") == 0)
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 else {
                                     switch (renglon) {
                                     case 8:
                                         tabla.addCell(reporte.celda("N", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     case 10:
                                         tabla.addCell(reporte.celda("D", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     case 11:
                                         tabla.addCell(reporte.celda("R", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     case 12:
                                         tabla.addCell(reporte.celda("M", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     }
                                 }
                                 //columna6
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(t_datos.getValueAt(i, 15)),
                                         font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                 //columna7 $tot aut.
                                 double n;
                                 n = BigDecimal
                                         .valueOf(Double.parseDouble(t_datos.getValueAt(i, renglon).toString())
                                                 * Double.parseDouble(t_datos.getValueAt(i, 15).toString()))
                                         .setScale(2, RoundingMode.UP).doubleValue();
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font, contenido,
                                         derecha, 0, 1, Rectangle.RECTANGLE));
                                 //columna8
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(t_datos.getValueAt(i, 16)),
                                         font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                                 //columna9 $tot com
                                 n = BigDecimal
                                         .valueOf(Double.parseDouble(t_datos.getValueAt(i, renglon).toString())
                                                 * Double.parseDouble(t_datos.getValueAt(i, 16).toString()))
                                         .setScale(2, RoundingMode.UP).doubleValue();
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font, contenido,
                                         derecha, 0, 1, Rectangle.RECTANGLE));

                                 //columna10 11
                                 if (renglon == 8 && t_datos.getValueAt(i, 9).toString().compareTo("-") == 0) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     switch (renglon) {
                                     case 8:
                                         n = BigDecimal.valueOf(
                                                 Double.parseDouble(t_datos.getValueAt(i, 16).toString()) / 0.9d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     case 10:
                                         n = BigDecimal
                                                 .valueOf(
                                                         Double.parseDouble(t_datos.getValueAt(i, 15).toString())
                                                                 * 0.72d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     case 11:
                                         n = BigDecimal
                                                 .valueOf(
                                                         Double.parseDouble(t_datos.getValueAt(i, 15).toString())
                                                                 * 0.65d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     case 12:
                                         n = BigDecimal
                                                 .valueOf(
                                                         Double.parseDouble(t_datos.getValueAt(i, 15).toString())
                                                                 * 0.65d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     }
                                 }
                                 //columna12
                                 if (t_datos.getValueAt(i, 18) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 18).toString(), font,
                                             contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                                 }

                                 //columna13
                                 if (t_datos.getValueAt(i, 19) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 19).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna14
                                 tabla.addCell(
                                         reporte.celda("V", font, contenido, centro, 0, 1, Rectangle.RECTANGLE));
                             }
                         }
                     }
                 }
                 font1.setColor(BaseColor.WHITE);
                 tabla.addCell(reporte.celda("Faltante en Vales", font1, contenido1, centro, 15, 1,
                         Rectangle.RECTANGLE));

                 for (int i = 0; i < num_r; i++) {
                     for (int j = 0; j < 4; j++) {
                         int renglon = 0;
                         switch (j) {
                         case 0:
                             renglon = 8;
                             break;
                         case 1:
                             renglon = 10;
                             break;
                         case 2:
                             renglon = 11;
                             break;
                         case 3:
                             renglon = 12;
                             break;
                         }
                         if ((Double.parseDouble(t_datos.getValueAt(i, renglon).toString()) > 0
                                 && t_datos.getValueAt(i, 9).toString().compareTo("N") == 0)
                                 || ((Double.parseDouble(t_datos.getValueAt(i, renglon).toString()) > 0
                                         && renglon >= 10))
                                 || (renglon == 8
                                         && Double.parseDouble(t_datos.getValueAt(i, 10).toString()) <= 0
                                         && Double.parseDouble(t_datos.getValueAt(i, 11).toString()) <= 0
                                         && Double.parseDouble(t_datos.getValueAt(i, 12).toString()) <= 0)) {
                             if (renglon == 8 && t_datos.getValueAt(i, 9).toString().compareTo("-") == 0)
                                 contenido = BaseColor.WHITE;
                             else
                                 contenido = BaseColor.LIGHT_GRAY;

                             if ((boolean) t_datos.getValueAt(i, 3) == false
                                     && (boolean) t_datos.getValueAt(i, 4) == false
                                     && t_datos.getValueAt(i, 5) != null) {
                                 //columna0
                                 if (t_datos.getValueAt(i, 5) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 5).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna1
                                 if (t_datos.getValueAt(i, 6) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 6).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna2
                                 tabla.addCell(reporte.celda(t_datos.getValueAt(i, renglon).toString(), font,
                                         contenido, centro, 0, 1, Rectangle.RECTANGLE));

                                 //columna3
                                 if (t_datos.getValueAt(i, 14) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 14).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna4
                                 tabla.addCell(reporte.celda(t_datos.getValueAt(i, 2).toString(), font,
                                         contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                                 //columna5
                                 if (renglon == 8 && t_datos.getValueAt(i, 9).toString().compareTo("-") == 0)
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 else {
                                     switch (renglon) {
                                     case 8:
                                         tabla.addCell(reporte.celda("N", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     case 10:
                                         tabla.addCell(reporte.celda("D", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     case 11:
                                         tabla.addCell(reporte.celda("R", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     case 12:
                                         tabla.addCell(reporte.celda("M", font, contenido, centro, 0, 1,
                                                 Rectangle.RECTANGLE));
                                         break;
                                     }
                                 }
                                 //columna6
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(t_datos.getValueAt(i, 15)),
                                         font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                 //columna7 $tot aut.
                                 double n;
                                 n = BigDecimal
                                         .valueOf(Double.parseDouble(t_datos.getValueAt(i, renglon).toString())
                                                 * Double.parseDouble(t_datos.getValueAt(i, 15).toString()))
                                         .setScale(2, RoundingMode.UP).doubleValue();
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font, contenido,
                                         derecha, 0, 1, Rectangle.RECTANGLE));
                                 //columna8
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(t_datos.getValueAt(i, 16)),
                                         font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));

                                 //columna9 $tot com
                                 n = BigDecimal
                                         .valueOf(Double.parseDouble(t_datos.getValueAt(i, renglon).toString())
                                                 * Double.parseDouble(t_datos.getValueAt(i, 16).toString()))
                                         .setScale(2, RoundingMode.UP).doubleValue();
                                 tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font, contenido,
                                         derecha, 0, 1, Rectangle.RECTANGLE));

                                 //columna10 11
                                 if (renglon == 8 && t_datos.getValueAt(i, 9).toString().compareTo("-") == 0) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     switch (renglon) {
                                     case 8:
                                         n = BigDecimal.valueOf(
                                                 Double.parseDouble(t_datos.getValueAt(i, 16).toString()) / 0.9d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     case 10:
                                         n = BigDecimal
                                                 .valueOf(
                                                         Double.parseDouble(t_datos.getValueAt(i, 15).toString())
                                                                 * 0.72d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     case 11:
                                         n = BigDecimal
                                                 .valueOf(
                                                         Double.parseDouble(t_datos.getValueAt(i, 15).toString())
                                                                 * 0.65d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     case 12:
                                         n = BigDecimal
                                                 .valueOf(
                                                         Double.parseDouble(t_datos.getValueAt(i, 15).toString())
                                                                 * 0.65d)
                                                 .setScale(2, RoundingMode.UP).doubleValue();
                                         tabla.addCell(reporte.celda(
                                                 formatoPorcentaje.format(n * Double.parseDouble(
                                                         t_datos.getValueAt(i, renglon).toString())),
                                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         tabla.addCell(reporte.celda(formatoPorcentaje.format(n), font,
                                                 contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                         break;
                                     }
                                 }
                                 //columna12
                                 if (t_datos.getValueAt(i, 18) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 18).toString(), font,
                                             contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                                 }

                                 //columna13
                                 if (t_datos.getValueAt(i, 19) == null) {
                                     tabla.addCell(reporte.celda("", font, contenido, centro, 0, 1,
                                             Rectangle.RECTANGLE));
                                 } else {
                                     tabla.addCell(reporte.celda(t_datos.getValueAt(i, 19).toString(), font,
                                             contenido, centro, 0, 1, Rectangle.RECTANGLE));
                                 }
                                 //columna14
                                 tabla.addCell(
                                         reporte.celda("", font, contenido, centro, 0, 1, Rectangle.RECTANGLE));
                             }
                         }
                     }
                 }
                 tabla.addCell(reporte.celda("Total", font, contenido, derecha, 11, 1, Rectangle.NO_BORDER));
                 tabla.addCell(
                         reporte.celda(formatoPorcentaje.format(Double.parseDouble(total.getValue().toString())),
                                 font, contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                 tabla.addCell(reporte.celda(" ", font, contenido, centro, 3, 1, Rectangle.NO_BORDER));
                 tabla.setHeaderRows(1);
                 reporte.agregaObjeto(tabla);
                 reporte.cerrar();
                 reporte.visualizar2(ruta + ".pdf");
             }
         }
     } catch (Exception e) {
         e.printStackTrace();
     }
 }

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printSignature() {
    try {/*from w ww.  ja  v  a  2s. c om*/
        table = new PdfPTable(2);
        table.setWidthPercentage(100);
        cell = new PdfPCell();
        cell.setBorder(PdfPCell.NO_BORDER);
        table.addCell(cell);
        cell = new PdfPCell(
                new Paragraph(getTran("report.monthly", "signature").toUpperCase() + "\n\n\n\n\n\n\n\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
        cell.setColspan(1);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
        table.addCell(cell);
        doc.add(table);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printActiveDiagnosis(SessionContainerWO sessionContainerWO) {
    try {//from   w ww. j  a  va2s . c  om
        Vector activeProblems = Problem.getActiveProblems(patient.personid);

        if (activeProblems.size() > 0) {
            doc.add(new Paragraph(" "));
            table = new PdfPTable(1);
            table.setWidthPercentage(100);

            // title
            cell = new PdfPCell(new Paragraph(getTran("web.occup", "medwan.common.problemlist").toUpperCase(),
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
            cell.setColspan(1);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
            cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(cell);

            // run thru diagnoses
            Problem activeProblem;
            String value;

            for (int n = 0; n < activeProblems.size(); n++) {
                activeProblem = (Problem) activeProblems.elementAt(n);
                value = MedwanQuery.getInstance().getCodeTran(
                        activeProblem.getCodeType() + "code" + activeProblem.getCode(), sPrintLanguage);
                cell = new PdfPCell(new Paragraph(
                        value + " (" + getTran("Web", "since") + " "
                                + dateFormat.format(activeProblem.getBegin()) + ")",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

                cell.setColspan(1);
                cell.setBorder(PdfPCell.BOX);
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                table.addCell(cell);
            }

            doc.add(table);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printWarnings(SessionContainerWO sessionContainerWO) {
    try {//from w w  w  . j a v a  2 s .  c  o  m
        if (sessionContainerWO.getHealthRecordVO() != null) {
            Collection alerts = MedwanQuery.getInstance().getTransactionsByType(
                    sessionContainerWO.getHealthRecordVO(), IConstants.TRANSACTION_TYPE_ALERT);
            sessionContainerWO.setAlerts(alerts);

            if (sessionContainerWO.getActiveAlerts().size() > 0) {
                doc.add(new Paragraph(" "));
                table = new PdfPTable(4);
                table.setWidthPercentage(100);

                // title
                cell = new PdfPCell(new Paragraph(getTran("curative", "warning.status.title").toUpperCase(),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
                cell.setColspan(4);
                cell.setBorder(PdfPCell.BOX);
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
                cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
                table.addCell(cell);

                // list alerts
                Collection activeAlerts = sessionContainerWO.getActiveAlerts();
                Iterator alertsIter = activeAlerts.iterator();
                TransactionVO transactionVO;
                String sLabel, sComment;
                ItemVO itemVO;

                while (alertsIter.hasNext()) {
                    transactionVO = (TransactionVO) alertsIter.next();

                    // label
                    sLabel = "";
                    itemVO = transactionVO.getItem(IConstants_PREFIX + "ITEM_TYPE_ALERTS_LABEL");
                    if (itemVO != null) {
                        sLabel = checkString(itemVO.getValue());
                    }

                    cell = new PdfPCell(new Paragraph(sLabel, FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                    cell.setColspan(1);
                    cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border
                    cell.setBorderColor(BaseColor.LIGHT_GRAY);
                    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                    table.addCell(cell);

                    // comment
                    sComment = "";
                    itemVO = transactionVO.getItem(IConstants_PREFIX + "ITEM_TYPE_ALERTS_DESCRIPTION");
                    if (itemVO != null) {
                        sComment = checkString(itemVO.getValue());
                    }

                    cell = new PdfPCell(new Paragraph(sComment, FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                    cell.setColspan(4);
                    cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border
                    cell.setBorderColor(BaseColor.LIGHT_GRAY);
                    cell.setVerticalAlignment(PdfPCell.ALIGN_TOP);
                    table.addCell(cell);
                }

                doc.add(table);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printMedication(SessionContainerWO sessionContainerWO) {
    try {/*from  ww  w. ja va2  s  .co m*/
        doc.add(new Paragraph(" "));
        table = new PdfPTable(2);
        table.setWidthPercentage(100);

        // main title
        cell = new PdfPCell(new Paragraph(getTran("curative", "medication.status.title").toUpperCase(),
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0),
                        Font.ITALIC)));
        cell.setColspan(2);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell);

        Vector chronicMedications = ChronicMedication.find(patient.personid, "", "", "", "OC_CHRONICMED_BEGIN",
                "ASC"), activePrescriptions = Prescription.getActivePrescriptions(patient.personid);

        //*** CHRONIC MEDICATION ******************************************
        if (chronicMedications.size() > 0) {
            PdfPTable medicationTable = new PdfPTable(2);

            // sub title
            cell = new PdfPCell(new Paragraph(getTran("curative", "medication.chronic"), FontFactory.getFont(
                    FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
            cell.setColspan(2);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setVerticalAlignment(PdfPCell.ALIGN_LEFT);
            cell.setBackgroundColor(BGCOLOR_LIGHT);
            medicationTable.addCell(cell);

            // run thru medications
            String sPrescrRule, sProductUnit, timeUnitTran;
            ChronicMedication medication;

            for (int n = 0; n < chronicMedications.size(); n++) {
                medication = (ChronicMedication) chronicMedications.elementAt(n);

                sPrescrRule = getTran("web.prescriptions", "prescriptionrule");
                sPrescrRule = sPrescrRule.replaceAll("#unitspertimeunit#",
                        medication.getUnitsPerTimeUnit() + "");

                // productunits
                if (medication.getUnitsPerTimeUnit() == 1) {
                    sProductUnit = getTran("product.unit", medication.getProduct().getUnit());
                } else {
                    sProductUnit = getTran("product.units", medication.getProduct().getUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#productunit#", sProductUnit.toLowerCase());

                // timeunits
                if (medication.getTimeUnitCount() == 1) {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", "");
                    timeUnitTran = getTran("prescription.timeunit", medication.getTimeUnit());
                } else {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", medication.getTimeUnitCount() + "");
                    timeUnitTran = getTran("prescription.timeunits", medication.getTimeUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#timeunit#",
                        timeUnitTran.replaceAll("  ", " ").toLowerCase());

                // product name
                cell = new PdfPCell(new Paragraph(medication.getProduct().getName(),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);

                // prescription rule
                cell = new PdfPCell(new Paragraph(sPrescrRule, FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);
            }

            // add cells to make up with the chronic medications
            if (chronicMedications.size() < activePrescriptions.size()) {
                int missingCellCount = activePrescriptions.size() - chronicMedications.size();
                for (int i = 0; i < missingCellCount; i++) {
                    cell = new PdfPCell();
                    cell.setColspan(2);
                    cell.setBorder(PdfPCell.NO_BORDER);
                    medicationTable.addCell(cell);
                }
            }

            // add chronicmedicationtables to medicationtable
            cell = new PdfPCell(medicationTable);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setPadding(3);
            table.addCell(cell);
        }

        //*** PRESCRIPTIONS ***********************************************
        if (activePrescriptions.size() > 0) {
            PdfPTable medicationTable = new PdfPTable(2);

            // sub title
            cell = new PdfPCell(new Paragraph(getTran("curative", "medication.prescription"),
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 8 * fontSizePercentage / 100.0), Font.ITALIC)));
            cell.setColspan(2);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setVerticalAlignment(PdfPCell.ALIGN_LEFT);
            cell.setBackgroundColor(BGCOLOR_LIGHT);
            medicationTable.addCell(cell);

            // run thru medications
            String sPrescrRule, sProductUnit, timeUnitTran;
            Prescription prescription;
            int n;

            for (n = 0; n < activePrescriptions.size(); n++) {
                prescription = (Prescription) activePrescriptions.elementAt(n);

                sPrescrRule = getTran("web.prescriptions", "prescriptionrule");
                sPrescrRule = sPrescrRule.replaceAll("#unitspertimeunit#",
                        prescription.getUnitsPerTimeUnit() + "");

                // productunits
                if (prescription.getUnitsPerTimeUnit() == 1) {
                    sProductUnit = getTran("product.unit", prescription.getProduct().getUnit());
                } else {
                    sProductUnit = getTran("product.units", prescription.getProduct().getUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#productunit#", sProductUnit.toLowerCase());

                // timeunits
                if (prescription.getTimeUnitCount() == 1) {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#", "");
                    timeUnitTran = getTran("prescription.timeunit", prescription.getTimeUnit());
                } else {
                    sPrescrRule = sPrescrRule.replaceAll("#timeunitcount#",
                            prescription.getTimeUnitCount() + "");
                    timeUnitTran = getTran("prescription.timeunits", prescription.getTimeUnit());
                }
                sPrescrRule = sPrescrRule.replaceAll("#timeunit#", timeUnitTran.toLowerCase());

                // product name
                cell = new PdfPCell(new Paragraph(prescription.getProduct().getName(),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.LEFT + PdfPCell.TOP + PdfPCell.BOTTOM); // no right border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);

                // prescription rule
                cell = new PdfPCell(new Paragraph(sPrescrRule, FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC)));
                cell.setColspan(1);
                cell.setBorder(PdfPCell.RIGHT + PdfPCell.TOP + PdfPCell.BOTTOM); // no left border
                cell.setBorderColor(BaseColor.LIGHT_GRAY);
                medicationTable.addCell(cell);
            }

            // add cells to make up with the active prescriptions
            if (activePrescriptions.size() < chronicMedications.size()) {
                int missingCellCount = chronicMedications.size() - activePrescriptions.size();
                for (int i = 0; i < missingCellCount; i++) {
                    cell = new PdfPCell();
                    cell.setColspan(2);
                    cell.setBorder(PdfPCell.NO_BORDER);
                    medicationTable.addCell(cell);
                }
            }

            // add presciptionssstable to medicationtable
            cell = new PdfPCell(medicationTable);
            cell.setBorder(PdfPCell.BOX);
            cell.setBorderColor(BaseColor.LIGHT_GRAY);
            cell.setPadding(3);
            table.addCell(cell);

            doc.add(table);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:be.mxs.common.util.pdf.general.chuk.GeneralPDFCreator.java

protected void printKeyData(SessionContainerWO sessionContainerWO) {
    try {//from w ww  . j  a  v  a2s .  c om
        doc.add(new Paragraph(" "));
        table = new PdfPTable(15);
        table.setWidthPercentage(100);

        // kernel-data
        cell = new PdfPCell(new Paragraph(getTran("Web.Occup", "medwan.common.kernel-data").toUpperCase(),
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0),
                        Font.ITALIC)));
        cell.setColspan(15);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
        cell.setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(cell);

        // row 1 : last-periodical-examination
        Paragraph par = new Paragraph(
                getTran("Web.Occup", "medwan.common.last-periodical-examination").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        TransactionVO tran = sessionContainerWO.getLastTransaction(IConstants_PREFIX + "TRANSACTION_TYPE_MER");
        ItemVO item;
        if (tran != null) {
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_MER_EXAMINATION_DATE");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }
        cell = new PdfPCell(par);
        cell.setColspan(5);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 1 : next-periodical-examination
        par = new Paragraph(
                getTran("Web.Occup", "medwan.common.next-periodical-examination").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        if (sessionContainerWO.getFlags().getLastExaminationReport() != null && sessionContainerWO.getFlags()
                .getLastExaminationReport().getNewExaminationDueDate() != null) {
            par.add(new Chunk(
                    dateFormat.format(sessionContainerWO.getFlags().getLastExaminationReport()
                            .getNewExaminationDueDate()),
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
        }
        cell = new PdfPCell(par);
        cell.setColspan(5);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 1 : next-driver-examination / Volgend onderzoek medische schifting
        par = new Paragraph(getTran("Web.Occup", "medwan.common.next-driver-examination").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        if (sessionContainerWO.getFlags().getLastDrivingCertificate() != null) {

            // CBMT only : only display newExaminationDueDate if patient has riskcode "070" (drivinglicense)
            boolean riskCode070Found = false;

            if (riskCode070Found) {
                String newExamDueDateMinus = ScreenHelper.checkString(sessionContainerWO.getFlags()
                        .getLastDrivingCertificate().getNewExaminationDueDateMinus());
                if (newExamDueDateMinus.length() > 0) {
                    par.add(new Chunk(newExamDueDateMinus.replaceAll("-", "/"),
                            FontFactory.getFont(FontFactory.HELVETICA,
                                    Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
                }
            }
        } else {
            // no data available
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.no-data"), FontFactory.getFont(
                    FontFactory.HELVETICA, Math.round((double) 8 * fontSizePercentage / 100.0), Font.BOLD)));
        }

        cell = new PdfPCell(par);
        cell.setColspan(5);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Biometrie
        par = new Paragraph(getTran("Web.Occup", "medwan.common.biometry").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeBiometry();
        if (tran != null) {
            // height
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_BIOMETRY_HEIGHT");
            String sHeight = "", sWeight = "";
            if (item != null) {
                sHeight = item.getValue();
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.length") + ": " + sHeight + " cm\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }

            // weight
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_BIOMETRY_WEIGHT");
            if (item != null) {
                sWeight = item.getValue();
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.weight") + ": " + sWeight + " kg\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }

            // BMI
            if (sWeight.length() > 0 && sHeight.length() > 0) {
                try {
                    DecimalFormat deci = new DecimalFormat("0.0");
                    Float bmi = new Float(Float.parseFloat(sWeight.replaceAll(",", ".")) * 10000
                            / (Float.parseFloat(sHeight.replaceAll(",", "."))
                                    * Float.parseFloat(sHeight.replaceAll(",", "."))));
                    par.add(new Chunk("BMI: " + deci.format(bmi), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Urineonderzoek
        par = new Paragraph("URINE\n", FontFactory.getFont(FontFactory.HELVETICA,
                Math.round((double) 7 * fontSizePercentage / 100.0), Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeUrineExamination();
        if (tran != null) {
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_ALBUMINE");
            if (item != null) {
                par.add(new Chunk("Albumine: " + getTran("Web.Occup", item.getValue()) + "\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_GLUCOSE");
            if (item != null) {
                par.add(new Chunk("Glucose: " + getTran("Web.Occup", item.getValue()) + "\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_URINE_BLOOD");
            if (item != null) {
                par.add(new Chunk(
                        getTran("Web.Occup", "medwan.common.blood") + ": "
                                + getTran("Web.Occup", item.getValue()),
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }

        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Audiometrie
        par = new Paragraph(getTran("Web.Occup", "medwan.common.audiometry").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeAudiometry();
        if (tran != null) {
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.mean-hearing-loss").toUpperCase() + "\n",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 6 * fontSizePercentage / 100.0), Font.ITALIC)));
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_AUDIOMETRY_RIGHT_LOSS");
            if (item != null) {
                par.add(new Chunk(
                        getTran("Web.Occup", "medwan.common.right") + ": -" + item.getValue() + " dB\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_AUDIOMETRY_LEFT_LOSS");
            if (item != null) {
                par.add(new Chunk(
                        getTran("Web.Occup", "medwan.common.left") + ": -" + item.getValue() + " dB\n",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }
        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Visus
        par = new Paragraph(
                getTran("Web.Occup", "medwan.common.vision").toUpperCase() + " - "
                        + getTran("Web.Occup",
                                IConstants_PREFIX + "item_type_opthalmology_screen_visiotest_vision_far")
                                        .toUpperCase()
                        + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeOphtalmology();
        if (tran != null) {
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.right-left-binocular").toUpperCase() + "\n",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 6 * fontSizePercentage / 100.0), Font.ITALIC)));
            par.add(new Chunk(getTran("Web.Occup", "medwan.common.without-correction") + ": ",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OD_WITHOUT_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OG_WITHOUT_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_BONI_WITHOUT_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("\n" + getTran("Web.Occup", "medwan.common.with-correction") + ": ",
                    FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OD_WITH_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_OG_WITH_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
            par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                    Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));

            item = tran.getItem(IConstants_PREFIX + "ITEM_TYPE_OPTHALMOLOGY_VISION_BONI_WITH_GLASSES");
            if (item != null) {
                par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }
        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        // row 2 : Bloeddruk
        par = new Paragraph(getTran("Web.Occup", "medwan.common.blood-pressure").toUpperCase() + "\n",
                FontFactory.getFont(FontFactory.HELVETICA, Math.round((double) 7 * fontSizePercentage / 100.0),
                        Font.ITALIC));
        tran = sessionContainerWO.getLastTransactionTypeGeneralClinicalExamination();
        if (tran != null) {
            // right
            ItemVO item1 = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_SYSTOLIC_PRESSURE_RIGHT");
            item = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_DIASTOLIC_PRESSURE_RIGHT");
            if (item1 != null || item != null) {
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.right") + ": ",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                if (item1 != null) {
                    par.add(new Chunk(item1.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                if (item != null) {
                    par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk(" mmHg\n", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }

            // left
            item = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_SYSTOLIC_PRESSURE_LEFT");
            item1 = tran.getItem(
                    IConstants_PREFIX + "ITEM_TYPE_CARDIAL_CLINICAL_EXAMINATION_DIASTOLIC_PRESSURE_LEFT");
            if (item != null || item1 != null) {
                par.add(new Chunk(getTran("Web.Occup", "medwan.common.left") + ": ",
                        FontFactory.getFont(FontFactory.HELVETICA,
                                Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                if (item != null) {
                    par.add(new Chunk(item.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk("/", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.NORMAL)));
                if (item1 != null) {
                    par.add(new Chunk(item1.getValue(), FontFactory.getFont(FontFactory.HELVETICA,
                            Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
                }
                par.add(new Chunk(" mmHg\n", FontFactory.getFont(FontFactory.HELVETICA,
                        Math.round((double) 7 * fontSizePercentage / 100.0), Font.BOLD)));
            }
        }

        cell = new PdfPCell(par);
        cell.setColspan(3);
        cell.setBorder(PdfPCell.BOX);
        cell.setBorderColor(BaseColor.LIGHT_GRAY);
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(cell);

        doc.add(table);
    } catch (Exception e) {
        e.printStackTrace();
    }
}