Example usage for com.itextpdf.text BaseColor BLACK

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

Introduction

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

Prototype

BaseColor BLACK

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

Click Source Link

Usage

From source file:EmployeeInfo.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    String value1 = txt_empID.getText();
    String value2 = txt_firstName.getText();
    String value3 = txt_lastName.getText();
    String value4 = txt_age.getText();

    try {//from   w w  w.  j  ava 2 s  . c  o  m
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Report1.pdf"));
        document.open();
        //add barcode
        PdfContentByte CB = writer.getDirectContent();
        BarcodeEAN codEAN = new BarcodeEAN();
        codEAN.setCode("1234567891023"); //this value must be 13 digits
        Paragraph para = new Paragraph();
        document.add(new Paragraph("Barcode UDCA"));
        codEAN.setCodeType(BarcodeEAN.UPCA);
        codEAN.setCode("1098765432112");
        document.add(codEAN.createImageWithBarcode(CB, BaseColor.BLACK, BaseColor.BLACK));
        document.add(para);

        Image image = Image.getInstance("images/Cherry.png");
        document.add(new Paragraph("Image"));
        document.add(image);

        // write tile with style
        document.add(new Paragraph("Hello World",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED)));
        // write date
        document.add(new Paragraph(new Date().toString()));
        document.add(new Paragraph("--------------------------------------------"));
        PdfPTable table = new PdfPTable(2);// 2 columns
        // set title , column sapn, aliignment,background color
        PdfPCell cell = new PdfPCell(new Paragraph("Title"));
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(BaseColor.BLUE);
        table.addCell(cell);
        // PdfPTable table = new PdfPTable(x); should add multiple of x
        table.addCell("EmployeeID");
        table.addCell(value1);
        table.addCell("Name");
        table.addCell(value2);
        table.addCell("Last Name");
        table.addCell(value3);
        table.addCell("Age");
        table.addCell(value4);
        document.add(table);
        List list = new List(true, 20);
        list.add("First Item");
        list.add("Second Item");
        list.add("Third Item");
        list.add("Fourth Item");
        document.add(list);
        document.close();
        JOptionPane.showMessageDialog(null, "Report saved");
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, e);
    }

}

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 {/*w w  w  .j av a  2  s  .co 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:Almacen.formatosAlmacen.java

private void cabeceraCompra(PDF reporte, BaseFont bf, PdfPTable tabla, Almacen almacen, Orden ord) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from  ww  w  .j  a  v  a2 s  .  c  o m*/
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        if (almacen.getPedido() != null) {
            reporte.contenido.roundRectangle(35, 695, 180, 10, 0);
            reporte.contenido.roundRectangle(35, 625, 180, 80, 0);

            reporte.contenido.roundRectangle(215, 695, 180, 10, 0);
            reporte.contenido.roundRectangle(215, 625, 180, 80, 0);
        }
        reporte.contenido.roundRectangle(395, 695, 180, 10, 0);
        reporte.contenido.roundRectangle(395, 625, 180, 80, 0);

        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 13);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.agregaObjeto(reporte.crearImagen("imagenes/grande300115.jpg", 30, -40, 60));
        reporte.contenido.setFontAndSize(bf, 12);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        if (almacen.getPedido() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Movimiento en almacen: "
                    + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(), 35, 710, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "Movimiento en almacen: " + almacen.getIdAlmacen(), 35, 710, 0);
        reporte.contenido.setFontAndSize(bf, 7);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 570, 710, 0);

        ord = (Orden) session.get(Orden.class, ord.getIdOrden());

        //************************datos del proveedor****************************
        if (almacen.getPedido() != null) {
            DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "DATOS DEL PROVEEDOR", 73, 697, 0);

            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    almacen.getPedido().getProveedorByIdProveedor().getNombre(), 40, 687, 0);

            if (almacen.getPedido().getProveedorByIdProveedor().getDireccion() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        almacen.getPedido().getProveedorByIdProveedor().getDireccion(), 40, 677, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Dir:", 40, 677, 0);

            if (almacen.getPedido().getProveedorByIdProveedor().getColonia() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Col: " + almacen.getPedido().getProveedorByIdProveedor().getColonia(), 40, 667, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Col:", 40, 667, 0);

            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "Edo: " + almacen.getPedido().getProveedorByIdProveedor().getEstado(), 40, 657, 0);

            if (almacen.getPedido().getProveedorByIdProveedor().getTel1() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Tel: " + almacen.getPedido().getProveedorByIdProveedor().getTel1(), 40, 647, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tel:", 40, 647, 0);

            if (almacen.getPedido().getProveedorByIdProveedor().getTel1() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Cto: " + almacen.getPedido().getProveedorByIdProveedor().getRepresentante(), 40, 637,
                        0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Cto:", 40, 637, 0);

            if (almacen.getPedido().getProveedorByIdProveedor().getEmail() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Email: " + almacen.getPedido().getProveedorByIdProveedor().getEmail(), 40, 627, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Email: ", 40, 627, 0);

            //**********************datos de facturacion*****************************
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "DATOS DE FACTURACIN", 250, 697, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    almacen.getPedido().getProveedorByIdEmpresa().getNombre(), 220, 687, 0);
            if (almacen.getPedido().getProveedorByIdEmpresa().getDireccion() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        almacen.getPedido().getProveedorByIdEmpresa().getDireccion(), 220, 677, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Dir:", 220, 677, 0);
            if (almacen.getPedido().getProveedorByIdEmpresa().getColonia() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Col: " + almacen.getPedido().getProveedorByIdEmpresa().getColonia(), 220, 667, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Col:", 220, 667, 0);
            if (almacen.getPedido().getProveedorByIdEmpresa().getPoblacion() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Pob: " + almacen.getPedido().getProveedorByIdEmpresa().getPoblacion(), 220, 657, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Pob:", 220, 657, 0);
            if (almacen.getPedido().getProveedorByIdEmpresa().getCp() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "CP: " + almacen.getPedido().getProveedorByIdEmpresa().getCp(), 220, 647, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "CP:", 220, 647, 0);
            if (almacen.getPedido().getProveedorByIdEmpresa().getRfc() != null)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "RFC: " + almacen.getPedido().getProveedorByIdEmpresa().getRfc(), 220, 637, 0);
            else
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RFC:", 220, 537, 0);
        }
        //**********************datos de la unidad*****************************
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "DATOS LA UNIDAD", 450, 697, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "No Orden: " + ord.getIdOrden(), 410, 687,
                0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo: " + ord.getTipo().getTipoNombre(),
                410, 677, 0);
        if (ord.getNoSerie() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "No Serie: " + ord.getNoSerie(), 410,
                    667, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "No Serie: ", 410, 667, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Modelo: " + ord.getModelo(), 410, 657, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "Compaia: " + ord.getCompania().getNombre(), 410, 647, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Cli:" + ord.getClientes().getNombre(),
                410, 637, 0);
        if (ord.getSiniestro() != null)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "No Siniestro:" + ord.getSiniestro(),
                    410, 627, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "No Siniestro:", 410, 627, 0);

        reporte.finTexto();
        reporte.contenido.setFontAndSize(bf, 12);
        //agregamos renglones vacios para dejar un espacio
        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(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor cabecera = BaseColor.GRAY;
        int centro = Element.ALIGN_CENTER;

        tabla.addCell(reporte.celda("N", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("#", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("N Parte", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Descripcin", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Cant", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Costo c/u", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Total", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));

        reporte.contenido.roundRectangle(50, 40, 180, 1, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Almacen", 120, 30, 0);
        reporte.contenido.roundRectangle(370, 40, 180, 1, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Proveedor", 440, 30, 0);
    } catch (Exception e) {
        System.out.println(e);
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Almacen.formatosOrden.java

private void cabeceraCompra(PDF reporte, BaseFont bf, PdfPTable tabla, Almacen almacen, Orden ord) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from   w  w w.  ja  v  a  2 s . c  om*/
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        reporte.contenido.roundRectangle(35, 755, 280, 10, 0);
        reporte.contenido.roundRectangle(35, 735, 280, 20, 0);
        ////*2
        reporte.contenido.roundRectangle(35, 388, 280, 10, 0);
        reporte.contenido.roundRectangle(35, 368, 280, 20, 0);
        ////         
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 13);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.agregaObjeto(reporte.crearImagen("imagenes/grande300115.jpg", 335, -23, 30));
        /*2*/reporte.agregarImagen(reporte.crearImagen("imagenes/grande300115.jpg", 100, -390, 30));
        reporte.contenido.setFontAndSize(bf, 12);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        if (miAlmacen.getTipoMovimiento() == 1) {
            if (miAlmacen.getOperacion() == 4)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimientos en Almacn (Entrada de Material): " + almacen.getIdAlmacen(), 35, 767, 0);
            if (miAlmacen.getOperacion() == 5)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimientos de Almacn (Devolucin de material de operarios): "
                                + almacen.getIdAlmacen(),
                        35, 767, 0);
            //*********2
            if (miAlmacen.getOperacion() == 4)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimientos en Almacn (Entrada de Material): " + almacen.getIdAlmacen(), 35, 400, 0);
            if (miAlmacen.getOperacion() == 5)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimientos de Almacn (Devolucin de material de operarios): "
                                + almacen.getIdAlmacen(),
                        35, 400, 0);
            ////
        } else {
            if (miAlmacen.getOperacion() == 4)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimiento de Almacn (Devolucin de material a proveedor): "
                                + almacen.getIdAlmacen(),
                        35, 767, 0);
            if (miAlmacen.getOperacion() == 5)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimientos de Almacn (Entrega de material a operarios): " + almacen.getIdAlmacen(),
                        35, 767, 0);
            //*********2
            if (miAlmacen.getOperacion() == 4)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimiento de Almacn (Devolucin de material a proveedor): "
                                + almacen.getIdAlmacen(),
                        35, 400, 0);
            if (miAlmacen.getOperacion() == 5)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimientos de Almacn (Entrega de material a operarios): " + almacen.getIdAlmacen(),
                        35, 400, 0);
            ///
        }

        reporte.contenido.setFontAndSize(bf, 7);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 306, 757, 0);
        /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 306, 390, 0);

        ord = (Orden) session.get(Orden.class, ord.getIdOrden());

        //************************datos de movimiento****************************
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Materiales y Refacciones del Almacn",
                40, 757, 0);
        /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "Materiales y Refacciones del Almacn", 40, 390, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "N. Movimiento: " + almacen.getIdAlmacen(), 40, 747, 0);
        /*2*/ reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "N. Movimiento: " + almacen.getIdAlmacen(), 40, 380, 0);
        if (almacen.getTipoMovimiento() == 1)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Entrada", 120,
                    747, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Salida", 120,
                    747, 0);
        ////**2
        if (almacen.getTipoMovimiento() == 1)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Entrada", 120,
                    380, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Salida", 120,
                    380, 0);
        ////

        if (almacen.getOperacion() == 4)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Compaa", 220,
                    747, 0);
        if (almacen.getOperacion() == 5)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Operarios", 220,
                    747, 0);

        ////**2
        if (almacen.getOperacion() == 4)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Compaa", 220,
                    380, 0);
        if (almacen.getOperacion() == 5)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Operarios", 220,
                    380, 0);
        ////

        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Orden: " + ord.getIdOrden(), 40, 737,
                0);
        /*2*/ reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Orden: " + ord.getIdOrden(),
                40, 370, 0);

        //Firmas de material 
        if (miAlmacen.getTipoMovimiento() == 1) {
            reporte.contenido.roundRectangle(45, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getEntrego(), 45,
                    440, 0);
            reporte.contenido.roundRectangle(250, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 440, 0);
            reporte.contenido.roundRectangle(440, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "RECIBE: " + almacen.getUsuario().getEmpleado().getNombre(), 440, 440, 0);
        } else {
            reporte.contenido.roundRectangle(45, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "ENTREGA: " + almacen.getUsuario().getEmpleado().getNombre(), 45, 440, 0);
            reporte.contenido.roundRectangle(250, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 440, 0);
            reporte.contenido.roundRectangle(440, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getEntrego(), 440,
                    440, 0);
        }

        /*2*/if (miAlmacen.getTipoMovimiento() == 1) {
            reporte.contenido.roundRectangle(45, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getEntrego(), 45,
                    20, 0);
            reporte.contenido.roundRectangle(250, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 20, 0);
            reporte.contenido.roundRectangle(440, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "RECIBE: " + almacen.getUsuario().getEmpleado().getNombre(), 440, 20, 0);
        } else {
            reporte.contenido.roundRectangle(45, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "ENTREGA: " + almacen.getUsuario().getEmpleado().getNombre(), 45, 20, 0);
            reporte.contenido.roundRectangle(250, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 20, 0);
            reporte.contenido.roundRectangle(440, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getEntrego(), 440,
                    20, 0);
        }
        ///
        reporte.finTexto();
        reporte.contenido.setFontAndSize(bf, 12);
        //agregamos renglones vacios para dejar un espacio(tabla)
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor cabecera = BaseColor.GRAY;
        int centro = Element.ALIGN_CENTER;

        tabla.addCell(reporte.celda("N", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("#", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("N Parte", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Descripcin", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Cant", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(null, "No se pudo realizar el reporte si el archivo esta abierto");
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Almacen.formatosPedido.java

private void cabeceraCompra(PDF reporte, BaseFont bf, PdfPTable tabla, Almacen almacen, Orden ord) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/*from  ww w.j  a  v a 2 s  . co m*/
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));
        reporte.contenido.roundRectangle(35, 755, 280, 10, 0);
        reporte.contenido.roundRectangle(35, 735, 280, 20, 0);
        ////*2
        reporte.contenido.roundRectangle(35, 388, 280, 10, 0);
        reporte.contenido.roundRectangle(35, 368, 280, 20, 0);
        ////         
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 13);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.agregaObjeto(reporte.crearImagen("imagenes/grande300115.jpg", 335, -23, 30));
        /*2*/reporte.agregarImagen(reporte.crearImagen("imagenes/grande300115.jpg", 100, -390, 30));//-390//-375
        reporte.contenido.setFontAndSize(bf, 12);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        if (miAlmacen.getTipoMovimiento() == 1) {
            if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3)
                reporte.contenido.showTextAligned(
                        PdfContentByte.ALIGN_LEFT, "Movimiento en Almacn (Entrada de Material): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 767, 0);
            if (miAlmacen.getOperacion() == 5)
                reporte.contenido.showTextAligned(
                        PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Devolucin de ventas): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 767, 0);
            ////*2
            if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3)
                reporte.contenido.showTextAligned(
                        PdfContentByte.ALIGN_LEFT, "Movimiento en Almacn (Entrada de Material): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 400, 0);
            if (miAlmacen.getOperacion() == 6)
                reporte.contenido.showTextAligned(
                        PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Devolucin de ventas): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 400, 0);
            /////
        } else {
            if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimiento de Almacn (Devolucin de material a proveedor): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 767, 0);
            if (miAlmacen.getOperacion() == 6)
                reporte.contenido.showTextAligned(
                        PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Entrega de ventas): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 767, 0);
            ///**2
            if (miAlmacen.getOperacion() == 1 || miAlmacen.getOperacion() == 2 || miAlmacen.getOperacion() == 3)
                reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                        "Movimiento de Almacn (Devolucin de material a proveedor): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 400, 0);
            if (miAlmacen.getOperacion() == 6)
                reporte.contenido.showTextAligned(
                        PdfContentByte.ALIGN_LEFT, "Movimientos de Almacn (Entrega de ventas): "
                                + almacen.getIdAlmacen() + " Pedido:" + almacen.getPedido().getIdPedido(),
                        35, 400, 0);
            ///
        }

        reporte.contenido.setFontAndSize(bf, 7);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 306, 757, 0);
        /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 306, 390, 0);
        if (ord != null)
            ord = (Orden) session.get(Orden.class, ord.getIdOrden());

        //************************datos de movimiento****************************
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");//YYYY-MM-DD HH:MM:SS
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Materiales y Refacciones del Almacn",
                40, 757, 0);
        /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "Materiales y Refacciones del Almacn", 40, 390, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "N. Movimiento: " + almacen.getIdAlmacen(), 40, 747, 0);
        /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                "N. Movimiento: " + almacen.getIdAlmacen(), 40, 380, 0);
        if (almacen.getTipoMovimiento() == 1)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Entrada", 120,
                    747, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Salida", 120,
                    747, 0);
        ////2
        if (almacen.getTipoMovimiento() == 1)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Entrada", 120,
                    380, 0);
        else
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Movimiento : Salida", 120,
                    380, 0);
        ////
        if (almacen.getOperacion() == 1)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido", 220,
                    747, 0);
        if (almacen.getOperacion() == 2)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido E.", 220,
                    747, 0);
        if (almacen.getOperacion() == 3)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido A.", 220,
                    747, 0);
        if (almacen.getOperacion() == 6)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Venta", 220, 747,
                    0);
        ////2
        if (almacen.getOperacion() == 1)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido", 220,
                    380, 0);
        if (almacen.getOperacion() == 2)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido E.", 220,
                    380, 0);
        if (almacen.getOperacion() == 3)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Pedido A.", 220,
                    380, 0);
        if (almacen.getOperacion() == 6)
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "Tipo de Operacin : Venta", 220, 380,
                    0);
        ////
        if (ord != null) {
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Orden: " + ord.getIdOrden(), 40,
                    737, 0);
            /*2*/reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "N. Orden: " + ord.getIdOrden(),
                    40, 370, 0);
        }

        //Firmas de material 
        if (miAlmacen.getTipoMovimiento() == 1) {
            reporte.contenido.roundRectangle(45, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getEntrego(), 45,
                    440, 0);
            reporte.contenido.roundRectangle(250, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 440, 0);
            reporte.contenido.roundRectangle(440, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "RECIBE: " + almacen.getUsuario().getEmpleado().getNombre(), 440, 440, 0);
        } else {
            reporte.contenido.roundRectangle(45, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "ENTREGA: " + almacen.getUsuario().getEmpleado().getNombre(), 45, 440, 0);
            reporte.contenido.roundRectangle(250, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 440, 0);
            reporte.contenido.roundRectangle(440, 450, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getEntrego(), 440,
                    440, 0);
        }

        ///2
        if (miAlmacen.getTipoMovimiento() == 1) {
            reporte.contenido.roundRectangle(45, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "ENTREGA: " + almacen.getEntrego(), 45,
                    20, 0);
            reporte.contenido.roundRectangle(250, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 20, 0);
            reporte.contenido.roundRectangle(440, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "RECIBE: " + almacen.getUsuario().getEmpleado().getNombre(), 440, 20, 0);
        } else {
            reporte.contenido.roundRectangle(45, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "ENTREGA: " + almacen.getUsuario().getEmpleado().getNombre(), 45, 20, 0);
            reporte.contenido.roundRectangle(250, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "AUTORIZA: ", 250, 20, 0);
            reporte.contenido.roundRectangle(440, 30, 130, 1, 0);
            reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, "RECIBE: " + almacen.getEntrego(), 440,
                    20, 0);
        }
        ///

        reporte.finTexto();
        reporte.contenido.setFontAndSize(bf, 12);
        //agregamos renglones vacios para dejar un espacio(tabla)
        reporte.agregaObjeto(new Paragraph(" "));
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor cabecera = BaseColor.GRAY;
        int centro = Element.ALIGN_CENTER;

        tabla.addCell(reporte.celda("N", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("#", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("N Parte", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Descripcin", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Med", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        tabla.addCell(reporte.celda("Cant", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        if (tabla.getNumberOfColumns() > 6) {
            tabla.addCell(reporte.celda("Costo c/u", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda("Total", font, cabecera, centro, 0, 1, Rectangle.RECTANGLE));
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Almacen.Reporte2.java

public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//  ww w  .j  av  a 2 s  . c  o  m
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));

        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 35, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        String titulo = titulo1;
        if (op == 1) {
            if (t_fecha1.getText().compareTo("AAAA-MM-DD") != 0)
                titulo += " del " + t_fecha1.getText();
            if (t_fecha2.getText().compareTo("AAAA-MM-DD") != 0)
                titulo += " al " + t_fecha2.getText();
        }
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 745, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 570, 745, 0);

        reporte.finTexto();
        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);

        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        if (op == 1) {
            for (int a = 0; a < tabla.getNumberOfColumns(); a++) {
                tabla.addCell(reporte.celda(t_datos.getColumnName(a), font, cabecera, centro, 0, 1,
                        Rectangle.RECTANGLE));
            }
        }
        if (op == 2) {
            for (int a = 0; a < tabla.getNumberOfColumns(); a++) {
                tabla.addCell(reporte.celda(t_datos1.getColumnName(a), font, cabecera, centro, 0, 1,
                        Rectangle.RECTANGLE));
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Almacen.Reporte2.java

public void cabecera1(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {/* ww  w  . j a v  a 2  s .  c o  m*/
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));

        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 35, 755, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        String titulo = titulo1;

        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 745, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 570, 745, 0);

        reporte.finTexto();
        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);

        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;

        for (int a = 0; a < tabla.getNumberOfColumns(); a++) {
            tabla.addCell(reporte.celda(t_datos2.getColumnName(a), font, cabecera, centro, 0, 1,
                    Rectangle.RECTANGLE));
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:AppPackage.printPDF.java

public void printNow(String id, String name, String dateRange, String underLate, String workedHours,
        String totalHours, String dateNow, String fDate, String lDate, String type, String empTypeRate,
        int lastRId, double salary) {
    this.id = id;
    this.name = name;
    this.dateRange = dateRange;
    this.underLate = underLate;
    this.workedHours = workedHours;
    this.totalHours = totalHours;
    this.dateNow = dateNow;
    this.fDate = fDate;
    this.lDate = lDate;
    this.type = type;
    this.empTypeRate = empTypeRate;
    this.lastRId = lastRId;
    this.salary = salary;
    try {//from  w w w.  j a  v a2s .  c o m

        Document document = new Document();
        Connection conn = null;
        Statement st = null;
        conn = dbC.getConnection();
        st = conn.createStatement();

        String query = "SELECT * FROM schedule WHERE empId ='" + id + "'";
        ResultSet rs = st.executeQuery(query);

        PdfWriter.getInstance(document,
                new FileOutputStream("reports/Report-" + reportCount + "." + lastRId + "-" + id + ".pdf"));
        document.open();
        document.setPageSize(PageSize.LETTER);
        document.setMargins(0f, 0f, 0f, 0f);

        Image image = Image.getInstance("Resources/DTRHeaderTwo.png");
        document.add(image);

        PdfPTable ICTable = new PdfPTable(5);
        ICTable.setWidthPercentage(100);

        ICTable.getDefaultCell().setBorder(0);
        //create a cell object
        PdfPCell ICTableCell;

        Phrase ICBlank = new Phrase();
        Phrase ICharge = new Phrase();
        Phrase ICBlanko = new Phrase();
        Phrase ICBlankx = new Phrase();
        Phrase IChargex = new Phrase();

        ICBlank.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        ICTable.addCell(ICBlank);
        ICharge.add(new Chunk("_____________________", new Font(Font.FontFamily.HELVETICA, 8, Font.ITALIC)));
        ICTable.addCell(ICharge);
        ICBlanko.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        ICTable.addCell(ICBlanko);
        ICBlankx.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        ICTable.addCell(ICBlankx);
        IChargex.add(new Chunk("____________________", new Font(Font.FontFamily.HELVETICA, 8, Font.ITALIC)));
        ICTable.addCell(IChargex);

        ICTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        ICTableCell.setBorder(PdfPCell.NO_BORDER);
        ICTable.addCell(ICTableCell);
        ICTableCell = new PdfPCell(
                new Phrase("In - Charge", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        ICTableCell.setBorder(PdfPCell.NO_BORDER);
        ICTable.addCell(ICTableCell);
        ICTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        ICTableCell.setBorder(PdfPCell.NO_BORDER);
        ICTable.addCell(ICTableCell);

        ICTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        ICTableCell.setBorder(PdfPCell.NO_BORDER);
        ICTable.addCell(ICTableCell);
        ICTableCell = new PdfPCell(
                new Phrase("In - Charge", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        ICTableCell.setBorder(PdfPCell.NO_BORDER);
        ICTable.addCell(ICTableCell);

        PdfPTable dateRecTable = new PdfPTable(5);
        dateRecTable.setWidthPercentage(100);

        dateRecTable.getDefaultCell().setBorder(0);
        //create a cell object
        PdfPCell dateRecTableCell;

        Phrase dRDate = new Phrase();
        Phrase dRNo = new Phrase();
        Phrase dRBlank = new Phrase();
        Phrase dRDatex = new Phrase();
        Phrase dRNox = new Phrase();

        dRDate.add(
                new Chunk("Released #: " + lastRId + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        dateRecTable.addCell(dRDate);
        dRNo.add(new Chunk("" + dateNow + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        dateRecTable.addCell(dRNo);
        dRBlank.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        dateRecTable.addCell(dRBlank);
        dRDatex.add(
                new Chunk("Released #: " + lastRId + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        dateRecTable.addCell(dRDatex);
        dRNox.add(new Chunk("" + dateNow + "", new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC)));
        dateRecTable.addCell(dRNox);

        PdfPTable InfoTable = new PdfPTable(5);
        InfoTable.setWidthPercentage(100);

        InfoTable.getDefaultCell().setBorder(0);
        //create a cell object
        PdfPCell InfoTableCell;

        Phrase infoId = new Phrase();
        Phrase infoType = new Phrase();
        Phrase infoBlank = new Phrase();
        Phrase infoIdx = new Phrase();
        Phrase infoTypex = new Phrase();

        infoId.add(new Chunk("ID: " + id + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTable.addCell(infoId);
        infoType.add(new Chunk("Type: " + type + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTable.addCell(infoType);
        infoBlank.add(new Chunk("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTable.addCell(infoBlank);
        infoIdx.add(new Chunk("ID: " + id + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTable.addCell(infoIdx);
        infoTypex.add(new Chunk("Type: " + type + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTable.addCell(infoTypex);

        InfoTableCell = new PdfPCell(
                new Phrase("Fullname: " + name + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("Hourly Rate: " + empTypeRate + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(
                new Phrase("Fullname: " + name + "", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("Hourly Rate: " + empTypeRate + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(new Phrase("Date Range: \n" + dateRange + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("Total Hours: " + totalHours + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(new Phrase("Date Range: \n" + dateRange + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("Total Hours: " + totalHours + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(new Phrase("Late & Under Time: " + underLate + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("Worked Hours: " + workedHours + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(new Phrase("Late & Under Time: " + underLate + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("Worked Hours: " + workedHours + "",
                new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(
                new Phrase("Salary: " + salary + " PHP", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        InfoTableCell = new PdfPCell(
                new Phrase("Salary: " + salary + " PHP", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);
        InfoTableCell = new PdfPCell(new Phrase("", new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL)));
        InfoTableCell.setBorder(PdfPCell.NO_BORDER);
        InfoTable.addCell(InfoTableCell);

        PdfPTable SchedTable = new PdfPTable(17);
        SchedTable.setWidthPercentage(100);

        SchedTable.getDefaultCell().setBorder(0);
        //create a cell object
        PdfPCell SchedTableCell;

        Phrase phraseDayS = new Phrase();
        Phrase phraseAMTotal = new Phrase();
        Phrase phraseAMStart = new Phrase();
        Phrase phraseAMEnd = new Phrase();
        Phrase phrasePMTotal = new Phrase();
        Phrase phrasePMStart = new Phrase();
        Phrase phrasePMEnd = new Phrase();
        Phrase phraseTotalTime = new Phrase();
        Phrase phraseBlankS = new Phrase();
        Phrase phraseDaySx = new Phrase();
        Phrase phraseAMTotalx = new Phrase();
        Phrase phraseAMStartx = new Phrase();
        Phrase phraseAMEndx = new Phrase();
        Phrase phrasePMTotalx = new Phrase();
        Phrase phrasePMStartx = new Phrase();
        Phrase phrasePMEndx = new Phrase();
        Phrase phraseTotalTimex = new Phrase();

        phraseDayS.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseDayS);
        phraseAMStart.add(new Chunk("AM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseAMStart);
        phraseAMEnd.add(new Chunk("AM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseAMEnd);
        phraseAMTotal.add(new Chunk("AM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseAMTotal);
        phrasePMStart.add(new Chunk("PM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phrasePMStart);
        phrasePMEnd.add(new Chunk("PM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phrasePMEnd);
        phrasePMTotal.add(new Chunk("PM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phrasePMTotal);
        phraseTotalTime.add(new Chunk("Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseTotalTime);
        phraseBlankS.add(new Chunk("           ", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseBlankS);

        phraseDaySx.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseDaySx);
        phraseAMStartx.add(new Chunk("AM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseAMStartx);
        phraseAMEndx.add(new Chunk("AM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseAMEndx);
        phraseAMTotalx.add(new Chunk("AM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseAMTotalx);
        phrasePMStartx.add(new Chunk("PM Start", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phrasePMStartx);
        phrasePMEndx.add(new Chunk("PM End", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phrasePMEndx);
        phrasePMTotalx.add(new Chunk("PM Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phrasePMTotalx);
        phraseTotalTimex.add(new Chunk("Total", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        SchedTable.addCell(phraseTotalTimex);

        while (rs.next()) {
            SimpleDateFormat readingFormat = new SimpleDateFormat("HH:mm:ss");
            SimpleDateFormat outputFormat = new SimpleDateFormat("hh:mm a");
            String dayxxx = rs.getString("day");
            String amStartxx = rs.getString("amStart");
            String amEndxx = rs.getString("amEnd");
            String pmStartxx = rs.getString("pmStart");
            String pmEndxx = rs.getString("pmEnd");
            String amTotalxx = rs.getString("amTotal");
            String pmTotalxx = rs.getString("pmTotal");
            String totalHoursxx = rs.getString("totalTime");
            String blank = "          ";

            String amStart = null;
            String amEnd = null;
            String amTotal = null;
            String pmStart = null;
            String pmEnd = null;
            String pmTotal = null;
            String totalHoursx = null;

            Date dayx = new SimpleDateFormat("EEEE").parse(dayxxx);
            SimpleDateFormat sdfxxx = new SimpleDateFormat("EEE");
            String day = sdfxxx.format(dayx);
            System.out.println(day + " day");

            try {
                Date amStartTxx = readingFormat.parse(amStartxx);
                amStart = outputFormat.format(amStartTxx);
                if (amStart.equals("12:00 AM")) {
                    amStart = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                Date amEndTx = readingFormat.parse(amEndxx);
                amEnd = outputFormat.format(amEndTx);
                if (amEnd.equals("12:00 AM")) {
                    amEnd = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                Date amTotalTx = readingFormat.parse(amTotalxx);
                amTotal = outputFormat.format(amTotalTx);
                if (amTotal.equals("12:00 AM")) {
                    amTotal = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                Date pmStartTxx = readingFormat.parse(pmStartxx);
                pmStart = outputFormat.format(pmStartTxx);
                if (pmStart.equals("12:00 AM")) {
                    pmStart = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                Date pmEndTxx = readingFormat.parse(pmEndxx);
                pmEnd = outputFormat.format(pmEndTxx);
                if (pmEnd.equals("12:00 AM")) {
                    pmEnd = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                Date pmTotalTxx = readingFormat.parse(pmTotalxx);
                pmTotal = outputFormat.format(pmTotalTxx);
                if (pmTotal.equals("12:00 AM")) {
                    pmTotal = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                Date totalHoursxT = readingFormat.parse(totalHoursxx);
                totalHoursx = outputFormat.format(totalHoursxT);
                if (totalHoursx.equals("12:00 AM")) {
                    totalHoursx = "00:00";
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(day);
            System.out.println(amStart);
            System.out.println(amEnd);
            System.out.println(amTotal);
            System.out.println(pmStart);
            System.out.println(pmEnd);
            System.out.println(pmTotal);
            System.out.println(totalHoursx);

            SchedTableCell = new PdfPCell(new Phrase(day, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(amStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(amEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(amTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(pmStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(pmEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(pmTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(totalHoursx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(new Phrase(blank));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(new Phrase(day, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(amStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(amEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(amTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(pmStart, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(pmEnd, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(pmTotal, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

            SchedTableCell = new PdfPCell(
                    new Phrase(totalHoursx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
            SchedTableCell.setBorder(PdfPCell.NO_BORDER);
            SchedTable.addCell(SchedTableCell);

        }

        PdfPTable DTRTable = new PdfPTable(17);
        DTRTable.setWidthPercentage(100);

        DTRTable.getDefaultCell().setBorder(0);
        //create a cell object
        PdfPCell DTRTableCell;

        Phrase phraseDay = new Phrase();
        Phrase phraseDate = new Phrase();
        Phrase phraseAMIn = new Phrase();
        Phrase phraseAMOut = new Phrase();
        Phrase phrasePMIn = new Phrase();
        Phrase phrasePMOut = new Phrase();
        Phrase phraseHours = new Phrase();
        Phrase phraseUTL = new Phrase();
        Phrase phraseBlank = new Phrase();
        Phrase phraseDayx = new Phrase();
        Phrase phraseDatex = new Phrase();
        Phrase phraseAMInx = new Phrase();
        Phrase phraseAMOutx = new Phrase();
        Phrase phrasePMInx = new Phrase();
        Phrase phrasePMOutx = new Phrase();
        Phrase phraseHoursx = new Phrase();
        Phrase phraseUTLx = new Phrase();

        phraseDay.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseDay);
        phraseDate.add(new Chunk("Date", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseDate);
        phraseAMIn.add(new Chunk("AM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseAMIn);
        phraseAMOut.add(new Chunk("AM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseAMOut);
        phrasePMIn.add(new Chunk("PM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phrasePMIn);
        phrasePMOut.add(new Chunk("PM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phrasePMOut);
        phraseHours.add(new Chunk("Hours", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseHours);
        phraseUTL.add(new Chunk("Late/U.T", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseUTL);
        phraseBlank.add(new Chunk("           ", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseBlank);

        phraseDayx.add(new Chunk("Day", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseDayx);
        phraseDatex.add(new Chunk("Date", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseDatex);
        phraseAMInx.add(new Chunk("AM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseAMInx);
        phraseAMOutx.add(new Chunk("AM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseAMOutx);
        phrasePMInx.add(new Chunk("PM IN", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phrasePMInx);
        phrasePMOutx.add(new Chunk("PM OUT", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phrasePMOutx);
        phraseHoursx.add(new Chunk("Hours", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseHoursx);
        phraseUTLx.add(new Chunk("Late/U.T", new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD)));
        DTRTable.addCell(phraseUTLx);

        try {
            Connection connx = null;
            Statement stx = null;
            connx = dbC.getConnection();
            stx = connx.createStatement();

            String queryx = "SELECT timeinout.day, timeinout.date, schedule.totalTime, schedule.amTotal, "
                    + "schedule.amStart, timeinout.amTimeIn, schedule.amEnd, timeinout.amTimeOut, "
                    + "schedule.pmTotal, schedule.pmStart, timeinout.pmTimeIn, schedule.pmEnd, "
                    + "timeinout.pmTimeOut FROM timeinout LEFT JOIN "
                    + "(schedule) ON (schedule.empId = timeinout.empId AND timeinout.day = schedule.day) WHERE  "
                    + "timeinout.empId ='" + id + "' AND  schedule.empId = '" + id + "' AND date(`Date`) >= '"
                    + fDate + "' " + "AND date(`Date`) <= '" + lDate + "'";
            ResultSet rsx = stx.executeQuery(queryx);
            while (rsx.next()) {
                String day = rsx.getString("timeinout.day");
                String date = rsx.getString("timeinout.date");
                String amStartDB = rsx.getString("schedule.amStart");
                String amIn = rsx.getString("timeinout.amTimeIn");
                String amEndDB = rsx.getString("schedule.amEnd");
                String amOut = rsx.getString("timeinout.amTimeOut");
                String pmStartDB = rsx.getString("schedule.pmStart");
                String pmIn = rsx.getString("timeinout.pmTimeIn");
                String pmEndDB = rsx.getString("schedule.pmEnd");
                String pmOut = rsx.getString("timeinout.pmTimeOut");
                String totTime = rsx.getString("schedule.totalTime");
                String wHours;
                String blank = "           ";
                String dayx = rsx.getString("timeinout.day");
                String datex = rsx.getString("timeinout.date");
                //                String amStartDBx = rsx.getString("schedule.amStart");
                //                String amInx = rsx.getString("timeinout.amTimeIn");
                //                String amEndDBx = rsx.getString("schedule.amEnd");
                //                String amOutx = rsx.getString("timeinout.amTimeOut");
                //                String pmStartDBx = rsx.getString("schedule.pmStart");
                //                String pmInx = rsx.getString("timeinout.pmTimeIn");
                //                String pmEndDBx = rsx.getString("schedule.pmEnd");
                String pmOutx = rsx.getString("timeinout.pmTimeOut");
                String totalAM = rsx.getString("schedule.amTotal");
                String totalPM = rsx.getString("schedule.pmTotal");
                String totTimex = rsx.getString("schedule.totalTime");
                String wHoursx;

                parser.setTimeZone(TimeZone.getTimeZone("UTC"));

                if (!amEndDB.equals("00:00:00") && !amOut.equals("00:00:00")) {
                    Start = parser.parse(amEndDB);
                    In = parser.parse(amOut);
                    if (Start.after(In)) {
                        amOutDiff = tDiff.timeDiff(amOut, amEndDB);

                        amOutDiffT = parser.parse(amOutDiff);
                        amOutDiffTotal += amOutDiffT.getTime();

                    } else {
                        amOutDiff = "00:00:00";
                    }
                } else {
                    amOutDiff = totalAM;
                    amOutDiffT = parser.parse(amOutDiff);
                    amOutDiffTotal += amOutDiffT.getTime();
                }

                Start = parser.parse(amStartDB);
                In = parser.parse(amIn);
                if (Start.after(In)) {
                    amInDiff = "00:00:00";
                } else if (amOutDiff.equals(totalAM)) {
                    amInDiff = "00:00:00";
                } else {
                    amInDiff = tDiff.timeDiff(amStartDB, amIn);

                    amInDiffT = parser.parse(amInDiff);
                    amInDiffTotal += amInDiffT.getTime();

                }
                if (!pmEndDB.equals("00:00:00") && !pmOut.equals("00:00:00")) {
                    Start = parser.parse(pmEndDB);
                    In = parser.parse(pmOut);
                    if (Start.after(In)) {
                        pmOutDiff = tDiff.timeDiff(pmOut, pmEndDB);

                        pmOutDiffT = parser.parse(pmOutDiff);
                        pmOutDiffTotal += pmOutDiffT.getTime();

                    } else {
                        pmOutDiff = "00:00:00";
                    }
                } else {
                    pmOutDiff = totalPM;
                    pmOutDiffT = parser.parse(pmOutDiff);
                    pmOutDiffTotal += pmOutDiffT.getTime();
                }

                Start = parser.parse(pmStartDB);
                In = parser.parse(pmIn);
                if (Start.after(In)) {
                    pmInDiff = "00:00:00";
                } else if (pmOutDiff.equals(totalPM)) {
                    pmInDiff = "00:00:00";
                } else {
                    pmInDiff = tDiff.timeDiff(pmStartDB, pmIn);

                    pmInDiffT = parser.parse(pmInDiff);
                    pmInDiffTotal += pmInDiffT.getTime();

                }

                Date totH = parser.parse(totTimex);
                long totHTotal = 0;
                totHTotal += totH.getTime();

                Date amInDiffx = parser.parse(amInDiff);
                Date amOutDiffx = parser.parse(amOutDiff);
                Date pmInDiffx = parser.parse(pmInDiff);
                Date pmOutDiffx = parser.parse(pmOutDiff);

                long workedHoursxxx = amInDiffx.getTime() + amOutDiffx.getTime() + pmInDiffx.getTime()
                        + pmOutDiffx.getTime();

                long hoursx = workedHoursxxx / 3600000;
                long minutesx = (workedHoursxxx % 3600000) / 60000;

                wHours = String.format("%02d:%02d", hoursx, minutesx);
                wHoursx = String.format("%02d:%02d", hoursx, minutesx);

                Date dayxxx = new SimpleDateFormat("EEEE").parse(day);
                SimpleDateFormat sdfxxx = new SimpleDateFormat("EEE");
                String newDayxx = sdfxxx.format(dayxxx);
                System.out.println(newDayxx);
                DTRTableCell = new PdfPCell(
                        new Phrase(newDayxx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                Date datexx = new SimpleDateFormat("yyyy-MM-dd").parse(date);
                SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy");
                String newDate = sdf.format(datexx);
                System.out.println(newDate);
                DTRTableCell = new PdfPCell(
                        new Phrase(newDate, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(amIn);
                DTRTableCell = new PdfPCell(
                        new Phrase(amIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(amOut);
                DTRTableCell = new PdfPCell(
                        new Phrase(amOut, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(pmIn);
                DTRTableCell = new PdfPCell(
                        new Phrase(pmIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(pmOut);
                DTRTableCell = new PdfPCell(
                        new Phrase(pmOut, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(totTime);
                DTRTableCell = new PdfPCell(
                        new Phrase(totTime, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(wHours);
                DTRTableCell = new PdfPCell(
                        new Phrase(wHours, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(blank);
                DTRTableCell = new PdfPCell(new Phrase(blank));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                Date dayxx = new SimpleDateFormat("EEEE").parse(dayx);
                SimpleDateFormat sdfxx = new SimpleDateFormat("EEE");
                String newDayx = sdfxx.format(dayxx);
                System.out.println(newDayx);
                DTRTableCell = new PdfPCell(
                        new Phrase(newDayx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                Date datexxx = new SimpleDateFormat("yyyy-MM-dd").parse(datex);
                SimpleDateFormat sdfx = new SimpleDateFormat("dd-MM-yy");
                String newDatex = sdfx.format(datexxx);
                System.out.println(newDatex);
                DTRTableCell = new PdfPCell(
                        new Phrase(newDatex, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(amIn);
                DTRTableCell = new PdfPCell(
                        new Phrase(amIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(amOut);
                DTRTableCell = new PdfPCell(
                        new Phrase(amOut, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(pmIn);
                DTRTableCell = new PdfPCell(
                        new Phrase(pmIn, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(pmOutx);
                DTRTableCell = new PdfPCell(
                        new Phrase(pmOutx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(totTimex);
                DTRTableCell = new PdfPCell(
                        new Phrase(totTimex, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

                System.out.println(wHoursx);
                DTRTableCell = new PdfPCell(
                        new Phrase(wHoursx, new Font(Font.FontFamily.HELVETICA, 6, Font.NORMAL)));
                DTRTableCell.setBorder(PdfPCell.NO_BORDER);
                DTRTable.addCell(DTRTableCell);

            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }
        document.add(dateRecTable);
        document.add(InfoTable);
        document.add(new Paragraph(
                "-----------------------------------------------------------------------               ----------------------------------------------------------------------",
                FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD, BaseColor.BLACK)));
        document.add(new Paragraph(
                "                                   Schedule                                                                                     Schedule\n",
                FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK)));
        document.add(SchedTable);
        document.add(new Paragraph(
                "-----------------------------------------------------------------------               ----------------------------------------------------------------------",
                FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD, BaseColor.BLACK)));
        document.add(new Paragraph(
                "                             Dailty Time Record                                                                     Dailty Time Record\n",
                FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL, BaseColor.BLACK)));
        document.add(DTRTable);
        document.add(ICTable);

        try {
            conn = dbC.getConnection();

            PreparedStatement stmtx = conn.prepareStatement("INSERT INTO released"
                    + "(empId, firstDate, lastDate, totalHours, lateUnderTime, workedHours, fileName, salary) VALUES (?,?,?,?,?,?,?,?)");

            stmtx.setString(1, id);
            stmtx.setString(2, fDate);
            stmtx.setString(3, lDate);
            stmtx.setString(4, totalHours);
            stmtx.setString(5, workedHours);
            stmtx.setString(6, totalHours);
            stmtx.setString(7, "Report-" + reportCount + "." + lastRId + "-" + id + ".pdf");
            stmtx.setString(8, salary + "");

            stmtx.executeUpdate();

        } catch (SQLException se) {
            //Handle errors for JDBC
            se.printStackTrace();
        } catch (Exception e) {
            //Handle errors for Class.forName
            e.printStackTrace();
        } finally {
            //finally block used to close resources
            try {
                if (stmt != null)
                    conn.close();
            } catch (SQLException se) {
            } // do nothing
            try {
                if (conn != null)
                    conn.close();
            } catch (SQLException se) {
                se.printStackTrace();
            } //end finally try
        } //end try
        document.close();
    } catch (DocumentException | IOException | SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    } catch (ParseException ex) {
        Logger.getLogger(printPDF.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:be.rheynaerde.poolsheets.AbstractPoolSheet.java

License:Open Source License

protected BaseColor getSolidCellColor() {
    return BaseColor.BLACK;
}

From source file:bemyguest.controller.ValidationResevation.java

@FXML
private void handleButtonValiderAction(ActionEvent event) throws FileNotFoundException, DocumentException {
    Resrevation e = tab_reservation.getSelectionModel().getSelectedItem();
    if (e == null) {

        Alert alert = new Alert(Alert.AlertType.WARNING);
        alert.setTitle("Warning Dialog");
        alert.setHeaderText(null);/*  ww w. j ava  2 s  .co  m*/
        alert.setContentText("selectionner un demande de  reservation a traiter svp!");

        alert.showAndWait();
        LoadData();
        setCellTable();
    }

    else {
        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
        alert.setTitle("Confiramtion");
        alert.setHeaderText(null);
        alert.setContentText("vous etes sur d'accepter cette demande de reservation");
        Optional<ButtonType> answer = alert.showAndWait();

        if (answer.get() == ButtonType.OK) {
            ResevationDAO dao = new ResevationDAO();
            if (dao.ajouter_Reservation(e)) {

                LoadData();
                setCellTable();

                alert.setTitle("Success Dialog");
                alert.setHeaderText(null);
                alert.setContentText("Demandes accepter avec success");

                alert.showAndWait();

                try {

                    Document d = new Document(PageSize.A4.rotate());
                    PdfWriter.getInstance(d, new FileOutputStream(e.getUser().getNom() + "Facture.pdf"));
                    d.open();

                    d.add(new Paragraph("BeMyGuest Facture :",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED)));
                    d.add(new Paragraph(new Date().toString()));
                    d.add(new Paragraph(
                            "-------------------------------------------------------------------------------------------------------------"));
                    d.add(new Paragraph("             "));
                    d.add(new Paragraph("             "));
                    PdfPTable pdt = new PdfPTable(7);
                    PdfPCell cell = new PdfPCell(new Paragraph("Composant de facture"));
                    cell.setColspan(7);
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    cell.setBackgroundColor(BaseColor.RED);
                    pdt.addCell(cell);

                    pdt.addCell(new Paragraph("Nom:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Prenom:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Date Debut:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Date Fin:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("nbre chambre:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("nbre personne:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph("Prix:",
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getUserDemandant().getNom(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getUserDemandant().getPrenom(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getDateDebut().toString(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(e.getDateFin().toString(),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(e.getDateDebut().toString());

                    int nb = e.getPropriete().getNbrChambre();

                    float pr = e.getPropriete().getPrix();
                    int nbp = e.getPropriete().getNbrVoyageur();
                    pdt.addCell(new Paragraph(Integer.toString(nb),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(Integer.toString(nbp),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));
                    pdt.addCell(new Paragraph(Float.toString(pr),
                            FontFactory.getFont(FontFactory.TIMES_BOLD, 8, Font.BOLD, BaseColor.BLACK)));

                    pdt.addCell(Float.toString(pr));

                    d.add(pdt);
                    d.close();
                } catch (Exception b) {

                    JOptionPane.showMessageDialog(null, b);
                }
            } else {
                alert.setTitle("Error Dialog");
                alert.setHeaderText(null);
                alert.setContentText("Cette Propriete Reserver pendant cette date ");

                alert.showAndWait();

                LoadData();
                setCellTable();
            }
        }

        else {
            LoadData();
            setCellTable();
        }
    }

}