Example usage for com.itextpdf.text BaseColor RED

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

Introduction

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

Prototype

BaseColor RED

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

Click Source Link

Usage

From source file:EmployeeInfo.java

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

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

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

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

}

From source file:ApplicationClasses.Reservation.ReservationInvoice.java

public void generatePDFinvoice(ReservationCustomer cus) throws Exception {

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    Calendar c = Calendar.getInstance();
    c.add(Calendar.DAY_OF_YEAR, 0);
    String date2 = dateFormat.format(c.getTime());

    Document doc = new Document();
    PdfWriter.getInstance(doc, new FileOutputStream(this.invoiceNo + ".pdf"));
    doc.open();/* w  ww  . j a v  a  2s.  co m*/
    doc.add(new Paragraph("CREATE TOURS PVT LTD",
            FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD, BaseColor.RED)));

    Paragraph p = new Paragraph();

    p.add("Reservation Invoice");
    p.add("\n INVOICE DATE : " + date2);

    p.setAlignment(Paragraph.ALIGN_CENTER);
    doc.add(p);
    doc.add(new Paragraph(cus.getCustomerName()));
    doc.add(new Paragraph(
            "-------------------------------------------------------------------------------------------------------------------------------"));
    //doc.add(new Paragraph("Deposit : " + this.deposit.toString() + "\t Resvation Start Date : " + this.reservationEndDate + "\t Reservation End Date : "+this.reservationEndDate  ));
    PdfPTable table = new PdfPTable(4);
    table.addCell("No");
    table.addCell("Description");
    table.addCell("VehicalRegNo");
    table.addCell("Price");
    for (int i = 0; i < invoiceDataArray.size(); i++) {
        Integer no = i + 1;

        table.addCell(no.toString());
        table.addCell(invoiceDataArray.get(i).getDescription());
        table.addCell(invoiceDataArray.get(i).getRegNo());
        table.addCell(invoiceDataArray.get(i).getPrice().toString());
    }
    doc.add(table);

    doc.add(new Paragraph("Total Cost :" + this.totalPrice.toString()));
    doc.add(new Paragraph("Deposit : " + this.deposit.toString()));
    doc.add(new Paragraph("Resvation Start Date : " + this.reservationStartDate));
    doc.add(new Paragraph("Reservation End Date : " + this.reservationEndDate));

    doc.close();
}

From source file:bemyguest.controller.ValidationResevation.java

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

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

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

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

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

                LoadData();
                setCellTable();

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

                alert.showAndWait();

                try {

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

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

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

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

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

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

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

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

                alert.showAndWait();

                LoadData();
                setCellTable();
            }
        }

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

}

From source file:biblioteca.reportes.PdfCreator.java

License:Open Source License

/**
 * createPdf es una funcin estatica que funciona como plantilla para generar
 * reportes dinamicos, segn la necesidad del usuario.
 * @param path La direccin del archivo donde se guardar el pdf
 * @param titulo El Ttulo que llevar el pdf
 * @param encabezado Un texto que se mostrar bajo el ttulo
 * @param tabla La tabla de resultados que mostrar el pdf
 *///  ww w .j  a  v a 2s.  c o  m
static public void createPdf(String path, String titulo, String encabezado, PdfPTable tabla) {
    Document document = new Document();
    // step 2
    try {
        PdfWriter.getInstance(document, new FileOutputStream(path));
        Font myFontTitle = new Font();
        myFontTitle.setFamily("Arial");
        myFontTitle.setStyle(Font.BOLD);
        myFontTitle.setSize(14);
        Font Univallef = new Font();
        Univallef.setColor(BaseColor.RED);
        Univallef.setFamily("Arial");
        Univallef.setSize(18);
        Image header = Image
                .getInstance(PdfCreator.class.getResource("/biblioteca/gui/resources/minilogo.png"));
        header.setAlignment(Image.ALIGN_CENTER);
        header.scaleToFit(50, 75);
        Paragraph Univalle = new Paragraph("Universidad del Valle", Univallef);
        Univalle.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph pTitulo = new Paragraph(titulo, myFontTitle);
        pTitulo.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph biblioteca = new Paragraph("Biblioteca Digital EISC", myFontTitle);
        biblioteca.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph developers = new Paragraph(
                "Desarrollado por:\n Mara Cristina Bustos \n Alejandro Valds Villada", myFontTitle);
        developers.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph Fecha = new Paragraph("Fecha y Hora del Reporte: " + fecha, myFontTitle);
        document.open();
        // step 4
        document.add(header);
        document.add(new Paragraph("\r\n"));
        document.add(Univalle);
        document.add(new Paragraph("\r\n"));
        document.add(pTitulo);
        document.add(new Paragraph("\r\n"));
        document.add(biblioteca);
        document.add(new Paragraph("\r\n"));
        document.add(developers);
        document.add(new Paragraph("\r\n"));
        document.add(Fecha);
        document.add(new Paragraph("\r\n"));
        document.add(new Paragraph(encabezado + (tabla.getRows().size() - 1)));
        document.add(new Paragraph("\r\n"));
        document.add(tabla);
        // step 5
        document.close();
    } catch (DocumentException de) {
        System.err.println(de);
    } catch (IOException ioex) {
        System.err.println(ioex);
    }
}

From source file:biblioteca.reportes.PdfCreator.java

License:Open Source License

static public void createArrayListPdf(String path, String titulo, String encabezado,
        ArrayList<PdfPTable> tablas) {
    Document document = new Document();
    ArrayList<String> NombreTablas = new DaoReportesEstadisticas().getNombreTablas();
    //step 2// w  ww  .j  av a2  s .  com
    try {
        PdfWriter.getInstance(document, new FileOutputStream(path));
        Font myFontTitle = new Font();
        myFontTitle.setFamily("Arial");
        myFontTitle.setStyle(Font.BOLD);
        myFontTitle.setSize(12);
        Font Univallef = new Font();
        Univallef.setColor(BaseColor.RED);
        Univallef.setFamily("Arial");
        Univallef.setSize(18);
        Image header = Image
                .getInstance(PdfCreator.class.getResource("/biblioteca/gui/resources/minilogo.png"));
        header.setAlignment(Image.ALIGN_CENTER);
        header.scaleToFit(50, 75);
        Paragraph Univalle = new Paragraph("Universidad del Valle", Univallef);
        Univalle.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph pTitulo = new Paragraph(titulo, myFontTitle);
        pTitulo.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph biblioteca = new Paragraph("Biblioteca Digital EISC", myFontTitle);
        biblioteca.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph developers = new Paragraph(
                "Desarrollado por:\n Mara Cristina Bustos \n Alejandro Valds Villada", myFontTitle);
        developers.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph Fecha = new Paragraph("Fecha y Hora de Reporte: " + fecha, myFontTitle);
        document.open();
        // step 4
        document.add(header);
        document.add(new Paragraph("\r\n"));
        document.add(Univalle);
        document.add(new Paragraph("\r\n"));
        document.add(pTitulo);
        document.add(new Paragraph("\r\n"));
        document.add(biblioteca);
        document.add(new Paragraph("\r\n"));
        document.add(developers);
        document.add(new Paragraph("\r\n"));
        document.add(Fecha);
        document.add(new Paragraph("\r\n"));
        for (int i = 0; i < tablas.size(); i++) {
            document.add(new Paragraph(NombreTablas.get(i)));
            document.add(new Paragraph(encabezado + (tablas.get(i).getRows().size() - 1)));
            document.add(new Paragraph("\r\n"));
            document.add(tablas.get(i));
        }
        // step 5
        document.close();
    } catch (DocumentException de) {
        System.err.println(de);
    } catch (IOException ioex) {
        System.err.println(ioex);
    }
}

From source file:biblioteca.reportes.PdfCreator.java

License:Open Source License

static public void createDinamicPdf(String path, String titulo, String encabezado,
        ArrayList<Element> contenido) {
    Document document = new Document();
    //step 2//from   w  w w  .j  a v  a2  s  .c  o m
    try {
        PdfWriter.getInstance(document, new FileOutputStream(path));
        Font myFontTitle = new Font();
        myFontTitle.setFamily("Arial");
        myFontTitle.setStyle(Font.BOLD);
        myFontTitle.setSize(12);
        Font Univallef = new Font();
        Univallef.setColor(BaseColor.RED);
        Univallef.setFamily("Arial");
        Univallef.setSize(18);
        Image header = Image
                .getInstance(PdfCreator.class.getResource("/biblioteca/gui/resources/minilogo.png"));
        header.setAlignment(Image.ALIGN_CENTER);
        header.scaleToFit(50, 75);
        Paragraph Univalle = new Paragraph("Universidad del Valle", Univallef);
        Univalle.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph pTitulo = new Paragraph(titulo, myFontTitle);
        pTitulo.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph biblioteca = new Paragraph("Biblioteca Digital EISC", myFontTitle);
        biblioteca.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph developers = new Paragraph(
                "Desarrollado por:\n Mara Cristina Bustos \n Alejandro Valds Villada", myFontTitle);
        developers.setAlignment(Paragraph.ALIGN_CENTER);
        Paragraph Fecha = new Paragraph("Fecha y Hora de Reporte: " + fecha, myFontTitle);
        //Paragraph Introduccion = new Paragraph("Reporte de usuarios registrados");
        document.open();
        // step 4
        document.add(header);
        document.add(new Paragraph("\r\n"));
        document.add(Univalle);
        document.add(new Paragraph("\r\n"));
        document.add(pTitulo);
        document.add(new Paragraph("\r\n"));
        document.add(biblioteca);
        document.add(new Paragraph("\r\n"));
        document.add(developers);
        document.add(new Paragraph("\r\n"));
        document.add(Fecha);
        document.add(new Paragraph("\r\n"));
        // document.add(Introduccion);
        document.add(new Paragraph("\r\n"));
        for (int i = 0; i < contenido.size(); i++) {
            document.add(contenido.get(i).getClass().equals(new PdfPTable(2).getClass())
                    ? (PdfPTable) contenido.get(i)
                    : contenido.get(i));
        }
        // step 5
        document.close();
    } catch (DocumentException de) {
        System.err.println(de);
    } catch (IOException ioex) {
        System.err.println(ioex);
    }
}

From source file:br.com.ifrn.panfleto.gui.PainelCadastrar.java

public BaseColor corPagina() {
    if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Branco")) {
        return BaseColor.WHITE;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Preto")) {
        return BaseColor.BLACK;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Azul")) {
        return BaseColor.BLUE;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza Escuro")) {
        return BaseColor.DARK_GRAY;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza")) {
        return BaseColor.GRAY;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cinza Claro")) {
        return BaseColor.LIGHT_GRAY;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Magenta")) {
        return BaseColor.MAGENTA;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Laranja")) {
        return BaseColor.ORANGE;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Rosa")) {
        return BaseColor.PINK;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Vermlho")) {
        return BaseColor.RED;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Amarero")) {
        return BaseColor.YELLOW;
    } else if (comboxSelecionarCorPainelGerarPdf.getSelectedItem().equals("Cyan")) {
        return BaseColor.CYAN;
    }/*ww w.j a v a2 s  . c  o  m*/

    return BaseColor.WHITE;
}

From source file:Clases.NuevoPdf.java

private static void addTableClienteYFactura(Document doc) throws DocumentException {
    PdfPTable encabezados = new PdfPTable(2);
    encabezados.setWidthPercentage(99);//ww  w .  jav  a 2s . co  m

    PdfPCell c1 = new PdfPCell(new Phrase("CLIENTE", normalWhite));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.RED);
    c1.setBorder(0);
    encabezados.addCell(c1);

    PdfPCell c2 = new PdfPCell(new Phrase("FOLIO FISCAL", normalWhite));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    c2.setBackgroundColor(BaseColor.RED);
    c2.setBorder(0);
    encabezados.addCell(c2);

    PdfPTable datos = new PdfPTable(2);
    datos.setWidthPercentage(99);

    Paragraph rfc = new Paragraph("N de Folio: " + Variables.idFactura, medium);
    Paragraph rfc2 = new Paragraph(Variables.RFC, medium);
    Paragraph nombre = new Paragraph(Variables.NombreCliente, medium);
    Paragraph direccion = new Paragraph(Variables.delegacion, medium);
    Paragraph ciudad = new Paragraph(Variables.municipio + " " + Variables.Estado + " MEXICO", medium);
    Paragraph cp = new Paragraph("CP: " + Variables.codpostal, medium);

    Paragraph[] datosCliente = { rfc, rfc2, nombre, direccion, ciudad, cp };

    PdfPCell c3 = new PdfPCell();
    for (int i = 0; i < datosCliente.length; i++) {
        c3.addElement(datosCliente[i]);
    }
    datos.addCell(c3);

    float[] columnWidths = new float[] { 60f, 40f };
    try {
        encabezados.setWidths(columnWidths);
        datos.setWidths(columnWidths);
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }

    Paragraph folioFactura = new Paragraph("CS434-BYOR3343-GVLR03-034", smallBold);
    Paragraph csd = new Paragraph("No de serie del certificado CSD", smallBold);
    Paragraph codigo = new Paragraph("03490941023923", smallBold);
    Paragraph fecha = new Paragraph("Fecha y hora de emisin", smallBold);
    Paragraph datosfecha = new Paragraph(Variables.FechaSistema, smallBold);
    folioFactura.setAlignment(Element.ALIGN_CENTER);
    csd.setAlignment(Element.ALIGN_CENTER);
    codigo.setAlignment(Element.ALIGN_CENTER);
    fecha.setAlignment(Element.ALIGN_CENTER);
    datosfecha.setAlignment(Element.ALIGN_CENTER);

    Paragraph[] datosFactura = { folioFactura, csd, codigo, fecha, datosfecha };
    PdfPCell c4 = new PdfPCell();
    for (int i = 0; i < datosFactura.length; i++) {
        c4.addElement(datosFactura[i]);
    }
    datos.addCell(c4);

    Paragraph p = new Paragraph();
    p.add(encabezados);
    p.add(datos);
    doc.add(p);

}

From source file:Clases.NuevoPdf.java

private static void addTableProducts(Document doc) throws DocumentException {
    PdfPTable table = new PdfPTable(6);
    table.setWidthPercentage(99);/*ww w  .  j ava2 s  .  c o  m*/

    PdfPCell c1 = new PdfPCell(new Phrase("CLAVE", normalWhite));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setBackgroundColor(BaseColor.RED);
    c1.setBorder(0);
    table.addCell(c1);

    PdfPCell c2 = new PdfPCell(new Phrase("CANTIDAD", normalWhite));
    c2.setHorizontalAlignment(Element.ALIGN_CENTER);
    c2.setBackgroundColor(BaseColor.RED);
    c2.setBorder(0);
    table.addCell(c2);

    PdfPCell c3 = new PdfPCell(new Phrase("UM", normalWhite));
    c3.setHorizontalAlignment(Element.ALIGN_CENTER);
    c3.setBackgroundColor(BaseColor.RED);
    c3.setBorder(0);
    table.addCell(c3);

    PdfPCell c4 = new PdfPCell(new Phrase("DESCRIPCION", normalWhite));
    c4.setHorizontalAlignment(Element.ALIGN_CENTER);
    c4.setBackgroundColor(BaseColor.RED);
    c4.setBorder(0);
    table.addCell(c4);

    PdfPCell c5 = new PdfPCell(new Phrase("PRECIO UNITARIO", normalWhite));
    c5.setHorizontalAlignment(Element.ALIGN_CENTER);
    c5.setBackgroundColor(BaseColor.RED);
    c5.setBorder(0);
    table.addCell(c5);

    PdfPCell c6 = new PdfPCell(new Phrase("IMPORTE", normalWhite));
    c6.setHorizontalAlignment(Element.ALIGN_CENTER);
    c6.setBackgroundColor(BaseColor.RED);
    c6.setBorder(0);
    table.addCell(c6);

    float[] columnWidths = new float[] { 15f, 15f, 10f, 30f, 15f, 15f };
    try {
        table.setWidths(columnWidths);
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
    }

    for (int i = 0; i < Variables.claves.size(); i++) {
        table.addCell(new Phrase(String.valueOf(Variables.claves.get(i)), normal));
        table.addCell(new Phrase(String.valueOf(Variables.cantidades.get(i)), normal));
        table.addCell(new Phrase(String.valueOf(Variables.ums.get(i)), normal));
        table.addCell(new Phrase(String.valueOf(Variables.descripciones.get(i)), normal));
        table.addCell(new Phrase(String.valueOf(Variables.preciosunitarios.get(i)), normal));
        table.addCell(new Phrase(String.valueOf(Variables.importes.get(i)), normal));

    }

    /*table.addCell(new Phrase("R0-510055-TIM",normal));
    table.addCell(new Phrase("2.0",normal));
    table.addCell(new Phrase("PIEZAS",normal));
    table.addCell(new Phrase("BALERO DOBLE",normal));
    table.addCell(new Phrase("$336.47",normal));
    table.addCell(new Phrase("$672.94",normal));*/

    Paragraph p = new Paragraph();
    p.add(table);
    doc.add(p);

}

From source file:classes.utils.crearPDF_Depreciacion.java

public String writePDF(String datos, Scene scene)
        throws FileNotFoundException, DocumentException, BadElementException, IOException {

    javafx.scene.control.TextField projectName = (TextField) scene.lookup(CNodeID.TEXTFIELD_PROJECT_NAME);
    String project = projectName.getText();

    StringTokenizer st = new StringTokenizer(datos, "_");

    principal = st.nextToken();//from www .j a v  a  2s  .  com
    salvageV = st.nextToken();
    period = st.nextToken();
    tax = st.nextToken();
    periodSalvage = st.nextToken();
    category = st.nextToken();
    data = st.nextToken();

    Document document = new Document(PageSize.LETTER, 80, 80, 50, 50);
    FileOutputStream salida = new FileOutputStream(project + "_depreciation.pdf");
    PdfWriter writer = PdfWriter.getInstance(document, salida);
    writer.setInitialLeading(0);

    Paragraph paragraph = new Paragraph();
    paragraph.setFont(new Font(FontFactory.getFont("Courier", 20, Font.BOLDITALIC, BaseColor.RED)));
    paragraph.add("\n\n\nDEPRECIACION");
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);

    //System.out.println(getClass().getResource("images/logo_report.png"));
    //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png");

    //image.scaleToFit(150, 150);

    Image image1 = Image.getInstance(project + "/" + project + "_DEP_TY.png");

    image1.scaleToFit(300, 300);

    //image.setAlignment(Chunk.ALIGN_RIGHT);
    image1.setAlignment(Chunk.ALIGN_CENTER);

    Paragraph paragraph_2 = new Paragraph();
    paragraph_2.setFont(new Font(FontFactory.getFont("Courier", 12, Font.BOLD, BaseColor.BLUE)));
    paragraph_2.add(
            "\n\n\n\n\n\n\n\n\n\n\nADMINISTRACION Y EVALUACION DE PROYECTOS\n\n SERGIO VALDES TORRES A01365520\n ERIK MARTIN A01365096\nISAAC SECUNDINO A01361162\n IVAN CABRER A01184937");
    paragraph_2.setAlignment(Paragraph.ALIGN_RIGHT);

    Paragraph paragraph_3 = new Paragraph();
    paragraph_3.setFont(new Font(FontFactory.getFont("Courier", 11, Font.BOLD, BaseColor.BLACK)));
    paragraph_3.add("\n " + data);
    paragraph_3.setAlignment(Paragraph.ALIGN_LEFT);

    Paragraph paragraph_5 = new Paragraph();
    paragraph_5.setFont(new Font(FontFactory.getFont("Courier", 6, Font.BOLD, BaseColor.BLUE)));
    paragraph_5.add("\n\nP   DEPRECIATON RATE  ANNUAL DEPRECIATON  CUMMULATIVE DEPRECIATON  VALUE IN LEDGERS ");
    paragraph_5.setAlignment(Paragraph.ALIGN_LEFT);

    Paragraph paragraph_4 = new Paragraph();
    paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 9, Font.BOLD, BaseColor.BLACK)));
    paragraph_4.add("Nombre del Evaluador: \n Principal: " + principal + " \n Salvag Value: " + salvageV
            + " \n Numero de Periodos: " + period + "\n Tax: " + tax + " \n Salvage Period: " + periodSalvage
            + "\n Categoria: " + category);
    paragraph_4.setAlignment(Paragraph.ALIGN_LEFT);

    Paragraph paragraph_6 = new Paragraph();
    paragraph_6.setFont(new Font(FontFactory.getFont("Courier", 15, Font.BOLD, BaseColor.GRAY)));
    paragraph_6.add("\n GRAFICAS\n");
    paragraph_6.setAlignment(Paragraph.ALIGN_CENTER);

    document.open();
    //document.add(image);

    document.add(paragraph);

    document.add(paragraph_4);
    document.add(paragraph_5);
    document.add(paragraph_3);
    document.add(paragraph_6);
    Image image2 = Image.getInstance(project + "/" + project + "_DEP_DR.png");
    Image image3 = Image.getInstance(project + "/" + project + "_DEP_AD.png");
    Image image4 = Image.getInstance(project + "/" + project + "_DEP_ACD.png");
    Image image5 = Image.getInstance(project + "/" + project + "_DEP_LV.png");
    document.add(image2);
    document.add(image3);
    document.add(image4);
    document.add(image5);
    document.add(image1);
    document.add(paragraph_2);
    document.close();
    return null;

}