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: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 w w w.j  a va  2  s. c  om
    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;

}

From source file:classes.utils.createPDF_checkList.java

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

    javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene
            .lookup(CNodeID.TEXTFIELD_PROJECT_NAME);
    String project = projectName.getText();
    StringTokenizer st = new StringTokenizer(datos, "*");

    dato1 = st.nextToken();/*from w  w  w  .  j  av a  2  s . com*/
    dato2 = st.nextToken();
    dato3 = st.nextToken();
    dato4 = st.nextToken();
    dato5 = st.nextToken();
    dato6 = st.nextToken();
    dato7 = st.nextToken();
    dato8 = st.nextToken();
    dato9 = st.nextToken();
    dato10 = st.nextToken();
    dato11 = st.nextToken();
    dato12 = st.nextToken();
    dato13 = st.nextToken();
    dato14 = st.nextToken();
    dato15 = st.nextToken();
    dato16 = st.nextToken();
    dato17 = st.nextToken();

    Document document = new Document(PageSize.LETTER, 80, 80, 50, 50);
    FileOutputStream salida = new FileOutputStream(project + "_CheckList.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\nCHECK LIST");
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);

    //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png");

    //image.scaleToFit(150, 150);

    //image.setAlignment(Chunk.ALIGN_RIGHT);

    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\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_4 = new Paragraph();
    paragraph_4.setFont(new Font(FontFactory.getFont("Courier", 6, Font.BOLD, BaseColor.BLACK)));
    paragraph_4.add("Strategy---Alignment What specific organization strategy does this project align with?"
            + "     " + dato1 + "\n" + "Driver---What business problem does the project solve?" + "     "
            + dato2 + "\n" + "Success Metrics---How will measure success?" + "     " + dato3 + "\n"
            + "Sponsorship---Who is the project sponsor?" + "     " + dato4 + "\n"
            + "Risk---What is the impact of not doing this project?" + "     " + dato5 + "\n"
            + "Risk---What is the project risk to our organization?" + "     " + dato6 + "\n"
            + "Risk---Where does the proposed project fit in our risk profile?" + "     " + dato7 + "\n"
            + "Benefits, value---What is the value of the project organization?" + "     " + dato8 + "\n"
            + "Benefits, value---When will the project shows results?" + "     " + dato9 + "\n"
            + "Objectives---What are the project objectives?" + "     " + dato10 + "\n"
            + "Organization Culture---Is our organization culture right for this type of project?" + "     "
            + dato11 + "\n" + "Resources---Will internal resources be available for this project?" + "     "
            + dato12 + "\n" + "Approach---Will we build or buy?" + "     " + dato13 + "\n"
            + "Schedule---How long will this project take?" + "     " + dato14 + "\n"
            + "Schedule---Is the timeline realistic?" + "     " + dato15 + "\n"
            + "Training/Resources---Will staff training be required?" + "     " + dato16 + "\n"
            + "Finance/Portfolio---What is the estimated cost of the project?" + "     " + dato17 + "\n");
    /*+ "Portfolio---Is this a new initiative or path of an existing initiative?"+"     "+dato18+"\n"
    + "Portfolio---How does this project interact with current projects?"+"     "+dato19+"\n"
    + "Technology---Is the technology available or new?"+"     "+dato20+"");
    */

    paragraph_4.setAlignment(Paragraph.ALIGN_LEFT);

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

    document.add(paragraph);

    document.add(paragraph_4);

    document.add(paragraph_2);
    document.close();
    return "pdf Creado";

}

From source file:classes.utils.createPDF_NetPresent.java

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

    javafx.scene.control.TextField projectName = (javafx.scene.control.TextField) scene
            .lookup(CNodeID.TEXTFIELD_PROJECT_NAME);
    String project = projectName.getText();
    StringTokenizer st = new StringTokenizer(datos, "_");

    period = st.nextToken();/*from   ww w.  j av a  2  s .  c o m*/
    principal = st.nextToken();
    interestRate = st.nextToken();
    tax = st.nextToken();
    salvageV = st.nextToken();
    periodSalvage = st.nextToken();
    data = st.nextToken();

    Document document = new Document(PageSize.LETTER, 80, 80, 50, 50);
    FileOutputStream salida = new FileOutputStream(project + "_NetPresentValue.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\nNET PRESENT VALUE");
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);

    //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png");

    //image.scaleToFit(150, 150);

    Image image1 = Image.getInstance(project + "/" + project + "_NPV_CCF.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", 10, Font.BOLD, BaseColor.BLUE)));
    paragraph_5.add("\n\nP   OUTFLOW   INFLOW   NET CASH FLOW   CUMULATIVE CASH ");
    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: \nPeriods: " + period + "\n Principal: " + principal
            + " \n Interest Rate%: " + interestRate + " \n Tax Rate %: " + tax + "\n Salvage Value: " + salvageV
            + " \n Period SV: " + periodSalvage);
    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);
    document.add(image1);
    Image image2 = Image.getInstance(project + "/" + project + "_NPV_NCF.png");
    document.add(image2);
    document.add(paragraph_2);
    document.close();
    return null;

}

From source file:classes.utils.createPDF_PayBack.java

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

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

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

    period = st.nextToken();/*from  w  ww.  ja  v  a 2  s. c  o m*/
    principal = st.nextToken();
    interestRate = st.nextToken();
    data = st.nextToken();

    Document document = new Document(PageSize.LETTER, 80, 80, 50, 50);
    FileOutputStream salida = new FileOutputStream(project + "_PayBackPeriod.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\nPAYBACK PERIOD");
    paragraph.setAlignment(Paragraph.ALIGN_CENTER);
    // TODO: Change absolute to relative
    //Image image = Image.getInstance("/home/isaac/IdeaProjects/ProjectEvaluation/src/images/logo_report.png");

    //image.scaleToFit(150, 150);

    Image image1 = Image.getInstance(project + "/" + project + "_PBP_CCF.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", 10, Font.BOLD, BaseColor.BLUE)));
    paragraph_5.add("\n\nP   OUTFLOW  INFLOW  CUMMULATIVE CASH... ");
    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 Numero de Periodos: " + period
            + "\nInterest Rate %" + interestRate);
    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 + "_PBP_NCF.png");
    document.add(image1);
    document.add(image2);
    document.add(paragraph_2);
    document.close();
    return null;

}

From source file:client.welcome1.java

private void genrateItemRepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genrateItemRepButtonActionPerformed
    Document doc = new Document();
    PdfWriter docWriter = null;//from   w w w  . j ava2 s  .c om
    int repID = ThreadLocalRandom.current().nextInt(10000, 99999 + 1);
    DecimalFormat df = new DecimalFormat("0.00");
    //Date d = Calendar.getInstance().getTime();
    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = new Date();

    try {

        //special font sizes
        com.itextpdf.text.Font bfBold12 = new com.itextpdf.text.Font(FontFamily.TIMES_ROMAN, 12,
                com.itextpdf.text.Font.BOLD, new BaseColor(0, 0, 0));
        com.itextpdf.text.Font bf12 = new com.itextpdf.text.Font(FontFamily.TIMES_ROMAN, 12);

        //file path
        String dt = dateFormat.format(date);
        sFileName = "Report No- " + repID + " Items Report- " + dt + " Status " + itemRepChoice + " .pdf";
        String path = "src/ItemsReports/" + sFileName;
        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path));

        DateFormat dateFormat3 = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        String d = dateFormat3.format(Calendar.getInstance().getTime());

        //document header attributes
        doc.addCreationDate();
        doc.setPageSize(PageSize.LETTER);

        //open document
        doc.open();

        //create a paragraph
        Image image = Image.getInstance("src/Images/logo for pdf.png");
        Font font1 = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);
        Paragraph paragraph = new Paragraph();
        Paragraph paragraph2 = new Paragraph("This report was generated by " + loginGUI.username + " at " + d
                + "\nYou can see " + itemRepChoice + " Items");
        image.setAlignment(Image.RIGHT);
        doc.add(image);

        //specify column widths
        float[] columnWidths = { 2f, 2f, 2f, 3f, 2f, 2f, 2f };
        //create PDF table with the given widths
        PdfPTable table = new PdfPTable(columnWidths);
        // set table width a percentage of the page width
        table.setWidthPercentage(100f);

        //insert column headings
        insertCell(table, "Item ID", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Item Name", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Quantity", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Min Quantity Level", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Warehouse", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Row", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Shelf", Element.ALIGN_CENTER, 1, bfBold12);
        table.setHeaderRows(1);

        //insert an empty row
        /* insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);*/
        //create section heading by cell merging
        /* insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12);*/
        /*double orderTotal, total = 0;*/

        String add1, add2, add3, add4, add5, add6, add7;

        if (itemRepChoice.equals("All")) {
            try {

                String sql = "select item_id,item_name,quantity,min_quantity_level,warehouse,row,shelf from items";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("item_id");
                    add2 = rs.getString("item_name");
                    add3 = rs.getString("quantity");
                    add4 = rs.getString("min_quantity_level");
                    add5 = rs.getString("warehouse");
                    add6 = rs.getString("row");
                    add7 = rs.getString("shelf");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add6, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add7, Element.ALIGN_CENTER, 1, bf12);
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        } else if (itemRepChoice.equals("Warehouse")) {
            String wh = wareHouschoice.getSelectedItem();
            try {

                String sql = "select item_id,item_name,quantity,min_quantity_level,warehouse,row,shelf from items where warehouse='"
                        + wh + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("item_id");
                    add2 = rs.getString("item_name");
                    add3 = rs.getString("quantity");
                    add4 = rs.getString("min_quantity_level");
                    add5 = rs.getString("warehouse");
                    add6 = rs.getString("row");
                    add7 = rs.getString("shelf");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add6, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add7, Element.ALIGN_CENTER, 1, bf12);
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        } else if (itemRepChoice.equals("Min Level")) {
            String wh = wareHouschoice.getSelectedItem();
            try {

                String sql = "select item_id,item_name,quantity,min_quantity_level,warehouse,row,shelf from items where min_quantity_level>=quantity";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("item_id");
                    add2 = rs.getString("item_name");
                    add3 = rs.getString("quantity");
                    add4 = rs.getString("min_quantity_level");
                    add5 = rs.getString("warehouse");
                    add6 = rs.getString("row");
                    add7 = rs.getString("shelf");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add6, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add7, Element.ALIGN_CENTER, 1, bf12);
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }

        //add the PDF table to the paragraph 
        paragraph2.add(table);

        // add the paragraph to the document
        doc.add(new Paragraph("\nItems Status Report " + dt + "\n", font1));
        doc.add(paragraph2);
    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            //close the document
            doc.close();
            JOptionPane.showMessageDialog(null, "Report No " + repID + " Generated!");
        }
        if (docWriter != null) {
            //close the writer
            docWriter.close();
        }
    }
    saveToDB(itemRepChoice, date, repID);
}

From source file:client.welcome2.java

private void genRepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genRepButtonActionPerformed
    Document doc = new Document();
    PdfWriter docWriter = null;/* w  ww. j a  v a  2  s.c  om*/
    int repID = ThreadLocalRandom.current().nextInt(10000, 99999 + 1);
    DecimalFormat df = new DecimalFormat("0.00");
    //Date d = Calendar.getInstance().getTime();
    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = new Date();

    try {

        //special font sizes
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);

        //file path
        String dt = dateFormat.format(date);
        sFileName = "Report No- " + repID + " Project Report- " + dt + " Status " + report_status + " .pdf";
        String path = "src/ProjectReports/" + sFileName;
        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path));

        DateFormat dateFormat3 = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        String d = dateFormat3.format(Calendar.getInstance().getTime());

        //document header attributes
        doc.addCreationDate();
        doc.setPageSize(PageSize.LETTER);

        //open document
        doc.open();

        //create a paragraph
        DateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
        String sd2 = dateFormat2.format(pBeginDateChooser.getDate());
        String ed2 = dateFormat2.format(pEndDateChooser.getDate());
        Image image = Image.getInstance("src/Images/logo for pdf.png");
        Font font1 = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);
        Paragraph paragraph = new Paragraph();
        Paragraph paragraph2 = new Paragraph("This report was generated by " + loginGUI.username + " at " + d
                + "\nYou can see all projects from " + sd2 + " to " + ed2);
        image.setAlignment(Image.RIGHT);
        doc.add(image);

        //specify column widths
        float[] columnWidths = { 2f, 2f, 2f, 2f, 2f };
        //create PDF table with the given widths
        PdfPTable table = new PdfPTable(columnWidths);
        // set table width a percentage of the page width
        table.setWidthPercentage(100f);

        //insert column headings
        insertCell(table, "Project ID", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Project Name", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Start Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Due Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Status", Element.ALIGN_CENTER, 1, bfBold12);
        table.setHeaderRows(1);

        //insert an empty row
        /* insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);*/
        //create section heading by cell merging
        /* insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12);*/
        /*double orderTotal, total = 0;*/

        String add1, add2, add3, add4, add5;
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        String sd = dateFormat1.format(pBeginDateChooser.getDate());
        String ed = dateFormat1.format(pEndDateChooser.getDate());

        if (report_status.equals("All")) {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where due_date >= '"
                        + sd + "' and due_date <= '" + ed + "' and start_date >= '" + sd
                        + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        } else {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where status = '"
                        + report_status + "' and due_date >= '" + sd + "' and due_date <= '" + ed
                        + "' and start_date >= '" + sd + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }

        //add the PDF table to the paragraph
        paragraph2.add(table);

        // add the paragraph to the document
        doc.add(new Paragraph("\nProject Status Report " + dt + "\n", font1));
        doc.add(paragraph2);
    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            //close the document
            doc.close();
            JOptionPane.showMessageDialog(null, "Report No " + repID + " Generated!");
        }
        if (docWriter != null) {
            //close the writer
            docWriter.close();
        }
    }
    saveToDB(report_status, date, repID);
}

From source file:client.welcome3.java

private void genRepButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_genRepButtonActionPerformed
    Document doc = new Document();
    PdfWriter docWriter = null;/*from w  ww  .  ja v a  2s.c om*/
    int repID = ThreadLocalRandom.current().nextInt(10000, 99999 + 1);
    DecimalFormat df = new DecimalFormat("0.00");
    //Date d = Calendar.getInstance().getTime();
    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
    Date date = new Date();

    try {

        //special font sizes
        Font bfBold12 = new Font(FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0));
        Font bf12 = new Font(FontFamily.TIMES_ROMAN, 12);

        //file path
        String dt = dateFormat.format(date);
        sFileName = "Report No- " + repID + " Project Report- " + dt + " Status " + report_status + " .pdf";
        String path = "src/ProjectReports/" + sFileName;
        docWriter = PdfWriter.getInstance(doc, new FileOutputStream(path));

        DateFormat dateFormat3 = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        String d = dateFormat3.format(Calendar.getInstance().getTime());

        //document header attributes
        doc.addCreationDate();
        doc.setPageSize(PageSize.LETTER);

        //open document
        doc.open();

        //create a paragraph
        DateFormat dateFormat2 = new SimpleDateFormat("dd/MM/yyyy");
        String sd2 = dateFormat2.format(pBeginDateChooser.getDate());
        String ed2 = dateFormat2.format(pEndDateChooser.getDate());
        Image image = Image.getInstance("src/Images/logo for pdf.png");
        Font font1 = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);
        Paragraph paragraph = new Paragraph();
        Paragraph paragraph2 = new Paragraph("This report was generated by " + loginGUI.username + " at " + d
                + "\nYou can see all projects from " + sd2 + " to " + ed2);
        image.setAlignment(Image.RIGHT);
        doc.add(image);

        //specify column widths
        float[] columnWidths = { 2f, 2f, 2f, 2f, 2f };
        //create PDF table with the given widths
        PdfPTable table = new PdfPTable(columnWidths);
        // set table width a percentage of the page width
        table.setWidthPercentage(100f);

        //insert column headings
        insertCell(table, "Project ID", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Project Name", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Start Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Due Date", Element.ALIGN_CENTER, 1, bfBold12);
        insertCell(table, "Status", Element.ALIGN_CENTER, 1, bfBold12);
        table.setHeaderRows(1);

        //insert an empty row
        /* insertCell(table, "", Element.ALIGN_LEFT, 4, bfBold12);*/
        //create section heading by cell merging
        /* insertCell(table, "New York Orders ...", Element.ALIGN_LEFT, 4, bfBold12);*/
        /*double orderTotal, total = 0;*/

        String add1, add2, add3, add4, add5;
        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd");
        String sd = dateFormat1.format(pBeginDateChooser.getDate());
        String ed = dateFormat1.format(pEndDateChooser.getDate());

        if (report_status.equals("All")) {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where due_date >= '"
                        + sd + "' and due_date <= '" + ed + "' and start_date >= '" + sd
                        + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        } else {
            try {

                String sql = "select project_id,project_name,start_date,due_date,status from projects where status = '"
                        + report_status + "' and due_date >= '" + sd + "' and due_date <= '" + ed
                        + "' and start_date >= '" + sd + "'and start_date <= '" + ed + "'";
                pst = conn.prepareStatement(sql);
                rs = pst.executeQuery();
                while (rs.next()) {
                    add1 = rs.getString("project_id");
                    add2 = rs.getString("project_name");
                    add3 = dateFormat.format(rs.getDate("start_date"));
                    add4 = dateFormat.format(rs.getDate("due_date"));
                    add5 = rs.getString("status");
                    insertCell(table, add1, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add2, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add3, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add4, Element.ALIGN_CENTER, 1, bf12);
                    insertCell(table, add5, Element.ALIGN_CENTER, 1, bf12);

                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, e);

            }
        }

        //add the PDF table to the paragraph 
        paragraph2.add(table);

        // add the paragraph to the document
        doc.add(new Paragraph("\nProject Status Report " + dt + "\n", font1));
        doc.add(paragraph2);
    } catch (DocumentException dex) {
        dex.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (doc != null) {
            //close the document
            doc.close();
            JOptionPane.showMessageDialog(null, "Report No " + repID + " Generated!");
        }
        if (docWriter != null) {
            //close the writer
            docWriter.close();
        }
    }
    saveToDB(report_status, date, repID);
}

From source file:com.algoboss.erp.util.report.PDFExporter.java

License:Apache License

protected PdfPTable exportPDFTable(FacesContext context, DataTable table, boolean pageOnly,
        boolean selectionOnly, boolean filteredOnly, String encoding) {
    int columnsCount = getColumnsCount(table);
    PdfPTable pdfTable = new PdfPTable(columnsCount);
    this.cellFont = FontFactory.getFont(FontFactory.TIMES, encoding, 7, Font.NORMAL);
    this.facetFont = FontFactory.getFont(FontFactory.TIMES, encoding, 7, Font.BOLD, BaseColor.BLUE);
    this.facetBgColor = BaseColor.LIGHT_GRAY;

    addColumnFacets(table, pdfTable, ColumnType.HEADER);

    if (pageOnly) {
        exportPageOnly(context, table, pdfTable);
    } else if (selectionOnly) {
        exportSelectionOnly(context, table, pdfTable);
    } else if (filteredOnly) {
        exportFilteredOnly(context, table, pdfTable);
    } else {/*from   w w  w  . j a  v  a  2 s. c o m*/
        exportAll(context, table, pdfTable);
    }

    if (table.hasFooterColumn()) {
        addColumnFacets(table, pdfTable, ColumnType.FOOTER);
    }

    table.setRowIndex(-1);

    return pdfTable;
}

From source file:com.asae.controllers.BeanGestionRutinas.java

public void generarPdf() {
    Document document = new Document();
    try {//  w ww .j ava  2  s  .c  om
        File file = File.createTempFile("rutina-", ".pdf", new File("/var/webapp/pdf"));
        pdfFileName = file.getName();

        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
        document.open();
        Font bold = new Font(Font.FontFamily.HELVETICA, 12f, Font.BOLD);
        URL url = FacesContext.getCurrentInstance().getExternalContext()
                .getResource("/resources/img/logo-unicauca-negro.png");
        Image imgLogoUnicauca = Image.getInstance(url);
        imgLogoUnicauca.scaleAbsolute(118f, 131f);

        PdfPTable tableEncabezado = new PdfPTable(2);
        tableEncabezado.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        tableEncabezado.setWidthPercentage(100);
        tableEncabezado.setSpacingAfter(5);
        PdfPCell cell1 = new PdfPCell(imgLogoUnicauca);
        cell1.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell2 = new PdfPCell(new Paragraph("Vicerrectoria Administrativa"));
        cell2.setBorder(Rectangle.NO_BORDER);
        cell2.setVerticalAlignment(Element.ALIGN_BOTTOM);
        cell2.setHorizontalAlignment(Element.ALIGN_RIGHT);
        PdfPCell cell3 = new PdfPCell(new Paragraph("Universidad del Cauca", bold));
        cell3.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell4 = new PdfPCell(new Paragraph("Gimnasio y Actividad Fsica", bold));
        cell4.setBorder(Rectangle.NO_BORDER);
        cell4.setHorizontalAlignment(Element.ALIGN_RIGHT);
        tableEncabezado.addCell(cell1);
        tableEncabezado.addCell(cell2);
        tableEncabezado.addCell(cell3);
        tableEncabezado.addCell(cell4);

        PdfPTable tableDatosUsuario = new PdfPTable(3);
        tableDatosUsuario.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        tableDatosUsuario.setWidthPercentage(100);
        tableDatosUsuario.setSpacingBefore(20);
        PdfPCell cell5 = new PdfPCell(new Paragraph("Nombre: " + rutinaVisualizar.getIdusuario().getFisrtname()
                + " " + rutinaVisualizar.getIdusuario().getSecondname() + " "
                + rutinaVisualizar.getIdusuario().getFirstlastname() + " "
                + rutinaVisualizar.getIdusuario().getSecondlastname()));
        cell5.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell6 = new PdfPCell();
        cell6.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell7 = new PdfPCell();
        cell7.setBorder(Rectangle.NO_BORDER);

        tableDatosUsuario.addCell(cell5);
        tableDatosUsuario.addCell(cell6);
        tableDatosUsuario.addCell(cell7);

        PdfPTable tableFechas = new PdfPTable(3);
        tableFechas.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        tableFechas.setWidthPercentage(100);
        tableFechas.setSpacingBefore(10);
        PdfPCell cell8 = new PdfPCell(
                new Paragraph("Fecha de inicio: " + getMyFormattedDate(rutinaVisualizar.getFechaInicio())));
        cell8.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell9 = new PdfPCell(
                new Paragraph("Fecha de fin: " + getMyFormattedDate(rutinaVisualizar.getFechaFin())));
        cell9.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell10 = new PdfPCell();
        cell10.setBorder(Rectangle.NO_BORDER);

        tableFechas.addCell(cell8);
        tableFechas.addCell(cell9);
        tableFechas.addCell(cell10);

        PdfPTable tableMedidas = new PdfPTable(4);
        tableMedidas.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        tableMedidas.setWidthPercentage(100);
        tableMedidas.setSpacingBefore(10);

        Usuario usuAux = rutinaVisualizar.getIdusuario();
        List<Evaluacion> lstEvalAux = usuAux.getEvaluacionList();
        Evaluacion evalAux;
        double peso = 0;
        if (lstEvalAux.size() > 0) {
            evalAux = lstEvalAux.get(lstEvalAux.size() - 1);
            peso = evalAux.getPeso().doubleValue();
        }

        double estatura = 0;
        MedidasGenerales medGenAux = usuAux.getMedidasGenerales();
        if (medGenAux != null) {
            estatura = medGenAux.getEstatura().doubleValue();
        }

        PdfPCell cell11 = new PdfPCell(new Paragraph("Peso: " + peso));
        cell11.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell12 = new PdfPCell(new Paragraph("Talla: " + estatura));
        cell12.setBorder(Rectangle.NO_BORDER);

        double imc = 0;
        if (peso != 0 && estatura != 0) {
            imc = peso / Math.pow(estatura, 2);
        }

        PdfPCell cell13 = new PdfPCell(new Paragraph("I.M.C: " + imc));
        cell13.setBorder(Rectangle.NO_BORDER);
        PdfPCell cell14 = new PdfPCell(new Paragraph("Rutina: " + rutinaVisualizar.getCodigoRutina()));
        cell14.setBorder(Rectangle.NO_BORDER);

        tableMedidas.addCell(cell11);
        tableMedidas.addCell(cell12);
        tableMedidas.addCell(cell13);
        tableMedidas.addCell(cell14);

        PdfPTable tableDias = new PdfPTable(2);
        tableDias.getDefaultCell().setBorder(Rectangle.NO_BORDER);
        tableDias.setWidthPercentage(100);
        tableDias.setSpacingBefore(20);
        tableDias.setHorizontalAlignment(Element.ALIGN_LEFT);
        tableDias.setWidths(new int[] { 1, 9 });

        List<Dia> lstDiasPDF = rutinaVisualizar.getDiaList();

        PdfPCell cellCabezeraDia = new PdfPCell(new Paragraph("Da", bold));
        PdfPCell cellCabezeraDia2 = new PdfPCell();
        cellCabezeraDia2.setBorder(Rectangle.NO_BORDER);

        tableDias.addCell(cellCabezeraDia);
        tableDias.addCell(cellCabezeraDia2);

        for (Dia dia : lstDiasPDF) {
            PdfPCell cellDia = new PdfPCell(new Paragraph(dia.getNumDia().toString()));
            PdfPCell cellDia2 = new PdfPCell();
            cellDia2.setBorder(Rectangle.NO_BORDER);

            List<GrupoMuscular> lstGMuscularPDF = dia.getGrupoMuscularList();

            if (lstGMuscularPDF.size() > 0) {
                PdfPTable tableGMuscular = new PdfPTable(2);
                tableGMuscular.getDefaultCell().setBorder(Rectangle.NO_BORDER);
                tableGMuscular.setWidthPercentage(100);
                tableGMuscular.setHorizontalAlignment(Element.ALIGN_LEFT);
                tableGMuscular.setWidths(new int[] { 1, 6 });

                PdfPCell cellCabezeraGMuscular = new PdfPCell(new Paragraph("Grupo Muscular", bold));
                cellCabezeraGMuscular.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP);
                PdfPCell cellCabezeraGMuscular2 = new PdfPCell();
                cellCabezeraGMuscular2.setBorder(Rectangle.NO_BORDER);
                tableGMuscular.addCell(cellCabezeraGMuscular);
                tableGMuscular.addCell(cellCabezeraGMuscular2);

                int aux = 1;
                for (GrupoMuscular gMuscularFor : lstGMuscularPDF) {
                    PdfPCell cellGMuscular = new PdfPCell(
                            new Paragraph(gMuscularFor.getIdgrupoMuscularGeneral().getNombre()));
                    cellGMuscular.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
                    PdfPCell cellGMuscular2 = new PdfPCell();
                    cellGMuscular2.setBorder(Rectangle.NO_BORDER);

                    List<EjercicioGm> lstEjerciciosGMuscularPDF = gMuscularFor.getEjercicioGmList();
                    BaseColor myColor = WebColors.getRGBColor("#CCEEFF");
                    if (lstEjerciciosGMuscularPDF.size() > 0) {
                        PdfPTable tableEjercicioGMsucular = new PdfPTable(5);
                        tableEjercicioGMsucular.getDefaultCell().setBorder(Rectangle.NO_BORDER);
                        tableEjercicioGMsucular.setWidthPercentage(100);
                        tableEjercicioGMsucular.setHorizontalAlignment(Element.ALIGN_LEFT);

                        PdfPCell cellCabezeraEjercicioGM = new PdfPCell(new Paragraph("Ejercicio", bold));
                        cellCabezeraEjercicioGM.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP);
                        cellCabezeraEjercicioGM.setLeading(20f, 0f);
                        cellCabezeraEjercicioGM.setBackgroundColor(myColor);
                        tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM);

                        PdfPCell cellCabezeraEjercicioGM2 = new PdfPCell(new Paragraph("Series", bold));
                        cellCabezeraEjercicioGM2.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP);
                        cellCabezeraEjercicioGM2.setLeading(20f, 0f);
                        cellCabezeraEjercicioGM2.setBackgroundColor(myColor);
                        tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM2);

                        PdfPCell cellCabezeraEjercicioGM3 = new PdfPCell(new Paragraph("Repeticiones", bold));
                        cellCabezeraEjercicioGM3.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP);
                        cellCabezeraEjercicioGM3.setLeading(20f, 0f);
                        cellCabezeraEjercicioGM3.setBackgroundColor(myColor);
                        tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM3);

                        PdfPCell cellCabezeraEjercicioGM4 = new PdfPCell(new Paragraph("Receso", bold));
                        cellCabezeraEjercicioGM4.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP);
                        cellCabezeraEjercicioGM4.setLeading(20f, 0f);
                        cellCabezeraEjercicioGM4.setBackgroundColor(myColor);
                        tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM4);

                        PdfPCell cellCabezeraEjercicioGM5 = new PdfPCell(new Paragraph("Peso", bold));
                        cellCabezeraEjercicioGM5.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT | Rectangle.TOP);
                        cellCabezeraEjercicioGM5.setLeading(20f, 0f);
                        cellCabezeraEjercicioGM5.setBackgroundColor(myColor);
                        tableEjercicioGMsucular.addCell(cellCabezeraEjercicioGM5);

                        int aux2 = 1;
                        for (EjercicioGm ejercicioGm : lstEjerciciosGMuscularPDF) {
                            PdfPCell cellEjercicioGM = new PdfPCell(
                                    new Paragraph(ejercicioGm.getEjercicio().getNombre()));
                            cellEjercicioGM.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
                            cellEjercicioGM.setLeading(20f, 0f);

                            PdfPCell cellEjercicioGM2 = new PdfPCell(
                                    new Paragraph(ejercicioGm.getNumeroSeries().toString()));
                            cellEjercicioGM2.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
                            cellEjercicioGM2.setLeading(20f, 0f);

                            PdfPCell cellEjercicioGM3 = new PdfPCell(
                                    new Paragraph(ejercicioGm.getRepeticiones().toString()));
                            cellEjercicioGM3.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
                            cellEjercicioGM3.setLeading(20f, 0f);

                            PdfPCell cellEjercicioGM4 = new PdfPCell(
                                    new Paragraph(ejercicioGm.getReceso().toString()));
                            cellEjercicioGM4.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
                            cellEjercicioGM4.setLeading(20f, 0f);

                            PdfPCell cellEjercicioGM5 = new PdfPCell(
                                    new Paragraph(ejercicioGm.getPeso().toString()));
                            cellEjercicioGM5.setBorder(Rectangle.BOTTOM | Rectangle.RIGHT);
                            cellEjercicioGM5.setLeading(20f, 0f);

                            if (aux2 % 2 == 0) {
                                cellEjercicioGM.setBackgroundColor(myColor);
                                cellEjercicioGM2.setBackgroundColor(myColor);
                                cellEjercicioGM3.setBackgroundColor(myColor);
                                cellEjercicioGM4.setBackgroundColor(myColor);
                                cellEjercicioGM5.setBackgroundColor(myColor);
                            }

                            tableEjercicioGMsucular.addCell(cellEjercicioGM);
                            tableEjercicioGMsucular.addCell(cellEjercicioGM2);
                            tableEjercicioGMsucular.addCell(cellEjercicioGM3);
                            tableEjercicioGMsucular.addCell(cellEjercicioGM4);
                            tableEjercicioGMsucular.addCell(cellEjercicioGM5);
                            aux2++;
                        }
                        cellGMuscular2.addElement(tableEjercicioGMsucular);
                    }
                    tableGMuscular.addCell(cellGMuscular);
                    tableGMuscular.addCell(cellGMuscular2);
                    aux++;
                }
                cellDia2.addElement(tableGMuscular);
            }
            tableDias.addCell(cellDia);
            tableDias.addCell(cellDia2);
        }

        LineSeparator ls = new LineSeparator();
        document.add(tableEncabezado);
        document.add(ls);
        document.add(tableDatosUsuario);
        document.add(tableFechas);
        document.add(tableMedidas);
        document.add(tableDias);
        document.close();
    } catch (DocumentException | FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException ex) {
        Logger.getLogger(BeanGestionRutinas.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.ashish.medicine.admin.invoice.InvoiceAction.java

private void addSignature(Document document) throws DocumentException, MalformedURLException, IOException {
    Font headerFont = new Font(Font.FontFamily.TIMES_ROMAN, 12f, Font.BOLD);
    Phrase p = new Phrase("" + getSpace(120) + "Signature", headerFont);
    document.add(p);/*from  w  w  w.j  a va 2  s .  c o  m*/
}