Example usage for com.itextpdf.text Font BOLD

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

Introduction

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

Prototype

int BOLD

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

Click Source Link

Document

this is a possible style.

Usage

From source file:login.DigiHoInitial.java

private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
    // TODO add your handling code here:
    Calendar timer = Calendar.getInstance();
    timer.getTime();//from w w w.j a v a  2 s.  c  o  m
    SimpleDateFormat Tdate = new SimpleDateFormat("dd-MMM-yyy");
    jTextField17.setText(Tdate.format(timer.getTime()));
    jLabel15.setText("");
    Random rand = new Random();
    int number, number1;
    number = rand.nextInt(8999);
    number1 = 1000 + number;

    jTextField11.setText(jTextField11.getText() + number1);

    Document doc = new Document();
    try {
        PdfWriter.getInstance(doc,
                new FileOutputStream("f:\\DiGiho\\Registration Form\\" + jTextField11.getText() + ".pdf"));
        doc.open();
        Paragraph para = new Paragraph();
        doc.add(new Paragraph("\n",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY)));
        doc.add(new Paragraph("\n\n\n\n\n\n\n\n\n\n"));
        doc.add(new Phrase("Customer ID         "));
        doc.add(new Phrase(jTextField11.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                    Date          "
                + jTextField17.getText() + "   \n\n"));
        doc.add(new Phrase("Name:-                   "));
        doc.add(new Phrase(jTextField5.getText() + ". " + jTextField6.getText() + " " + jTextField1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nFather's Name:-     "));
        doc.add(new Phrase(jTextField2.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nAddress                "));
        doc.add(new Phrase(jTextField3.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nBlock                    "));
        doc.add(new Phrase(jTextField16.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                           District                  "));
        doc.add(new Phrase(jTextField10.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nCity                       "));
        doc.add(new Phrase(jTextField15.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                Pin Code                  "));
        doc.add(new Phrase(jTextField9.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase());
        doc.add(new Phrase("\nState                    "));
        doc.add(new Phrase(jTextField14.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                                   Date of Birth             "));
        doc.add(new Phrase(jTextField12.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nMoblie No.           "));
        doc.add(new Phrase(jTextField7.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("                                         Phone No.                 "));
        doc.add(new Phrase(jTextField13.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase());
        doc.add(new Phrase("\nEmail address          "));
        doc.add(new Phrase(jTextField8.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\nOccupation:          "));
        doc.add(new Phrase(a, FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(para);
        doc.add(new Phrase(
                "          \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n                         "
                        + jTextField6.getText() + "  " + jTextField1.getText()));
        doc.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(DigiHoInitial.class.getName()).log(Level.SEVERE, null, ex);
    }
    JOptionPane.showMessageDialog(null, "File has been created", "deeps message", JOptionPane.PLAIN_MESSAGE);

}

From source file:login.DigiHoInitial.java

private void jButton22ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton22ActionPerformed
    // TODO add your handling code here:
    Document doc = new Document();
    try {//  w w w  .jav a2s  . c  o  m
        PdfWriter.getInstance(doc,
                new FileOutputStream("F:\\DiGiho\\Customer Recipt\\" + jTextField11.getText() + ".pdf"));
        doc.open();
        doc.add(new Phrase("\n\n\n\n\n\n\n"));
        doc.add(new Phrase(
                "                                                                                                              Date:"));
        doc.add(new Phrase(jTextField17.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\n\n\n           Customer ID.:      "));
        doc.add(new Phrase(jTextField11.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));

        doc.add(new Phrase("\n           Name:                 "));
        doc.add(new Phrase(jTextField5.getText() + "  " + jTextField6.getText() + "  " + jTextField1.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\n           Father's Name:   "));
        doc.add(new Phrase(jTextField2.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\n           Address:             "));
        doc.add(new Phrase(
                jTextField3.getText() + "  " + jTextField16.getText() + "  " + jTextField10.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\n           Mobile:                "));
        doc.add(new Phrase(jTextField7.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.add(new Phrase("\n           Email ID.:            "));
        doc.add(new Phrase(jTextField8.getText(),
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.BOLD, BaseColor.BLACK)));
        doc.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (FileNotFoundException ex) {
        Logger.getLogger(DigiHoInitial.class.getName()).log(Level.SEVERE, null, ex);
    }
    JOptionPane.showMessageDialog(null, "Recipt has been created", "deeps message",
            JOptionPane.INFORMATION_MESSAGE);
}

From source file:Login.ventas.fproyectos.java

/**
 * Creates new form cliente//from w  w  w  .  ja  v  a  2s.  co  m
 * @param user
 */
public fproyectos(Login user) {
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    @SuppressWarnings("MismatchedReadAndWriteOfArray")
    String[] fecha = { "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre",
            "Octubre", "Noviembre", "Diciembre" };
    initComponents();
    Calendar rightNow = Calendar.getInstance();
    int ccyy = rightNow.get(Calendar.YEAR);
    int month = rightNow.get(Calendar.MONTH);
    setSize(d.width, d.height - 95);
    this.usuario = user;
    add(f);
    f.setLocation(jPanel1.getX(), jPanel1.getY());
    add(f3);
    f3.setLocation(jPanel1.getX(), jPanel1.getY());
    add(f4);
    f4.setLocation(jPanel1.getX(), jPanel1.getY());
    add(f5);
    f5.setLocation(jPanel1.getX(), jPanel1.getY());
    add(f2);
    f2.setLocation(jPanel1.getX(), jPanel1.getY());

    f2.getjButton1().addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            try {
                ServiceHb helper = new ServiceHb();
                helper.iniciarTransaccion();
                Fcomisiones fc = helper.getFcomisiones(idcliente, idinstalacion);
                if (helper.getFcomisiones(idcliente, idinstalacion) == null) {
                    fc = new Fcomisiones();
                    Calendar d = Calendar.getInstance();
                    fc.setFecha(new java.sql.Date(d.getTime().getTime()));
                    fc.setClientes(
                            (Clientes) helper.obtenerObjeto(Clientes.class, Integer.parseInt(idcliente)));
                    fc.setInstalacion((Instalacion) helper.obtenerObjeto(Instalacion.class,
                            Integer.parseInt(idinstalacion)));
                    fc.setRentabilidad(f2.getjLabel20().getText());
                    fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length()));
                    fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length()));
                    fc.setDiferido(f2.getjLabel4().getText());
                    fc.setDias(numeroinstala);
                    helper.crearObjeto(fc);
                    helper.confirmarTransaccion();
                    helper.cerrarSesion();
                    JOptionPane.showMessageDialog(null,
                            "Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime()));
                } else {
                    Calendar d = Calendar.getInstance();
                    fc.setFecha(new java.sql.Date(d.getTime().getTime()));
                    fc.setRentabilidad(f2.getjLabel20().getText());
                    fc.setValor1(f2.getjLabel11().getText().substring(2, f2.getjLabel11().getText().length()));
                    fc.setValor2(f2.getjLabel2().getText().substring(3, f2.getjLabel2().getText().length()));
                    fc.setDiferido(f2.getjLabel4().getText());
                    fc.setDias(numeroinstala);
                    helper.actualizarObjeto(fc);
                    helper.confirmarTransaccion();
                    helper.cerrarSesion();
                    JOptionPane.showMessageDialog(null,
                            "Actualizado / Comision prepara con fecha " + Funcion.DateFormatSql(d.getTime()));
                }
            } catch (Exception io) {
                System.out.println(io);
            }
        }
    });
    f2.getjButton2().addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        @SuppressWarnings("UseSpecificCatch")
        public void mouseClicked(MouseEvent e) {
            float ancho = 0;
            try {
                Document documento = new Document(PageSize.A4, 0, 0, 0, 0);
                ancho = documento.getPageSize().getWidth() - 100;
                FileOutputStream ficheroPdf;
                PdfWriter writer = null;
                PdfWriter writer2 = null;
                String direccion = "";
                Calendar now2 = Calendar.getInstance();
                try {
                    JFileChooser chooser = new JFileChooser();
                    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                    //Mostrar la ventana para abrir archivo y recoger la respuesta
                    //En el parmetro del showOpenDialog se indica la ventana
                    //  al que estar asociado. Con el valor this se asocia a la
                    //  ventana que la abre.
                    int respuesta = chooser.showOpenDialog(null);
                    String cadena = "";
                    if (respuesta == JFileChooser.APPROVE_OPTION) {
                        direccion = chooser.getSelectedFile().getAbsolutePath();
                    }
                    Calendar d = Calendar.getInstance();
                    ficheroPdf = new FileOutputStream(direccion + "/" + idcliente + idinstalacion + ".pdf");
                    writer = PdfWriter.getInstance(documento, ficheroPdf);
                } catch (IOException ex) {
                    System.out.println(ex.toString());
                }
                ServiceHb helper = null;
                try {
                    List<Productos> lt = null;
                    helper = new ServiceHb();
                    helper.iniciarTransaccion();
                    PdfPTable tabla;
                    PdfPCell casilla;
                    PdfPTable salto = null;
                    PdfPCell celda;
                    Font fontpersonalizado = FontFactory.getFont("ARIAL", 7, Font.BOLD);
                    Font fontpersonalizado2 = FontFactory.getFont("ARIAL", 7, Font.NORMAL);
                    documento.open();
                    PdfContentByte canvas = writer.getDirectContent();
                    fondos(documento, canvas);
                    //Materiales
                    double total = 0;
                    double total2 = 0;
                    double total3 = 0;
                    double total4 = 0;
                    double total5 = 0;
                    tabla = new PdfPTable(6);
                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                    tabla.setTotalWidth(ancho);
                    tabla.setLockedWidth(true);
                    celda = new PdfPCell(new Paragraph("ADQUISICION DE MATERIALES"));
                    celda.setColspan(6);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);
                    float pagina = documento.getPageSize().getHeight() - 140;
                    final float max = pagina;
                    pagina = pagina - tabla.getRow(0).calculateHeights();
                    if (ltart != null) {
                        Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "PRECIO", "SUBTOTAL", "TOTAL DIARIO" };
                        for (Object obj : nuevo2) {
                            celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                            celda.setBorderColor(new Color(195, 195, 195));
                            celda.setColspan(1);
                            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                            tabla.addCell(celda);
                        }
                        pagina = pagina - tabla.getRow(1).calculateHeights();
                        int tam = 0;
                        double diario = 0;
                        int turno = 0;
                        for (int i = 0; i < ltart.size(); i++) {
                            turno = 0;
                            fact = helper.getFacturafecha(ltart.get(i).getIdfactura());
                            String fecha = "";
                            if (fact != null) {
                                fecha = Funcion.DateFormatSql(fact.getFecha());
                            }
                            if ((i + 1) == ltart.size()) {
                                diario = diario + Double.parseDouble(ltart.get(i).getTotal());
                                turno = 1;
                            } else {
                                fact2 = helper.getFacturafecha(ltart.get(i + 1).getIdfactura());
                                String fecha2 = "";
                                if (fact2 != null) {
                                    fecha2 = Funcion.DateFormatSql(fact2.getFecha());
                                    if (fecha.equalsIgnoreCase(fecha2)) {
                                        diario = diario + Double.parseDouble(ltart.get(i).getTotal());
                                    } else {
                                        diario = diario + Double.parseDouble(ltart.get(i).getTotal());
                                        turno = 1;
                                    }
                                }
                            }
                            String uni = "$ " + df.format(Double.parseDouble(ltart.get(i).getUnitario()))
                                    .replace(",", ".");
                            String tot = "$ "
                                    + df.format(Double.parseDouble(ltart.get(i).getTotal())).replace(",", ".");
                            total = total + Double.parseDouble(ltart.get(i).getTotal());
                            if (turno == 0) {
                                Object nuevo[] = { fecha, ltart.get(i).getDescripcion(),
                                        ltart.get(i).getCantidad(), uni, tot, "" };
                                for (Object obj : nuevo) {

                                    celda = new PdfPCell(
                                            new Paragraph((String) obj, new Font(fontpersonalizado2)));
                                    if (((String) obj).equalsIgnoreCase("")) {
                                        celda.setBorder(Rectangle.RIGHT);
                                    }
                                    celda.setBorderColor(new Color(195, 195, 195));
                                    celda.setColspan(1);
                                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    tabla.addCell(celda);
                                }
                            } else {
                                Object nuevo[] = { fecha, ltart.get(i).getDescripcion(),
                                        ltart.get(i).getCantidad(), uni, tot,
                                        "$ " + df.format(diario).replace(",", ".") };
                                int va = 0;
                                for (Object obj : nuevo) {
                                    va++;
                                    celda = new PdfPCell(
                                            new Paragraph((String) obj, new Font(fontpersonalizado2)));
                                    if (va == 5) {
                                        celda.setBorder(Rectangle.BOTTOM);
                                    }
                                    celda.setColspan(1);
                                    celda.setBorderColor(new Color(195, 195, 195));
                                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    tabla.addCell(celda);
                                }
                                diario = 0;
                            }
                            pagina = pagina - tabla.getRow(tam).getMaxHeights();
                            tam++;
                            if (pagina < 11) {
                                salto = new PdfPTable(1);
                                casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                                casilla.setMinimumHeight(90);
                                casilla.setBorder(PdfPCell.NO_BORDER);
                                salto.addCell(casilla);
                                documento.add(salto);

                                documento.add(tabla);
                                documento.newPage();
                                fondos(documento, canvas);
                                tabla = new PdfPTable(6);
                                tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                                tabla.setTotalWidth(ancho);
                                tabla.setLockedWidth(true);
                                pagina = max;
                                tam = 0;
                            }

                        }
                    }
                    salto = new PdfPTable(1);
                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                    casilla.setMinimumHeight(90);
                    casilla.setBorder(PdfPCell.NO_BORDER);
                    salto.addCell(casilla);
                    documento.add(salto);

                    celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(
                            new Paragraph("Adquisicin de Materiales", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(4);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("$ " + df.format(total).replace(",", "."),
                            new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    documento.add(tabla);
                    documento.newPage();
                    fondos(documento, canvas);
                    /*Parte 2*/

                    tabla = new PdfPTable(4);
                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                    tabla.setTotalWidth(ancho);
                    tabla.setLockedWidth(true);
                    tabla.setWidths(new int[] { 1, 3, 1, 1 });
                    celda = new PdfPCell(new Paragraph("MANO DE OBRA TECNICOS"));
                    celda.setColspan(4);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);
                    pagina = documento.getPageSize().getHeight() - 140;
                    pagina = pagina - tabla.getRow(0).calculateHeights();

                    if (list != null) {
                        Object nuevo2[] = { "FECHA", "DETALLE", "CANT.", "SUBTOTAL" };
                        for (Object obj : nuevo2) {
                            celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                            celda.setBorderColor(new Color(195, 195, 195));
                            celda.setColspan(1);
                            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                            tabla.addCell(celda);
                        }
                        pagina = pagina - tabla.getRow(1).calculateHeights();
                        int tam = 0;
                        double diario = 0;
                        int turno = 0;
                        for (Ctepagar list1 : list) {
                            if (list1.getDetalle().contains("ci:")) {
                                String fecha = list1.getFecha();
                                String desc = list1.getDetalle();
                                String[] cadena = desc.split(" ");
                                String result = "";
                                int contador = 0;
                                for (String n : cadena) {
                                    if (n.contains("ci:")) {
                                        result = result + ", ";
                                        contador++;
                                    } else {
                                        result = result + n + " ";
                                    }
                                }
                                result = result.substring(0, result.length() - 2);
                                String uni = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                String tot = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                total2 = total2 + Double.parseDouble(list1.getValor());
                                Object nuevo[] = { fecha, result, "" + contador, tot };
                                for (Object obj : nuevo) {
                                    celda = new PdfPCell(
                                            new Paragraph((String) obj, new Font(fontpersonalizado2)));
                                    celda.setBorderColor(new Color(195, 195, 195));
                                    celda.setColspan(1);
                                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    tabla.addCell(celda);
                                }
                                pagina = pagina - tabla.getRow(tam).getMaxHeights();
                                tam++;
                                if (pagina < 90) {
                                    salto = new PdfPTable(1);
                                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2)));
                                    casilla.setMinimumHeight(90);
                                    casilla.setBorder(PdfPCell.NO_BORDER);
                                    salto.addCell(casilla);
                                    documento.add(salto);

                                    documento.add(tabla);
                                    documento.newPage();
                                    fondos(documento, canvas);
                                    tabla = new PdfPTable(4);
                                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                                    tabla.setTotalWidth(ancho);
                                    tabla.setLockedWidth(true);
                                    tabla.setWidths(new int[] { 1, 3, 1, 1 });
                                    pagina = max;
                                    tam = 0;
                                }
                            }
                        }
                    }
                    salto = new PdfPTable(1);
                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                    casilla.setMinimumHeight(90);
                    casilla.setBorder(PdfPCell.NO_BORDER);
                    salto.addCell(casilla);
                    documento.add(salto);

                    celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("Mano de Obra Tcnicos", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(2);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("$ " + df.format(total2).replace(",", "."),
                            new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    documento.add(tabla);

                    documento.newPage();
                    fondos(documento, canvas);

                    tabla = new PdfPTable(3);
                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                    tabla.setTotalWidth(ancho);
                    tabla.setLockedWidth(true);
                    tabla.setWidths(new int[] { 1, 3, 1 });
                    celda = new PdfPCell(new Paragraph("TRANSPORTE"));
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);
                    pagina = documento.getPageSize().getHeight() - 140;
                    pagina = pagina - tabla.getRow(0).calculateHeights();

                    if (list != null) {
                        Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" };
                        for (Object obj : nuevo2) {
                            celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                            celda.setBorderColor(new Color(195, 195, 195));
                            celda.setColspan(1);
                            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                            tabla.addCell(celda);
                        }
                        pagina = pagina - tabla.getRow(1).calculateHeights();
                        int tam = 0;
                        for (Ctepagar list1 : list) {
                            if (list1.getDetalle().contains("Transporte")) {
                                String fecha = list1.getFecha();
                                String desc = list1.getDetalle();
                                String result = "";
                                String uni = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                String tot = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                total3 = total3 + Double.parseDouble(list1.getValor());
                                Object nuevo[] = { fecha, desc, tot };
                                for (Object obj : nuevo) {
                                    celda = new PdfPCell(
                                            new Paragraph((String) obj, new Font(fontpersonalizado2)));
                                    celda.setBorderColor(new Color(195, 195, 195));
                                    celda.setColspan(1);
                                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    tabla.addCell(celda);
                                }
                                pagina = pagina - tabla.getRow(tam).getMaxHeights();
                                tam++;
                                if (pagina < 50) {
                                    salto = new PdfPTable(1);
                                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado2)));
                                    casilla.setMinimumHeight(90);
                                    casilla.setBorder(PdfPCell.NO_BORDER);
                                    salto.addCell(casilla);
                                    documento.add(salto);

                                    documento.add(tabla);
                                    documento.newPage();
                                    fondos(documento, canvas);
                                    tabla = new PdfPTable(3);
                                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                                    tabla.setTotalWidth(ancho);
                                    tabla.setLockedWidth(true);
                                    tabla.setWidths(new int[] { 1, 3, 1 });
                                    pagina = max;
                                    tam = 0;
                                }
                            }
                        }
                    }
                    salto = new PdfPTable(1);
                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                    casilla.setMinimumHeight(90);
                    casilla.setBorder(PdfPCell.NO_BORDER);
                    salto.addCell(casilla);
                    documento.add(salto);

                    celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("Transporte", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("$ " + df.format(total3).replace(",", "."),
                            new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    documento.add(tabla);

                    documento.newPage();
                    fondos(documento, canvas);

                    tabla = new PdfPTable(3);
                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                    tabla.setTotalWidth(ancho);
                    tabla.setLockedWidth(true);
                    tabla.setWidths(new int[] { 1, 3, 1 });
                    celda = new PdfPCell(new Paragraph("COMBUSTIBLE"));
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);
                    pagina = documento.getPageSize().getHeight() - 140;
                    pagina = pagina - tabla.getRow(0).calculateHeights();

                    if (list != null) {
                        Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" };
                        for (Object obj : nuevo2) {
                            celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                            celda.setBorderColor(new Color(195, 195, 195));
                            celda.setColspan(1);
                            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                            tabla.addCell(celda);
                        }
                        pagina = pagina - tabla.getRow(1).calculateHeights();
                        int tam = 0;
                        for (Ctepagar list1 : list) {
                            if (list1.getDetalle().contains("Combustible")) {
                                String fecha = list1.getFecha();
                                String desc = list1.getDetalle();
                                String result = "";
                                String uni = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                String tot = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                total4 = total4 + Double.parseDouble(list1.getValor());
                                Object nuevo[] = { fecha, desc, tot };
                                for (Object obj : nuevo) {
                                    celda = new PdfPCell(
                                            new Paragraph((String) obj, new Font(fontpersonalizado2)));
                                    celda.setBorderColor(new Color(195, 195, 195));
                                    celda.setColspan(1);
                                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    tabla.addCell(celda);
                                }
                                pagina = pagina - tabla.getRow(tam).getMaxHeights();
                                tam++;
                                if (pagina < 50) {
                                    salto = new PdfPTable(1);
                                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                                    casilla.setMinimumHeight(90);
                                    casilla.setBorder(PdfPCell.NO_BORDER);
                                    salto.addCell(casilla);
                                    documento.add(salto);

                                    documento.add(tabla);
                                    documento.newPage();
                                    fondos(documento, canvas);
                                    tabla = new PdfPTable(3);
                                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                                    tabla.setTotalWidth(ancho);
                                    tabla.setLockedWidth(true);
                                    tabla.setWidths(new int[] { 1, 3, 1 });
                                    pagina = max;
                                    tam = 0;
                                }
                            }
                        }
                    }
                    salto = new PdfPTable(1);
                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                    casilla.setMinimumHeight(90);
                    casilla.setBorder(PdfPCell.NO_BORDER);
                    salto.addCell(casilla);
                    documento.add(salto);

                    celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("Combustible", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("$ " + df.format(total4).replace(",", "."),
                            new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    documento.add(tabla);

                    documento.newPage();
                    fondos(documento, canvas);

                    //Extras

                    tabla = new PdfPTable(3);
                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                    tabla.setTotalWidth(ancho);
                    tabla.setLockedWidth(true);
                    tabla.setWidths(new int[] { 1, 3, 1 });
                    celda = new PdfPCell(new Paragraph("EXTRAS"));
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);
                    pagina = documento.getPageSize().getHeight() - 140;
                    pagina = pagina - tabla.getRow(0).calculateHeights();

                    if (list != null) {
                        Object nuevo2[] = { "FECHA", "DETALLE", "SUBTOTAL" };
                        for (Object obj : nuevo2) {
                            celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                            celda.setBorderColor(new Color(195, 195, 195));
                            celda.setColspan(1);
                            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                            tabla.addCell(celda);
                        }
                        pagina = pagina - tabla.getRow(1).calculateHeights();
                        int tam = 0;
                        for (Ctepagar list1 : list) {
                            if (!list1.getDetalle().contains("Combustible")
                                    && !list1.getDetalle().contains("ci:")
                                    && !list1.getDetalle().contains("Transporte")) {
                                String fecha = list1.getFecha();
                                String desc = list1.getDetalle();
                                String result = "";
                                String uni = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                String tot = "$ "
                                        + df.format(Double.parseDouble(list1.getValor())).replace(",", ".");
                                total5 = total5 + Double.parseDouble(list1.getValor());
                                Object nuevo[] = { fecha, desc, tot };
                                for (Object obj : nuevo) {
                                    celda = new PdfPCell(
                                            new Paragraph((String) obj, new Font(fontpersonalizado2)));
                                    celda.setBorderColor(new Color(195, 195, 195));
                                    celda.setColspan(1);
                                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                                    tabla.addCell(celda);
                                }
                                pagina = pagina - tabla.getRow(tam).getMaxHeights();
                                tam++;
                                if (pagina < 50) {
                                    salto = new PdfPTable(1);
                                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                                    casilla.setMinimumHeight(90);
                                    casilla.setBorder(PdfPCell.NO_BORDER);
                                    salto.addCell(casilla);
                                    documento.add(salto);

                                    documento.add(tabla);
                                    documento.newPage();
                                    fondos(documento, canvas);
                                    tabla = new PdfPTable(3);
                                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                                    tabla.setTotalWidth(ancho);
                                    tabla.setLockedWidth(true);
                                    tabla.setWidths(new int[] { 1, 3, 1 });
                                    pagina = max;
                                    tam = 0;
                                }
                            }
                        }
                    }
                    salto = new PdfPTable(1);
                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                    casilla.setMinimumHeight(90);
                    casilla.setBorder(PdfPCell.NO_BORDER);
                    salto.addCell(casilla);
                    documento.add(salto);

                    celda = new PdfPCell(new Paragraph("Total", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("Extra", new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("$ " + df.format(total5).replace(",", "."),
                            new Font(fontpersonalizado2)));
                    celda.setBorderColor(new Color(195, 195, 195));
                    celda.setColspan(1);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);

                    documento.add(tabla);

                    documento.newPage();
                    fondos(documento, canvas);

                    //Final Vendedor

                    tabla = new PdfPTable(3);
                    tabla.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
                    tabla.setTotalWidth(ancho);
                    tabla.setLockedWidth(true);
                    tabla.setWidths(new int[] { 1, 3, 1 });
                    celda = new PdfPCell(new Paragraph(nombrecliente));
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);

                    celda = new PdfPCell(new Paragraph("Venta"));
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_LEFT);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);

                    pagina = documento.getPageSize().getHeight() - 140;
                    pagina = pagina - tabla.getRow(0).calculateHeights();

                    Object nuevo2[] = { "FECHA", "DETALLE", "TOTAL" };
                    for (Object obj : nuevo2) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                        celda.setBorderColor(new Color(195, 195, 195));
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo3[] = { "", nombreinstalacion, totalinstalacion };
                    for (Object obj : nuevo3) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorderColor(new Color(195, 195, 195));
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    celda = new PdfPCell(new Paragraph("INVERSION", new Font(fontpersonalizado)));
                    celda.setBorder(PdfPCell.NO_BORDER);
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tabla.addCell(celda);
                    Object nuevo4[] = { "Uso de Materiales", "", "$ " + df.format(total).replace(",", ".") };
                    for (Object obj : nuevo4) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo5[] = { "Mano de obra tcnicos", "",
                            "$ " + df.format(total2).replace(",", ".") };
                    for (Object obj : nuevo5) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo6[] = { "Transporte", "", "$ " + df.format(total3).replace(",", ".") };
                    for (Object obj : nuevo6) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo7[] = { "Combustible", "", "$ " + df.format(total4).replace(",", ".") };
                    for (Object obj : nuevo7) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo71[] = { "Extras", "", "$ " + df.format(total5).replace(",", ".") };
                    for (Object obj : nuevo71) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo8[] = { "Total Inversin", "",
                            "$ " + df.format(total + total2 + total3 + total4).replace(",", ".") };
                    for (Object obj : nuevo8) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado2)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    celda = new PdfPCell(new Paragraph(""));
                    celda.setColspan(3);
                    celda.setHorizontalAlignment(Element.ALIGN_LEFT);
                    celda.setBorder(PdfPCell.NO_BORDER);
                    tabla.addCell(celda);

                    Object nuevo9[] = { "Utilidad del proyecto", "", "$ "
                            + df.format(proyectoval - total - total2 - total3 - total4).replace(",", ".") };
                    for (Object obj : nuevo9) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                        celda.setColspan(1);
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }
                    Object nuevo10[] = { "Rentabilidad ", "", df.format(porcent).replace(",", ".") + " %" };
                    for (Object obj : nuevo10) {
                        celda = new PdfPCell(new Paragraph((String) obj, new Font(fontpersonalizado)));
                        celda.setBorder(PdfPCell.NO_BORDER);
                        celda.setColspan(1);
                        celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                        tabla.addCell(celda);
                    }

                    salto = new PdfPTable(1);
                    casilla = new PdfPCell(new Phrase("", new Font(fontpersonalizado)));
                    casilla.setMinimumHeight(90);
                    casilla.setBorder(PdfPCell.NO_BORDER);
                    salto.addCell(casilla);
                    documento.add(salto);

                    documento.add(tabla);

                    /*Fin Parte 3*/
                    documento.close();
                    helper.cerrarSesion();
                } catch (Exception ex) {
                    documento.close();
                }
                JOptionPane.showMessageDialog(null, "PDF Generado");
            } catch (Exception io) {
                System.out.println(io);
            }
        }
    });
    f.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int row = f.getjTable1().getSelectedRow();
            int col = f.getjTable1().getSelectedColumn();
            if (col == 4) {
                f2.setVisible(true);
                f.setVisible(false);
                idcliente = f.getjTable1().getValueAt(row, 5).toString();
                idinstalacion = f.getjTable1().getValueAt(row, 6).toString();
                f2.getjLabel15().setText(f.getjTable1().getValueAt(row, 0).toString());
                f2.getjLabel8().setText(f.getjTable1().getValueAt(row, 2).toString());
                nombrecliente = f.getjTable1().getValueAt(row, 0).toString();
                nombreinstalacion = f.getjTable1().getValueAt(row, 2).toString();
                updateTablas up = new updateTablas(1);
                up.start();
            }
        }
    });
    f5.getjComboBox1().addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DefaultTableModel temp2 = (DefaultTableModel) f5.getjTable2().getModel();
            for (int i = temp2.getRowCount() - 1; i >= 0; i--) {
                temp2.removeRow(i);
            }
            f5.setComi(null);
            f5.setNinstalacion("");
            f5.setNcliente("");
            f5.setList(null);
            f5.setId("");
            updateTablas up = new updateTablas(4);
            up.start();
        }
    });
    f3.getjTable1().addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int row = f3.getjTable1().getSelectedRow();
            int col = f3.getjTable1().getSelectedColumn();
            if (col == 6) {
                visible(f4);
                fcomisiones = f3.getjTable1().getValueAt(row, 6).toString();
                try {
                    ServiceHb helper = new ServiceHb();
                    helper.iniciarTransaccion();
                    Fcomisiones ft = (Fcomisiones) helper.obtenerObjeto(Fcomisiones.class,
                            Integer.parseInt(fcomisiones));
                    numeroinstala = ft.getDias();
                    f4.setIdcliente("" + ft.getClientes().getId());
                    f4.setIdinstalacion("" + ft.getInstalacion().getId());
                    f4.getDiasint().setText(numeroinstala);
                    helper.cerrarSesion();
                } catch (Exception io) {

                }
                f4.getjLabel1().setText(fcomisiones);
                f4.getC1().setText(f3.getjTable1().getValueAt(row, 0).toString());
                f4.getC2().setText(f3.getjTable1().getValueAt(row, 1).toString());
                double campo1 = Double
                        .parseDouble(f3.getjTable1().getValueAt(row, 3).toString().replace("$ ", ""));
                double campo2 = Double
                        .parseDouble(f3.getjTable1().getValueAt(row, 4).toString().replace("-$ ", ""));
                f4.getC3().setText(f3.getjTable1().getValueAt(row, 3).toString());
                f4.getC4().setText(f3.getjTable1().getValueAt(row, 4).toString());
                f4.getC5().setText(f3.getjTable1().getValueAt(row, 5).toString());
                f4.getC6().setText("$ " + df.format((campo1 - campo2)).replace(",", "."));

                updateTablas up = new updateTablas(3);
                up.start();
            }
        }
    });

    setVisible(false);
}

From source file:MailSender.PDF.java

public void createInvoice(ArrayList<Guest> guestarray, Reservation res, String roomType, int roomPrice)
        throws DocumentException, IOException {
    filePath = "Invoice" + guestarray.get(0).getReservationNo() + ".pdf";
    // step 1/*w  w  w .java  2  s  .  co m*/
    String firstName = guestarray.get(0).getGuestFirstName();
    String lastName = guestarray.get(0).getGuestFamilyName();
    int deposit = roomPrice / 2;

    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yy");

    Document document = new Document();
    System.out.println("document");
    // step 2
    FileOutputStream fos = new FileOutputStream(filePath);
    PdfWriter.getInstance(document, fos);
    System.out.println("fos");
    // step 3
    document.open();
    // step 4
    Font font = FontFactory.getFont("Times-Roman", 18);
    Font fontbold = FontFactory.getFont("Times-Roman", 34, Font.BOLD);

    document.add(new Paragraph("Invoice", fontbold));
    document.add(new Paragraph("                                    Casablanca Holiday Centre", font));
    document.add(new Paragraph("                                    " + c.getTime(), font));

    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("Dear " + firstName + " " + lastName + ",", font));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("thank you for your reservation.", font));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("++++++Reservation details+++++++", font));
    document.add(new Paragraph(
            "Name: " + guestarray.get(0).getGuestFirstName() + " " + guestarray.get(0).getGuestFamilyName(),
            font));
    document.add(new Paragraph("From: " + dateFormat.format(res.getFromDate()), font));
    document.add(new Paragraph("To: " + dateFormat.format(res.getEndDate()), font));
    document.add(new Paragraph("Room type: " + roomType, font));
    document.add(new Paragraph("++++++++++++++++++++++++++++++++", font));

    document.add(new Paragraph(Chunk.NEWLINE));

    document.add(new Paragraph("Please place the deposit in our follwing bank account in 5 days.", font));
    document.add(new Paragraph(Chunk.NEWLINE));

    document.add(new Paragraph("Deposit ammount: " + deposit + " USD", font));
    document.add(new Paragraph("Bank account: xxxx xxxx xxxx", font));

    document.add(new Paragraph(Chunk.NEWLINE));

    document.add(new Paragraph("Please read our cancel rule mentioned in the next page", font));

    document.add(new Paragraph(Chunk.NEWLINE));

    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("Regards,", font));
    document.add(new Paragraph("CasaBlanca Hotel Resort", font));

    document.add(new Paragraph(Chunk.NEXTPAGE));

    document.add(new Paragraph("The deposit and rules of cancellations", fontbold));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(
            new Paragraph("The deposit must be paid at the latest 5 days after receiving the invoice.", font));
    document.add(new Paragraph(
            "The deposit is half the bill. If deposit is not received by the centre within this deadline the booking will be cancelled.",
            font));
    document.add(new Paragraph(
            "In case of cancellation your deposit will be refunded after deducting the cancellation fees as follows.",
            font));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("2 weeks before the date of arrival:  the deposit will be refunded", font));
    document.add(new Paragraph("1 week before the date of arrival:  the deposit will be refunded", font));
    document.add(new Paragraph("Less than a week no deposit is refunded.", font));
    // step 5
    document.close();
    System.out.println("closed");
}

From source file:MailSender.PDF.java

public void createConfirmation(ArrayList<Guest> guestarray, Reservation res, String roomType)
        throws DocumentException, IOException {
    filePath = "Confirmation" + guestarray.get(0).getReservationNo() + ".pdf";
    // step 1/*from  w  w w .  j  a  v a 2  s.  c  om*/
    String firstName = guestarray.get(0).getGuestFirstName();
    String lastName = guestarray.get(0).getGuestFamilyName();

    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yy");

    Document document = new Document();
    System.out.println("document");
    // step 2
    FileOutputStream fos = new FileOutputStream(filePath);
    PdfWriter.getInstance(document, fos);
    System.out.println("fos");
    // step 3
    document.open();
    // step 4
    Font font = FontFactory.getFont("Times-Roman", 14);
    Font fontbold = FontFactory.getFont("Times-Roman", 30, Font.BOLD);

    document.add(new Paragraph("Confirmation", fontbold));
    document.add(new Paragraph(
            "                                                             Casablanca Holiday Centre", font));
    document.add(new Paragraph(
            "                                                            " + dateFormat.format(c.getTime()),
            font));

    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("Dear " + firstName + " " + lastName + ",", font));
    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("thank you for your reservation.", font));
    //document.add(new Paragraph("Please print out and bring this confirmation.", font));
    //document.add(new Paragraph("You will need password shown in guest details below for booking sport facilities.", font));

    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("++++++Reservation details+++++++", font));
    document.add(new Paragraph("From: " + dateFormat.format(res.getFromDate()), font));
    document.add(new Paragraph("To: " + dateFormat.format(res.getEndDate()), font));
    document.add(new Paragraph("Room type: " + roomType, font));

    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("++++++Guest details+++++++", font));
    document.add(new Paragraph(toStringForPDF(guestarray), font));

    document.add(new Paragraph("+++++++++++++++++++++++++++++++++", font));
    document.add(new Paragraph(Chunk.NEWLINE));

    document.add(new Paragraph("We are looking forward to seeing you.", font));

    document.add(new Paragraph(Chunk.NEWLINE));

    document.add(new Paragraph(Chunk.NEWLINE));
    document.add(new Paragraph("Regards,", font));
    document.add(new Paragraph("CasaBlanca Hotel Resort", font));

    // step 5
    document.close();
    System.out.println("closed");
}

From source file:Model.Emprestimo.java

private void resultado() {
    Document documento = new Document();
    Livro l;/*from w  w w. j  a  va2 s . com*/
    try {
        PdfWriter.getInstance(documento, new FileOutputStream("Emprestimo" + id() + ".pdf"));
    } catch (DocumentException ex) {
        Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex);
    }
    documento.open();

    try {
        Paragraph pa = new Paragraph();
        Font fonte = new Font(Font.FontFamily.TIMES_ROMAN, 28, Font.BOLD, new BaseColor(0, 0, 225));
        pa.setFont(fonte);
        pa.setAlignment(Element.ALIGN_CENTER);
        pa.setSpacingAfter(50);
        pa.add("Emprestimo");
        documento.add(pa);
        fonte = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        pa = new Paragraph();
        pa.setFont(fonte);
        pa.setAlignment(Element.ALIGN_LEFT);
        pa.add("id: " + Integer.toString(id()));
        documento.add(pa);
        pa = new Paragraph();
        pa.setFont(fonte);
        pa.setAlignment(Element.ALIGN_LEFT);
        pa.add("ra: " + Integer.toString(this.getRa()));
        documento.add(pa);
        String lin = "";
        String[] h = this.Livros.split("/");
        for (int c = 0; c < h.length; c++) {
            l = new Livro();
            l.consultar(Integer.parseInt(h[c]));
            lin = lin + l.getNome() + "\n";
        }
        pa = new Paragraph();
        pa.setFont(fonte);
        pa.setAlignment(Element.ALIGN_LEFT);
        pa.add("Livros: " + lin);
        documento.add(pa);
        pa = new Paragraph();
        pa.setFont(fonte);
        pa.setAlignment(Element.ALIGN_LEFT);
        pa.add("Data de Realizao: " + this.dataR);
        documento.add(pa);
        pa = new Paragraph();
        pa.setFont(fonte);
        pa.setAlignment(Element.ALIGN_LEFT);
        pa.add("Data de Devoluo: " + this.dataD);
        documento.add(pa);
    } catch (DocumentException ex) {
        Logger.getLogger(Emprestimo.class.getName()).log(Level.SEVERE, null, ex);
    }
    documento.close();
}

From source file:Model.GerarRelatorio.java

public void init() {
    /*JFileChooser chooser = new JFileChooser();
     chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
     if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
     System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
     System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
     } else {/*from  w w w  . ja  v a  2s .c o m*/
     System.out.println("No Selection ");
     }
                
     String saida = "\\RelatorioDiarioExecucao.pdf";
            
     System.out.println(chooser.getSelectedFile() + saida);
     file = new File(chooser.getSelectedFile() + saida);*/

    file = new File("C:\\Windows\\Temp\\" + relatorio.getNmRelatorio() + ".pdf");
    file.delete();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            try {
                if (file.exists()) {
                    file = new File("C:\\Windows\\Temp\\" + relatorio.getNmRelatorio() + "2.pdf");
                }
                if (relatorio.getOrientacao().equalsIgnoreCase("Retrato")) {
                    d = new Document(PageSize.A4);
                } else {
                    d = new Document(PageSize.A4.rotate());
                }

                paragrafos = new ArrayList<>();
                tableHeader = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK);
                tableContent = new Font(FontFamily.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK);

                dateHeader();
                preencheVariaveis();
                preencheNomeColuna();
                preenche();
                printPdf();
            } catch (Exception e) {

            }
        }
    });

}

From source file:Model.GerarRelatorio.java

public void dateHeader() {
    Font fonte = new Font(FontFamily.TIMES_ROMAN, 10);
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm");
    toParagraphs(sdf.format(new Date(System.currentTimeMillis())), Element.ALIGN_RIGHT, fonte);
    toParagraphs("\n", Element.ALIGN_LEFT);
    fonte = new Font(FontFamily.TIMES_ROMAN, 15, Font.BOLD);
    toParagraphs("Santos Engenharia", Element.ALIGN_LEFT, fonte);
    toParagraphs("\n", Element.ALIGN_CENTER);
    fonte = new Font(FontFamily.TIMES_ROMAN, 15);
    toParagraphs(relatorio.getNmRelatorio(), Element.ALIGN_CENTER, fonte);
    toParagraphs("\n", Element.ALIGN_CENTER);
    sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");
    toParagraphs("Data: " + (sdf.format(new Date(System.currentTimeMillis()))), Element.ALIGN_LEFT);

}

From source file:Model.MyFontSelector.java

License:Open Source License

/**
 * Inicializa as fontes//from  www .  java 2 s  .  c  om
 * Initialize the fonts
 * @param baseFontList A List with the BaseFonts
 */
private void initFonts(ArrayList<BaseFont> baseFontList) {
    FontSelector fontSelectorTitle = new FontSelector();
    FontSelector fontSelectorBlue = new FontSelector();
    FontSelector fontSelectorGreen = new FontSelector();
    FontSelector fontSelectorRed = new FontSelector();
    FontSelector fontSelectorBlack = new FontSelector();

    for (BaseFont bf : baseFontList) {
        Font TITLE = new Font(bf, 16, Font.BOLD, BaseColor.BLACK);
        Font BLUE = new Font(bf, 14, Font.NORMAL, BaseColor.BLUE);
        Font GREEN = new Font(bf, 14, Font.NORMAL, new BaseColor(8, 138, 75));
        Font RED = new Font(bf, 14, Font.NORMAL, BaseColor.RED);
        Font BLACK = new Font(bf, 14, Font.NORMAL, BaseColor.BLACK);

        fontSelectorTitle.addFont(TITLE);
        fontSelectorBlue.addFont(BLUE);
        fontSelectorGreen.addFont(GREEN);
        fontSelectorRed.addFont(RED);
        fontSelectorBlack.addFont(BLACK);
    }

    fontSelectors.put("TITLE", fontSelectorTitle);
    fontSelectors.put("BLUE", fontSelectorBlue);
    fontSelectors.put("GREEN", fontSelectorGreen);
    fontSelectors.put("RED", fontSelectorRed);
    fontSelectors.put("BLACK", fontSelectorBlack);
}

From source file:model.PDFModel.java

License:Open Source License

public PdfPTable createTablePDFTable(int counter, String raportDate) {

    JTable resultTable = query.getProductsInTablePDFTable(raportDate, counter);

    PdfPTable[] tableTable = new PdfPTable[11];
    PdfPCell cell, productNameCell, paymentCell, countCell, priceCell;

    tableTable[counter] = new PdfPTable(4);
    tableTable[counter].setSpacingBefore(5f);
    tableTable[counter].setSpacingAfter(5f);

    totalTablePayment[counter] = 0.00;//from   w w w .j  av a  2  s .  com
    if (resultTable != null) {
        DefaultTableModel resultTableModel = (DefaultTableModel) resultTable.getModel();
        if (resultTableModel.getRowCount() > 0) {
            cell = new PdfPCell(new Phrase("Stolik " + (counter)));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(new BaseColor(80, 255, 50));
            tableTable[counter].addCell(cell);
            cell = new PdfPCell();
            cell.setBorder(Rectangle.NO_BORDER);
            tableTable[counter].addCell(cell);
            cell = new PdfPCell();
            cell.setBorder(Rectangle.NO_BORDER);
            tableTable[counter].addCell(cell);
            cell = new PdfPCell();
            cell.setBorder(Rectangle.NO_BORDER);
            tableTable[counter].addCell(cell);

            cell = new PdfPCell(new Phrase("Produkt"));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(new BaseColor(80, 172, 8));
            tableTable[counter].addCell(cell);
            cell = new PdfPCell(new Phrase("Ilosc"));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(new BaseColor(80, 172, 8));
            tableTable[counter].addCell(cell);
            cell = new PdfPCell(new Phrase("Cena jednostkowa"));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(new BaseColor(80, 172, 8));
            tableTable[counter].addCell(cell);
            cell = new PdfPCell(new Phrase("Zaplata"));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(new BaseColor(80, 172, 8));
            tableTable[counter].addCell(cell);

            for (int i = 0; i < resultTableModel.getRowCount(); i++) {
                productNameCell = new PdfPCell(new Phrase(resultTableModel.getValueAt(i, 0).toString(),
                        FontFactory.getFont(FontFactory.defaultEncoding, 10, Font.NORMAL, BaseColor.BLACK)));
                productNameCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                productNameCell.setBackgroundColor(new BaseColor(80, 135, 8));
                tableTable[counter].addCell(productNameCell);
                countCell = new PdfPCell(new Phrase(String.valueOf(resultTableModel.getValueAt(i, 2))));
                countCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                tableTable[counter].addCell(countCell);
                double payment = Double.parseDouble(resultTableModel.getValueAt(i, 1).toString())
                        * Double.parseDouble(resultTableModel.getValueAt(i, 2).toString());
                totalTablePayment[counter] += payment;
                paymentCell = new PdfPCell(new Phrase(String.valueOf(resultTableModel.getValueAt(i, 1))));
                paymentCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                tableTable[counter].addCell(paymentCell);
                priceCell = new PdfPCell(new Phrase(String.valueOf(payment)));
                priceCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                priceCell.setBackgroundColor(new BaseColor(255, 160, 160));
                tableTable[counter].addCell(priceCell);
            }
        }
    }
    if (totalTablePayment[counter] > 0.00) {
        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        tableTable[counter].addCell(cell);
        cell = new PdfPCell();
        cell.setBorder(Rectangle.NO_BORDER);
        tableTable[counter].addCell(cell);
        cell = new PdfPCell(new Phrase("SUMA:",
                FontFactory.getFont(FontFactory.defaultEncoding, 12, Font.NORMAL, BaseColor.BLACK)));
        cell.setBorder(Rectangle.NO_BORDER);
        cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableTable[counter].addCell(cell);
        cell = new PdfPCell(new Phrase(String.valueOf(totalTablePayment[counter]),
                FontFactory.getFont(FontFactory.defaultEncoding, 12, Font.BOLD, BaseColor.BLACK)));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setBackgroundColor(new BaseColor(255, 50, 50));
        tableTable[counter].addCell(cell);
    }

    return tableTable[counter];
}