Example usage for com.itextpdf.text Font Font

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

Introduction

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

Prototype


public Font() 

Source Link

Document

Constructs a Font.

Usage

From source file:com.iisigroup.cap.report.factory.ItextFontFactory.java

License:Open Source License

public Font getFont(String fontname, String fontType, String encoding, boolean embedded, float size, int style,
        BaseColor color) {/*w  w  w.j  a  va2  s. co  m*/
    try {
        return FontFactory.getFont(getFontPath(fontname, fontType), encoding, embedded, size, style, color);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    }
    return new Font();
}

From source file:Controlador.ControladorClasificacion.java

/**
 * Mtodo generarPDF que genera el PDF con la clasificacin al pulsar el
 * botn generar PDF//from   w  w w .ja  va  2  s  .  c om
 *
 * @throws FileNotFoundException salta la excepcion
 * @throws DocumentException salta la excepcion
 * @throws IOException salta la excepcion
 */
public void generarPDF() throws FileNotFoundException, DocumentException, IOException {

    Calendar cal = Calendar.getInstance();
    String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime());

    File file = new File("Clasificacion.pdf");
    FileOutputStream fileout = new FileOutputStream(file.getAbsolutePath());
    Document document = new Document();
    PdfWriter.getInstance(document, fileout);

    Font fuente1 = new Font();
    Font fuente2 = new Font();
    Font fuente3 = new Font();
    fuente1.setStyle(Font.BOLD | Font.ITALIC | Font.UNDERLINE);
    fuente1.setSize(18);
    fuente1.setColor(0, 51, 204);
    fuente2.setStyle(Font.BOLD | Font.ITALIC);
    fuente2.setColor(0, 51, 204);
    fuente2.setSize(13);
    fuente3.setStyle(Font.BOLD | Font.ITALIC);
    fuente3.setSize(16);
    fuente3.setColor(255, 153, 0);

    document.open();

    Paragraph pa = new Paragraph("Fecha y hora: " + time);

    pa.setAlignment(Element.ALIGN_RIGHT);
    document.add(pa);

    /*String url = "imagenPDF.jpg";
    File file2 = new File(url);
    FileInputStream filein = new FileInputStream(file2.getAbsolutePath());
    //String url = "./imagenPDF.jpg";
    Image imagen = Image.getInstance(filein.getFD());  
    //System.out.println(file2.getAbsolutePath());
    imagen.scalePercent(20);
    document.add(imagen);*/
    document.add(new Paragraph("\n"));
    Paragraph p3 = new Paragraph("GESTOR DE CAMPEONATO DE BALONCESTO", fuente1);
    p3.setAlignment(Element.ALIGN_CENTER);
    document.add(p3);

    document.add(new Paragraph("\n"));
    String tipo_competicion = FicherosTipo.leerFichero();

    if (tipo_competicion.contains("Copa")) {
        Paragraph pa1 = new Paragraph("COPA", fuente3);
        pa1.setAlignment(Element.ALIGN_CENTER);
        document.add(pa1);
        document.add(new Paragraph(
                "---------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("\n"));
        int jornada_maxima = PartidoDAO.obtenerJornadaActual();

        for (int i = jornada_maxima; i > 0; i--) {
            List<Partido> listarPartidosJornada = PartidoDAO.listarPartidosJornada(i);
            for (Partido p : listarPartidosJornada) {

                List<PartidoJugado> listarEquiposporPartido = PartidoJugadoDAO
                        .listarEquiposporPartido(p.getIdPartido());

                int equipoA = listarEquiposporPartido.get(0).getIdEquipo();
                int equipoB = listarEquiposporPartido.get(1).getIdEquipo();

                Paragraph p2 = new Paragraph(
                        "Equipo A: " + EquipoDAO.obtenerNombreEquipo(equipoA) + " - Equipo B: "
                                + EquipoDAO.obtenerNombreEquipo(equipoB) + " - Resultado: " + p.getResultado(),
                        fuente2);
                p2.setAlignment(Element.ALIGN_LEFT);
                document.add(p2);
            }

        }

    } else if (tipo_competicion.contains("Liga")) {
        Paragraph pa1 = new Paragraph("LIGA", fuente3);
        pa1.setAlignment(Element.ALIGN_LEFT);
        document.add(pa1);
        document.add(new Paragraph(
                "---------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("\n"));
        List<Equipo> obtenerTodosEquipos = EquipoDAO.obtenerTodosEquipos();
        Collections.sort(obtenerTodosEquipos);
        System.out.println(obtenerTodosEquipos);
        for (Equipo p : obtenerTodosEquipos) {
            Paragraph pa2 = new Paragraph(p.getNombre(), fuente2);
            pa2.setAlignment(Element.ALIGN_LEFT);
            document.add(pa2);
        }

    }
    document.close();
    File myfile = new File("Clasificacion.pdf");
    Desktop.getDesktop().open(myfile);
}

From source file:Controlador.ControladorCrearPase.java

public void generaPDF(String Prueba, String Causa, Integer idCita, Integer idPaciente, Integer idPersona)
        throws FileNotFoundException, DocumentException, IOException {

    Calendar cal = Calendar.getInstance();
    String time = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(cal.getTime());
    String timename = new SimpleDateFormat("yyyyMMddHHmm").format(cal.getTime());

    File file = new File("PaseServicio" + timename + ".pdf");
    FileOutputStream fileout = new FileOutputStream(file);
    Document document = new Document();
    PdfWriter writer;// w ww  . ja va 2  s.co  m
    writer = PdfWriter.getInstance(document, fileout);

    Font fuente = new Font();
    Font fuente2 = new Font();
    Font fuente3 = new Font();

    // fuente.setColor(BaseColor.BLUE);
    fuente.setStyle(Font.UNDERLINE | Font.BOLDITALIC);
    fuente2.setStyle(Font.BOLD);
    fuente2.setSize(12);
    fuente3.setSize(20);
    fuente3.setStyle(Font.BOLD);

    document.open();
    document.add(new Paragraph("\n \n \n \n \n"));
    document.add(new Paragraph("Clinica Mdica INFTEL", fuente3));

    String imageUrl = "src/Imagen/logo.png";
    //  String imagen="src\Imagen\logo.png"; 
    Image image = Image.getInstance(imageUrl);
    image.setAbsolutePosition(300, 750);
    image.scalePercent(80f);
    document.add(image);

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

    document.add(new Paragraph("DATOS DEL PACIENTE", fuente));
    document.add(new Paragraph(" "));
    document.add(
            new Paragraph("Apellidos y Nombre : " + paciente.getApellidos() + ", " + paciente.getNombre()));
    document.add(new Paragraph("NIF : " + paciente.getNif()));
    document.add(new Paragraph("NSS : " + paciente.getNumSS()));
    document.add(new Paragraph("Direccion : " + paciente.getDireccion()));
    document.add(new Paragraph("Telefono : " + paciente.getTelefono()));
    document.add(new Paragraph("Email : " + paciente.getEmail()));
    document.add(new Paragraph("ID Paciente : " + idPaciente));

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

    document.add(new Paragraph("DATOS ", fuente));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    document.add(new Paragraph("Prueba : ", fuente2));
    document.add(new Paragraph(Prueba));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    document.add(new Paragraph("Causa : ", fuente2));
    document.add(new Paragraph(Causa));
    document.add(new Paragraph(" "));
    document.add(new Paragraph(" "));

    absText(writer, time, 450, 50);

    document.close();
    File myfile = new File("PaseServicio" + timename + ".pdf");
    Desktop.getDesktop().open(myfile);
}

From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java

License:Apache License

private PdfPCell createHeaderCell(String content) {
    Paragraph paragraph = new Paragraph();
    Font font = new Font();
    font.setColor(BaseColor.WHITE);//from  w  w w  . j  a va 2  s  .c  om
    paragraph.setFont(font);
    paragraph.add(new Phrase(content));
    PdfPCell cell = new PdfPCell(paragraph);
    cell.setPaddingBottom(10);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBackgroundColor(BaseColor.GRAY);
    return cell;
}

From source file:fr.ybonnel.breizhcamppdf.PdfRenderer.java

License:Apache License

private List<Talk> createProgrammePages() throws DocumentException, IOException {
    List<Talk> talksToExplain = new ArrayList<>();
    document.setPageSize(PageSize.A4.rotate());
    Font font = new Font();
    font.setStyle(Font.BOLD);/*from  w w w. j a va 2 s . c  om*/
    font.setSize(14);

    for (String date : service.getDates()) {

        Set<String> tracksInPage = new HashSet<>();

        Map<String, Talk> precedentTalk = new HashMap<>();
        PdfPTable table = createBeginningOfPage(font, date);
        for (String creneau : service.getCreneaux().get(date)) {
            // Nouvelle page  14h
            if (creneau.startsWith("14:00") && !tracksInPage.isEmpty()) {
                document.add(table);

                addLegend(tracksInPage);
                table = createBeginningOfPage(font, date);
            }

            PdfPCell cellCreneau = new PdfPCell();
            cellCreneau.setPaddingBottom(10);
            Paragraph startTime = new Paragraph(creneau);
            startTime.setAlignment(Element.ALIGN_CENTER);
            cellCreneau.addElement(startTime);
            Paragraph endTime = new Paragraph(getEndTime(date, creneau));
            endTime.setAlignment(Element.ALIGN_CENTER);
            cellCreneau.addElement(endTime);
            table.addCell(cellCreneau);
            for (String room : service.getRooms(date)) {
                PdfPCell cell = new PdfPCell();
                cell.setPaddingBottom(10);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);

                Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room);
                if (talk != null) {
                    talksToExplain.add(talk);
                    remplirCellWithTalk(cell, talk);
                    cell.setRowspan(getRowSpan(date, talk));
                    precedentTalk.put(room, talk);
                    tracksInPage.add(talk.getTrack());
                    table.addCell(cell);
                } else {
                    talk = precedentTalk.get(room);
                    if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) {
                        table.addCell(cell);
                    }
                }
            }
        }
        document.add(table);
        addLegend(tracksInPage);
    }
    return talksToExplain;
}

From source file:fr.ybonnel.breizhcamppdf.RoomPdfRenderer.java

License:Apache License

private List<Talk> createProgrammePages() throws DocumentException, IOException {
    List<Talk> talksToExplain = new ArrayList<>();
    document.setPageSize(PageSize.A4);/*from w  ww  .  j ava2s.c  o  m*/
    Font font = new Font();
    font.setStyle(Font.BOLD);
    font.setSize(14);

    for (String date : service.getDates()) {

        for (String room : service.getRooms(date)) {

            Set<String> tracksInPage = new HashSet<>();

            Map<String, Talk> precedentTalk = new HashMap<>();
            PdfPTable table = createBeginningOfPage(font, date, room);
            for (String creneau : service.getCreneaux().get(date)) {

                PdfPCell cellCreneau = new PdfPCell();
                cellCreneau.setPaddingBottom(10);
                Paragraph startTime = new Paragraph(creneau);
                startTime.setAlignment(Element.ALIGN_CENTER);
                cellCreneau.addElement(startTime);
                Paragraph endTime = new Paragraph(getEndTime(date, creneau));
                endTime.setAlignment(Element.ALIGN_CENTER);
                cellCreneau.addElement(endTime);
                table.addCell(cellCreneau);

                PdfPCell cell = new PdfPCell();
                cell.setPaddingBottom(10);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);

                Talk talk = service.getTalkByDateAndCreneauxAndRoom(date, creneau, room);
                if (talk != null) {
                    talksToExplain.add(talk);
                    remplirCellWithTalk(cell, talk);
                    cell.setRowspan(getRowSpan(date, talk));
                    precedentTalk.put(room, talk);
                    tracksInPage.add(talk.getTrack());
                    table.addCell(cell);
                } else {
                    talk = precedentTalk.get(room);
                    if (!(talk != null && talk.getEnd().compareTo(creneau) > 0)) {
                        table.addCell(cell);
                    }
                }

            }
            document.add(table);
            addLegend(tracksInPage);
        }
    }
    return talksToExplain;
}

From source file:GUI.Framenewventa.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    if (jLabel17.getText().toString().equals("-")) {
        JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE");
    } else {/*from w  w  w. ja  v a2 s .  c  o  m*/

        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            funciones f = new funciones();
            String dia = (Calendar.getInstance().getTime().getDate() < 10)
                    ? "0" + Calendar.getInstance().getTime().getDate()
                    : Calendar.getInstance().getTime().getDate() + "";
            String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1));
            String anio = (Calendar.getInstance().getTime().getYear() + 1900) + "";

            String nombre = "COTIZACION TIENDA ULTIMO ROUND";
            String rut_socio = "";
            int mon = 0;
            String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf";
            DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            String stringToEncrypt = nombre.trim() + dateFormat.format(date);

            int encryptedString = stringToEncrypt.trim().hashCode();
            String aRemplazar = Integer.toString(encryptedString);
            String remplazado = aRemplazar.replace("-", "");

            String url = f.getRutaCotizacion() + arch;
            FileOutputStream archivo = new FileOutputStream(url);

            int deuda = Integer.parseInt("1");

            String palabra = f.Convertir(deuda + "", false);

            palabra = palabra.substring(0, palabra.length() - 2);
            if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones")
                    | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) {
                palabra = palabra + "de pesos";
            } else {
                palabra = palabra + "pesos";
            }

            Document documento = new Document(PageSize.LETTER);
            PdfWriter.getInstance(documento, archivo);
            documento.open();
            try {
                Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png");
                im.setAlignment(Image.ALIGN_CENTER);
                im.scaleToFit(600, 400);
                documento.add(im);
            } catch (Exception e) {
                setCursor(Cursor.getDefaultCursor());

                JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.",
                        "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE);

            }

            int linea = 0;
            Font fuente = new Font();
            fuente.setStyle(Font.UNDERLINE | Font.BOLD);
            fuente.setSize(11);
            fuente.setColor(BaseColor.BLACK);
            documento.add(new Paragraph(" "));
            Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n",
                    FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK));
            fecha.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(fecha);
            Paragraph obp = new Paragraph("ULTIMO ROUND\n",
                    FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK));
            obp.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(obp);
            Paragraph codigo = new Paragraph("COD." + remplazado,
                    FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK));
            codigo.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(codigo);
            Paragraph space = new Paragraph("\n",
                    FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK));
            space.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(space);
            Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            origen.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(origen);
            Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            origen2.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(origen2);
            Paragraph a = new Paragraph(nombre,
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            a.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(a);
            Paragraph rut = new Paragraph(rut_socio,
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            rut.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(rut);
            Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n",
                    FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK));
            ref.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(ref);

            documento.add(space);
            int numerocheque = 0;
            int montofinal = 0;
            String montostring = "";
            String detalle = "";
            String monto = jLabel22.getText();

            String montoaux = monto.replace(".", "");

            deuda = Integer.parseInt(montoaux);

            palabra = f.Convertir(deuda + "", false);
            System.out.println(palabra);
            palabra = palabra.replaceAll("0", "");
            System.out.println(palabra);
            Paragraph e = new Paragraph(
                    "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos"
                            + " por el monto de $" + monto + ".- ( " + palabra
                            + "pesos IVA INCLUIDO) ,segn detalle:\n\n",
                    FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK));
            e.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(e);
            documento.add(new Paragraph(" "));
            // ACA DEBE IR LA TABLA
            //special font sizes
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10);
            //specify column widths

            //create PDF table with the given widths

            documento.add(new Paragraph(" "));
            float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f };
            PdfPTable tabla = new PdfPTable(5);
            tabla.setWidths(colsWidth);
            String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" };

            tabla.setWidthPercentage(100);
            PdfPCell celda;
            for (int k = 0; k < titulos.length; k++) {
                celda = new PdfPCell(new Paragraph(titulos[k],
                        FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
            }
            int var = 0;
            int w = 0;
            for (w = 0; w < jTable1.getRowCount(); w++) {
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);

            }
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("MONTO NETO",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph(monto,
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("IVA TOTAL",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            double iva2 = Float.parseFloat(monto) * (0.19);
            iva2 = Math.round(iva2);

            celda = new PdfPCell(new Paragraph(Double.toString(iva2),
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("VALOR TOTAL",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            int valortotal = Integer.parseInt(monto);
            ;
            celda = new PdfPCell(new Paragraph(Integer.toString(valortotal),
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            documento.add(tabla);
            //FOOOTER
            documento.add(space);
            Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            despido.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(despido);
            documento.add(space);

            Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            firma2.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(firma2);
            documento.add(space);
            documento.add(space);
            documento.add(space);
            Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            firma3.setAlignment(Paragraph.ALIGN_CENTER);
            documento.add(firma3);
            documento.add(space);
            documento.add(space);
            try {
                Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png");
                im.setAlignment(Image.ALIGN_CENTER);
                im.scaleToFit(600, 500);
                documento.add(im);
            } catch (Exception ex) {
                setCursor(Cursor.getDefaultCursor());

                JOptionPane.showConfirmDialog(null,
                        "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR",
                        JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE);

            }
            documento.close();

            setCursor(Cursor.getDefaultCursor());

            JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN",
                    JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE);
        } catch (Exception ex) {
            setCursor(Cursor.getDefaultCursor());

            JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }

    }

}

From source file:GUI.frameNewVentaKit.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

    if (jLabel17.getText().toString().equals("-")) {
        JOptionPane.showMessageDialog(rootPane, "DEBE SELECCIONAR UN CLIENTE");
    } else {//from ww  w .  j  ava2 s.com

        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

            funciones f = new funciones();
            String dia = (Calendar.getInstance().getTime().getDate() < 10)
                    ? "0" + Calendar.getInstance().getTime().getDate()
                    : Calendar.getInstance().getTime().getDate() + "";
            String mes = f.get_mesMay((Calendar.getInstance().getTime().getMonth() + 1));
            String anio = (Calendar.getInstance().getTime().getYear() + 1900) + "";

            String nombre = "COTIZACION TIENDA ULTIMO ROUND";
            String rut_socio = "";
            int mon = 0;
            String arch = Calendar.getInstance().getTimeInMillis() + "_" + nombre + ".pdf";
            DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
            Date date = new Date();
            String stringToEncrypt = nombre.trim() + dateFormat.format(date);

            int encryptedString = stringToEncrypt.trim().hashCode();
            String aRemplazar = Integer.toString(encryptedString);
            String remplazado = aRemplazar.replace("-", "");

            String url = f.getRutaCotizacion() + arch;
            FileOutputStream archivo = new FileOutputStream(url);

            int deuda = Integer.parseInt("1");

            String palabra = f.Convertir(deuda + "", false);

            palabra = palabra.substring(0, palabra.length() - 2);
            if (palabra.split(" ")[palabra.split(" ").length - 1].equals("millones")
                    | palabra.split(" ")[palabra.split(" ").length - 1].equals("milln")) {
                palabra = palabra + "de pesos";
            } else {
                palabra = palabra + "pesos";
            }

            Document documento = new Document(PageSize.LETTER);
            PdfWriter.getInstance(documento, archivo);
            documento.open();
            try {
                Image im = Image.getInstance(f.getRutaCotizacion() + "headerword.png");
                im.setAlignment(Image.ALIGN_CENTER);
                im.scaleToFit(600, 400);
                documento.add(im);
            } catch (Exception e) {
                setCursor(Cursor.getDefaultCursor());

                JOptionPane.showConfirmDialog(null, "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL ENCABEZADO.",
                        "ERROR", JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE);

            }

            int linea = 0;
            Font fuente = new Font();
            fuente.setStyle(Font.UNDERLINE | Font.BOLD);
            fuente.setSize(11);
            fuente.setColor(BaseColor.BLACK);
            documento.add(new Paragraph(" "));
            Paragraph fecha = new Paragraph(dia + " de " + mes.toLowerCase() + " de " + anio + "\n",
                    FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK));
            fecha.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(fecha);
            Paragraph obp = new Paragraph("ULTIMO ROUND\n",
                    FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK));
            obp.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(obp);
            Paragraph codigo = new Paragraph("COD." + remplazado,
                    FontFactory.getFont("times new roman", 8, Font.NORMAL, BaseColor.BLACK));
            codigo.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(codigo);
            Paragraph space = new Paragraph("\n",
                    FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK));
            space.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(space);
            Paragraph origen = new Paragraph("ESTIMADO CLIENTE: " + jLabel13.getText() + "\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            origen.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(origen);
            Paragraph origen2 = new Paragraph("EMAIL: " + jLabel15.getText() + "\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            origen2.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(origen2);
            Paragraph a = new Paragraph(nombre,
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            a.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(a);
            Paragraph rut = new Paragraph(rut_socio,
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            rut.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(rut);
            Paragraph ref = new Paragraph("REF:COTIZACION POR PRODUCTOS TIENDA ULTIMO ROUND\n",
                    FontFactory.getFont("times new roman", 10, Font.BOLD, BaseColor.BLACK));
            ref.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(ref);

            documento.add(space);
            int numerocheque = 0;
            int montofinal = 0;
            String montostring = "";
            String detalle = "";
            String monto = jLabel22.getText();

            String montoaux = monto.replace(".", "");

            deuda = Integer.parseInt(montoaux);

            palabra = f.Convertir(deuda + "", false);
            System.out.println(palabra);
            palabra = palabra.replaceAll("0", "");
            System.out.println(palabra);
            Paragraph e = new Paragraph(
                    "Junto con saludarlo, adjunto la cotizacin detallada de los siguientes productos"
                            + " por el monto de $" + monto + ".- ( " + palabra
                            + "pesos IVA INCLUIDO) ,segn detalle:\n\n",
                    FontFactory.getFont("times new roman", 11, Font.NORMAL, BaseColor.BLACK));
            e.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(e);
            documento.add(new Paragraph(" "));
            // ACA DEBE IR LA TABLA
            //special font sizes
            Font bfBold10 = new Font(Font.FontFamily.TIMES_ROMAN, 10, Font.BOLD, new BaseColor(0, 0, 0));
            Font bf10 = new Font(Font.FontFamily.TIMES_ROMAN, 10);
            //specify column widths

            //create PDF table with the given widths

            documento.add(new Paragraph(" "));
            float[] colsWidth = { 1.5f, 1.5f, 1.5f, 1.5f, 1.5f };
            PdfPTable tabla = new PdfPTable(5);
            tabla.setWidths(colsWidth);
            String[] titulos = { "PRODUCTO", "VALOR PRODUCTO", "TIPO", "MARCA", "TALLA" };

            tabla.setWidthPercentage(100);
            PdfPCell celda;
            for (int k = 0; k < titulos.length; k++) {
                celda = new PdfPCell(new Paragraph(titulos[k],
                        FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
            }
            int var = 0;
            int w = 0;
            for (w = 0; w < jTable1.getRowCount(); w++) {
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 1).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 7).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 4).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 3).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);
                celda = new PdfPCell(new Paragraph(jTable1.getValueAt(w, 2).toString(), FontFactory
                        .getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
                celda.setHorizontalAlignment(Element.ALIGN_CENTER);
                tabla.addCell(celda);

            }
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("MONTO NETO",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph(monto,
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("IVA TOTAL",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            double iva2 = Float.parseFloat(monto) * (0.19);
            iva2 = Math.round(iva2);

            celda = new PdfPCell(new Paragraph(Double.toString(iva2),
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            celda = new PdfPCell(new Paragraph("",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);

            celda = new PdfPCell(new Paragraph("VALOR TOTAL",
                    FontFactory.getFont("times new roman", 10, java.awt.Font.BOLD, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            int valortotal = Integer.parseInt(monto);

            celda = new PdfPCell(new Paragraph(Integer.toString(valortotal),
                    FontFactory.getFont("times new roman", 10, java.awt.Font.ROMAN_BASELINE, BaseColor.BLACK)));
            celda.setHorizontalAlignment(Element.ALIGN_CENTER);
            tabla.addCell(celda);
            documento.add(tabla);
            //FOOOTER
            documento.add(space);
            Paragraph despido = new Paragraph("Quedando a vuestra disposicin, saluda atentamente a Ud.,\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            despido.setAlignment(Paragraph.ALIGN_LEFT);
            documento.add(despido);
            documento.add(space);

            Paragraph firma2 = new Paragraph("TIENDA ULTIMO ROUND\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            firma2.setAlignment(Paragraph.ALIGN_RIGHT);
            documento.add(firma2);
            documento.add(space);
            documento.add(space);
            documento.add(space);
            Paragraph firma3 = new Paragraph("Cotizacin vlida por siete das\n",
                    FontFactory.getFont("times new roman", 10, Font.NORMAL, BaseColor.BLACK));
            firma3.setAlignment(Paragraph.ALIGN_CENTER);
            documento.add(firma3);
            documento.add(space);
            documento.add(space);
            try {
                Image im = Image.getInstance(f.getRutaCotizacion() + "footerword.png");
                im.setAlignment(Image.ALIGN_CENTER);
                im.scaleToFit(600, 500);
                documento.add(im);
            } catch (Exception ex) {
                setCursor(Cursor.getDefaultCursor());

                JOptionPane.showConfirmDialog(null,
                        "HA OCURRIDO UN ERROR AL INTENTAR AGREGAR EL PIE DE PAGINA.", "ERROR",
                        JOptionPane.PLAIN_MESSAGE, JOptionPane.ERROR_MESSAGE);

            }
            documento.close();

            setCursor(Cursor.getDefaultCursor());

            JOptionPane.showConfirmDialog(null, "REALIZADO CORRECTAMENTE", "INFORMACIN",
                    JOptionPane.PLAIN_MESSAGE, JOptionPane.INFORMATION_MESSAGE);
        } catch (Exception ex) {
            setCursor(Cursor.getDefaultCursor());

            JOptionPane.showConfirmDialog(null, "ERROR" + ex.getMessage(), "ERROR", JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.ERROR_MESSAGE);
        }

    }

}

From source file:informes.InformeActividad.java

public void generarInforme() {
    try {/*from  ww w.ja va  2  s  . c  o  m*/
        Document document = new Document();
        Paragraph ParrafoHoja = new Paragraph();
        String parrafo = this.getDescripsion();
        String ruta = ec.getRealPath("img");
        PdfWriter.getInstance(document, new FileOutputStream(ruta + "\\" + "actividades.pdf"));

        Font fuente = new Font();
        fuente.setColor(255, 0, 0);
        fuente.setSize(30);

        Font fuente3 = new Font();
        fuente3.setColor(255, 255, 255);
        fuente3.setSize(30);

        PdfPTable tabla2 = new PdfPTable(1);
        tabla2.getDefaultCell().setBackgroundColor(BaseColor.BLUE);
        tabla2.setWidthPercentage(110f);
        tabla2.addCell(new Paragraph("UNIDAD EDUCATIVA", fuente3));
        tabla2.addCell(new Paragraph("'MISIONEROS OBLATOS'", fuente3));

        Paragraph p = new Paragraph(parrafo, fuente);

        agregarLineasEnBlanco(ParrafoHoja, 3);

        document.open();
        document.add(tabla2);
        document.add(p);
        document.add(ParrafoHoja);
        Font fuente1 = new Font();
        fuente1.setColor(0, 0, 0);
        fuente1.setSize(5);

        Font fuente2 = new Font();
        fuente2.setColor(255, 0, 0);
        fuente2.setSize(5);
        PdfPTable tabla = new PdfPTable(5);
        tabla.setWidthPercentage(107f);

        Font fuente4 = new Font();
        fuente4.setColor(0, 0, 0);
        fuente4.setSize(8);

        // Paragraph p4 = new Paragraph(parrafo, fuente4);

        //tabla.addCell(new Paragraph("OBJESTRATEGICO",fuente2));
        tabla.addCell(new Paragraph("RESPONSABLE", fuente2));
        tabla.addCell(new Paragraph("CONTROL", fuente2));
        tabla.addCell(new Paragraph("FECHA INICIO", fuente2));
        tabla.addCell(new Paragraph("FECHA FIN", fuente2));
        tabla.addCell(new Paragraph("AVANCE", fuente2));
        int cont = 0;
        tabla.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
        for (int i = 0; i < this.getItems().size(); i++) {
            // Paragraph p1 =new Paragraph(parrafo,fuente);
            String num = String.valueOf(i);
            Paragraph p4 = new Paragraph("Objetivo: " + num + " --> " + this.getItems().get(i).getNombre(),
                    fuente4);
            document.add(p4);
            Paragraph p8 = new Paragraph();
            agregarLineasEnBlanco(p8, 1);
            document.add(p8);

            for (Actividad a : this.getItems().get(i).getActividadCollection()) {
                System.out.println("");
                if (a.getIdObjetivoEstrategico()
                        .getIdObjetivoEstrategico() == (this.getItems().get(i).getIdObjetivoEstrategico())) {
                    cont = 1;
                    tabla.addCell(new Paragraph(a.getIdObjetivoEstrategico().getNombre(), fuente1));

                    tabla.addCell(new Paragraph(a.getIdPersonaResponsable().getNombre(), fuente1));
                    tabla.addCell(new Paragraph(a.getControl(), fuente1));
                    tabla.addCell(new Paragraph(a.getFechaInicio().toString(), fuente1));
                    tabla.addCell(new Paragraph(a.getFechaFin().toString(), fuente1));
                    tabla.addCell(new Paragraph(a.getAvance().toString(), fuente1));

                }
            }
            Paragraph p7 = new Paragraph();
            if (cont == 1) {
                document.add(tabla);
                cont = 0;
                agregarLineasEnBlanco(p7, 2);
                document.add(p7);
            } else {
                Font fuente5 = new Font();
                fuente5.setColor(0, 0, 255);
                fuente5.setSize(10);

                document.add(new Paragraph("No contiene actividades registradas", fuente5));
                agregarLineasEnBlanco(p7, 2);
                document.add(p7);
            }
        }

        document.add(new Paragraph(new Date().toString()));

        document.close();
        System.out.println("aquiiiiii");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(InformeActividad.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(InformeActividad.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(InformeActividad.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:informes.InformeObjEs.java

public void generarInforme() {
    try {/*from   w w w . ja  v  a  2 s  .co m*/
        Document document = new Document();
        Paragraph ParrafoHoja = new Paragraph();
        String parrafo = this.getDescripsion();
        String ruta = ec.getRealPath("img");
        PdfWriter.getInstance(document, new FileOutputStream(ruta + "\\" + "objEstra.pdf"));

        Font fuente = new Font();
        fuente.setColor(255, 0, 0);
        fuente.setSize(30);

        Font fuente3 = new Font();
        fuente3.setColor(255, 255, 255);
        fuente3.setSize(30);
        PdfPTable tabla2 = new PdfPTable(1);
        tabla2.getDefaultCell().setBackgroundColor(BaseColor.BLUE);
        tabla2.setWidthPercentage(110f);
        tabla2.addCell(new Paragraph("UNIDAD EDUCATIVA", fuente3));
        tabla2.addCell(new Paragraph("'MISIONEROS OBLATOS'", fuente3));

        Paragraph p = new Paragraph(parrafo, fuente);

        agregarLineasEnBlanco(ParrafoHoja, 3);

        document.open();
        document.add(tabla2);
        document.add(p);
        document.add(ParrafoHoja);
        Font fuente1 = new Font();
        fuente1.setColor(0, 0, 0);
        fuente1.setSize(5);

        Font fuente2 = new Font();
        fuente2.setColor(255, 0, 0);
        fuente2.setSize(5);
        PdfPTable tabla = new PdfPTable(8);
        tabla.setWidthPercentage(107f);

        tabla.addCell(new Paragraph("OBJETIVO", fuente2));
        tabla.addCell(new Paragraph("META", fuente2));
        tabla.addCell(new Paragraph("DEFINICION", fuente2));
        tabla.addCell(new Paragraph("ACLARACION", fuente2));
        tabla.addCell(new Paragraph("CONCEPTUALIZACION", fuente2));
        tabla.addCell(new Paragraph("INDICADOR", fuente2));
        tabla.addCell(new Paragraph("FORMULA", fuente2));
        tabla.addCell(new Paragraph("UNIDADES", fuente2));

        tabla.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
        for (int i = 0; i < this.getItems().size(); i++) {
            // Paragraph p1 =new Paragraph(parrafo,fuente);

            System.out.println("aquiiiiiiiiiiii" + this.getItems().get(i).getSemaforo());

            tabla.addCell(new Paragraph(this.getItems().get(i).getObjetivoestrategico().getNombre(), fuente1));
            tabla.addCell(new Paragraph(this.getItems().get(i).getMeta(), fuente1));
            tabla.addCell(new Paragraph(this.getItems().get(i).getDefinicion(), fuente1));
            tabla.addCell(new Paragraph(this.getItems().get(i).getAclaracion(), fuente1));
            tabla.addCell(new Paragraph(this.getItems().get(i).getConceptualizacion(), fuente1));
            tabla.addCell(new Paragraph(this.getItems().get(i).getIndicador().getNombre(), fuente1));
            tabla.addCell(new Paragraph(this.getItems().get(i).getIndicador().getFormula(), fuente1));
            tabla.addCell(new Paragraph(String.valueOf(this.getItems().get(i).getIndicador().getUnidades()),
                    fuente1));
        }
        document.add(tabla);
        document.add(new Paragraph(new Date().toString()));

        document.close();
        System.out.println("aquiiiiii");
    } catch (FileNotFoundException ex) {
        Logger.getLogger(InformeObjEs.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DocumentException ex) {
        Logger.getLogger(InformeObjEs.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(InformeObjEs.class.getName()).log(Level.SEVERE, null, ex);
    }
}