Example usage for com.itextpdf.text BaseColor GREEN

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

Introduction

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

Prototype

BaseColor GREEN

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

Click Source Link

Usage

From source file:com.chaschev.itext.columns.BalancedColumnsBuilder.java

License:Apache License

private BalancingResult applyBestResult() {
    final float hCenter = horCenter();
    List<Element> elements = sequence.getElements();

    setColumn((float) bestResult.leftColumnHeight, hCenter, true, true, singleColumnRect, leftCTB);
    setColumn((float) bestResult.rightColumnHeight, hCenter, false, false, singleColumnRect, rightCTB);

    if (b.drawBorders) {
        b.getCanvasBuilder().drawGrayRectangle(leftCTB.getSimpleColumnRectangle(), BaseColor.RED);
        b.getCanvasBuilder().drawGrayRectangle(rightCTB.getSimpleColumnRectangle(), BaseColor.GREEN);
    }/*w ww  .ja va2 s  .  c  o m*/

    leftCTB.clearContent();
    rightCTB.clearContent();

    final DirectContentAdder.Result addResult = new DirectContentAdder(leftCTB).setStartWith(initialLeftCTB)
            .setStartAtIndex(startAtElement).setSwitchToRightCTB(rightCTB).setSimulate(false).go();

    float yLine = Math.min(leftCTB.getYLine(), rightCTB.getYLine());

    final BalancingResult r;

    if (addResult.hasContentLeft(elements.size())) {
        final ColumnTextBuilder contentCopy = addResult.contentLeft == null ? null
                : b.newColumnTextBuilder().setACopy(addResult.contentLeft);

        r = startWithANewPage(contentCopy, addResult.index);
    } else {
        r = new BalancingResult(yLine);

        //            if(updateAfterRun != null){
        //                updateAfterRun.growBottom(origRectangle.getTop() - yLine);
        //            }
    }

    if (updateAfterRun != null) {
        updateAfterRun.setSimpleColumn(b.reuseRectangleBuilder(new Rectangle(origRectangle.get())).setTop(yLine)
                .setBottom(b.getDocument().bottom()).get());
    }

    return r;
}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

private BaseColor getBackgroundColor(String str) {
    if ("Green".equals(str) || "On Target".equals(str)) {
        return BaseColor.GREEN;
    } else if ("Yellow".equals(str) || "At Risk".equals(str)) {
        return BaseColor.YELLOW;
    } else if ("Red".equals(str) || "Off Target".equals(str)) {
        return BaseColor.RED;
    }/*from  w  ww  . ja v  a2  s .c om*/
    return null;
}

From source file:com.pearson.controller.PdfGentrate.java

public static void main(String[] args) {

    try {// w w w  .ja v a  2s  . co m
        /*Document document = new Document(PageSize.
        A4, 50, 50, 50, 50);
        PdfWriter writer = PdfWriter.getInstance
        (document, new FileOutputStream("C:\\my.pdf"));
        document.open();               
        // create a chunk object using chunk class  of itext library.
        Chunk underlined = new Chunk("Welcome to Pearson Q-Service Portal : ");   
        // set the distance between text and line.
        underlined.setTextRise(8.0f);      
        // set the width of the line, 'y' position,  color and design of the line
        underlined.setUnderline(new Color(0x00, 0x00, 0xFF),0.0f, 0.2f, 3.0f, 0.0f, PdfContentByte.LINE_CAP_PROJECTING_SQUARE);      // finally add object to the document.
        document.add(underlined);
        document.add(new Paragraph("Hi username",
        FontFactory.getFont(FontFactory.COURIER, 14, 
        Font.BOLD, new Color(255, 150, 200))));;
                 
                
             document.add(new Paragraph("Tiltle",catFont));
             document.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
               smallBold));
             document.add(new Paragraph("This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",
               redFont));
                     
             PdfPTable table = new PdfPTable(3); // 3 columns.   
            table.setWidthPercentage(100); //Width 100%     
            table.setSpacingBefore(10f); //Space before table    
             table.setSpacingAfter(10f); //Space after table         //Set Column widths     
            float[] columnWidths = {1f, 1f, 1f};     
            table.setWidths(columnWidths);    
            PdfPCell cell1 = new PdfPCell(new Paragraph("Cell 1"));     
            cell1.setBorderColor(BaseColor.BLUE);     
            cell1.setPaddingLeft(10);     
            cell1.setHorizontalAlignment(Element.ALIGN_CENTER);     
            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);    
            PdfPCell cell2 = new PdfPCell(new Paragraph("Cell 2"));    
          cell2.setBorderColor(BaseColor.GREEN);    
          cell2.setPaddingLeft(10);    
          cell2.setHorizontalAlignment(Element.ALIGN_CENTER);      
            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);      
            PdfPCell cell3 = new PdfPCell(new Paragraph("Cell 3"));   
            cell3.setBorderColor(BaseColor.RED);      
            cell3.setPaddingLeft(10);      
            cell3.setHorizontalAlignment(Element.ALIGN_CENTER);    
          cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);   
            //To avoid having the cell border and the content overlap, if you are having thick cell borders     
            //cell1.setUserBorderPadding(true);     
            //cell2.setUserBorderPadding(true);   
            //cell3.setUserBorderPadding(true);   
            table.addCell(cell1);   
          table.addCell(cell2);   
          table.addCell(cell3);     
             document.add(table);     
             document.close();     
             writer.close();
                    
                  
                
        document.close();
        } 
        catch (Exception e2) {
        System.out.println(e2.getMessage());
        }
        }*/

        Document document = new Document();

        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("AddTableExample.pdf"));
        document.open();
        PdfPTable table = new PdfPTable(3); // 3 columns.      
        table.setWidthPercentage(100); //Width 100%       
        table.setSpacingBefore(10f); //Space before table    
        table.setSpacingAfter(10f); //Space after table         //Set Column widths     
        float[] columnWidths = { 1f, 1f, 1f };
        table.setWidths(columnWidths);
        PdfPCell cell1 = new PdfPCell(new Paragraph("Cell 1"));
        cell1.setBorderColor(BaseColor.BLUE);
        cell1.setPaddingLeft(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
        PdfPCell cell2 = new PdfPCell(new Paragraph("Cell 2"));
        cell2.setBorderColor(BaseColor.GREEN);
        cell2.setPaddingLeft(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
        PdfPCell cell3 = new PdfPCell(new Paragraph("Cell 3"));
        cell3.setBorderColor(BaseColor.RED);
        cell3.setPaddingLeft(10);
        cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
        //To avoid having the cell border and the content overlap, if you are having thick cell borders        //cell1.setUserBorderPadding(true);        //cell2.setUserBorderPadding(true);   
        //cell3.setUserBorderPadding(true);    
        table.addCell(cell1);
        table.addCell(cell2);
        table.addCell(cell3);
        document.add(table);
        document.close();
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.systemevent.jsfclass.util.PdfEvento.java

public PdfPTable Tabla_compleja() {
    //creamos una tabla con 3 columnas
    PdfPTable mitablacompleja = new PdfPTable(3);
    //aadimos texto con formato a la primera celda
    PdfPCell celda = new PdfPCell(new Paragraph("Historial de Observaciones", FontFactory.getFont("arial", // fuente
            22, // tamao
            Font.BOLD, // estilo
            BaseColor.RED))); // color
    //unimos esta celda con otras 2
    celda.setColspan(3);/* ww  w .  j a v a 2s . co  m*/
    //alineamos el contenido al centro
    celda.setHorizontalAlignment(Element.ALIGN_CENTER);
    // aadimos un espaciado
    celda.setPadding(12.0f);
    //colocamos un color de fondo
    celda.setBackgroundColor(BaseColor.GRAY);
    //se aade a la tabla
    mitablacompleja.addCell(celda);

    //fila 2
    celda = new PdfPCell(new Paragraph("AUDITORIA DE SISTEMAS"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.GREEN);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Aprobado"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 3        
    celda = new PdfPCell(new Paragraph("COMPILADORES"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.YELLOW);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Reprobado"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 4        
    celda = new PdfPCell(new Paragraph("Prog. Bajo Nivel"));
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.CYAN);
    mitablacompleja.addCell(celda);
    celda = new PdfPCell(new Paragraph("Eximido"));
    celda.setBackgroundColor(BaseColor.LIGHT_GRAY);
    mitablacompleja.addCell(celda);
    //fila 5
    mitablacompleja.addCell("Conclusion");
    celda = new PdfPCell(new Paragraph("GET A LIFE!!!"));
    celda.setHorizontalAlignment(Element.ALIGN_RIGHT);
    celda.setColspan(2);
    celda.setBackgroundColor(BaseColor.ORANGE);
    mitablacompleja.addCell(celda);
    // se retorna la tabla

    return mitablacompleja;
}

From source file:frames.main.java

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
    try {/*from  w  w  w . j  ava 2s. co m*/

        BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);
        Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0));
        Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
        Font font1004 = new Font(unicode, 18, Font.BOLD, new BaseColor(139, 0, 0));
        Font font1009 = new Font(unicode, 10, Font.NORMAL, new BaseColor(139, 10, 20));
        Font font1005 = new Font(unicode, 18, Font.UNDERLINE, new BaseColor(101, 67, 33));
        Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33));
        // Rectangle rect=new RectangleReadOnly(590, 470, 0);
        /////////////////////////////////////
        Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE);
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("REGISTRATION-FORM.pdf"));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
        Font font110 = new Font(Font.FontFamily.COURIER, 14, Font.NORMAL, BaseColor.GREEN);
        Font font11 = new Font(Font.FontFamily.COURIER, 12, Font.NORMAL, BaseColor.GREEN);
        com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
        image2.scaleAbsolute(115f, 115f);
        image2.setAbsolutePosition(3, 716);
        Paragraph p = new Paragraph();
        document.add(image2);
        document.add(new Chunk("                                                  ", font1004));
        document.add(new Chunk("ADMISSION FORM", font1005));
        document.add(new Paragraph("                                   SMART KIDS CONVENT SCHOOL", font1004));
        document.add(new Paragraph(
                "                                              Managed By:The Smart Kids Educational Society,"));
        document.add(new Paragraph(
                "                                                                           Reg.No:-00169"));
        document.add(new Paragraph(
                "                                                        413A/23,HEERA NAGAR,GURGAON"));
        document.add(new Paragraph(
                "                                                           MOB:-9911752900  ,  9891929835"));
        document.add(new Paragraph(
                "                                                                                                                   Reg.No"
                        + "   " + Rtf8.getText()));
        document.add(new Paragraph(
                "Admission No." + "                                                                  "
                        + new Date().toString()));
        document.add(new Paragraph("  "));
        Paragraph p1 = new Paragraph();
        p1.add(new Chunk("Certified that                 " + "Son/Daughter of:",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p1.add(new Chunk(Rtf1.getText(), font11));
        document.add(p1);

        document.add(new Paragraph("  "));
        Paragraph p2 = new Paragraph();
        p2.add(new Chunk("Father's Name  :" + Rtf2.getText() + "Mob:-",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p2.add(new Chunk(Rtf2.getText(), font11));
        document.add(p2);

        document.add(new Paragraph("  "));
        Paragraph p3 = new Paragraph();
        p3.add(new Chunk("Mother's Name  :" + Rtf2.getText() + "Mob:-",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p3.add(new Chunk(Rtf2.getText(), font11));
        document.add(p3);
        document.add(new Paragraph("  "));

        Paragraph p4 = new Paragraph();
        p4.add(new Chunk("His/Her Date of birth :" + Rtf2.getText() + "Age",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p4.add(new Chunk(Rtf2.getText(), font11));
        document.add(p4);
        document.add(new Paragraph("  "));

        Paragraph p5 = new Paragraph();
        p5.add(new Chunk("Corrosponding Address                  :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p5.add(new Chunk("", font11));
        document.add(p5);
        document.add(new Paragraph("  "));

        Paragraph p6 = new Paragraph();
        p6.add(new Chunk("Parmanent Address                  :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p6.add(new Chunk("", font11));
        document.add(p6);
        document.add(new Paragraph("  "));

        Paragraph p7 = new Paragraph();
        p7.add(new Chunk("Previous School & result                   :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p7.add(new Chunk("He/She Wants Admmisiion in",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(p7);
        document.add(new Paragraph("  "));
        Paragraph p8 = new Paragraph();
        p8.add(new Chunk("Smart Kids Convent School in                :",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p8.add(new Chunk("Class.He/She will always be regular and punctual to school.",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(p8);
        document.add(new Paragraph("  "));
        Paragraph p9 = new Paragraph();
        p9.add(new Chunk("Please admit him/her              :" + "Signature",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        p9.add(new Chunk(
                "                                                                              in" + "Class"
                        + "Parents/Guardian",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(p9);
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph(
                " Principal(Signature)                                                 Permission of Director",
                FontFactory.getFont(FontFactory.COURIER, 11, Font.ITALIC, BaseColor.BLACK)));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("  "));
        document.add(new Paragraph("NOTE:- FEES WILL NOT BE REFUNDED AFTER ADMISSION."));
        cb.saveState();
        cb.setColorStroke(BaseColor.BLACK);
        cb.rectangle(2, 2, 588, 826);
        cb.stroke();
        cb.restoreState();
        JOptionPane.showMessageDialog(this, "receipt printed..");

        document.close();
        ;
    } catch (Exception ee) {
        JOptionPane.showMessageDialog(this, ee);
    }
}

From source file:frames.main.java

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
    if (PRINTMODE.getSelectedIndex() == 0) {
        try {//  www  .  ja va 2s.  c  o m

            //mrpno=Integer.parseInt(DTFrpno.getText());
            BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0));
            Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
            Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
            Font font1005 = new Font(unicode, 12, Font.UNDERLINE, new BaseColor(255, 0, 0));
            Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33));
            Rectangle rect = new RectangleReadOnly(590, 470, 0);
            /////////////////////////////////////
            Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE);
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("REGISTRATION.pdf"));
            document.setPageSize(rect);
            document.open();
            // PdfContentByte cb = writer.getDirectContent();
            Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
            com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                    .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
            image2.scaleAbsolute(115f, 115f);
            image2.setAbsolutePosition(2, 350);
            document.add(image2);
            document.add(new Chunk(
                    "                                                                                         ",
                    font100));
            document.add(new Chunk("RECEIPT", font1005));
            //document.add(p);
            // document.add(new Paragraph( ));
            document.add(new Paragraph(
                    "                                  SMART KID CONVENT SCHOOL                 ", font1003));
            // document.add(new Chunk("                          SMART KID CONVENT SCHOOL                 ",font1003));
            // document.add(new Chunk("                                                              413A/23,HEERA NAGAR GURGAON.                        ",font100));
            document.add(new Paragraph(
                    "                                                                  413A/23,HEERA NAGAR GURGAON.                        ",
                    font100));
            // document.add(new Chunk("                                                                                            ph:9911752900,9891929835                 ",font100));
            document.add(new Paragraph(
                    "                                                                     ph:9911752900,9891929835                 ",
                    font100));
            // document.add(new Chunk("                                                          E-mail:info.smartkids@gmail.com",FontFactory.getFont(FontFactory.COURIER,9,Font.BOLDITALIC,BaseColor.DARK_GRAY)));
            document.add(new Paragraph("                                  E-mail:info.smartkids@gmail.com",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLDITALIC, BaseColor.DARK_GRAY)));

            document.add(new Paragraph("  "));
            PdfPTable table1 = new PdfPTable(4);
            PdfPCell c = new PdfPCell(new Paragraph("STUDENT PARTICULARS"));
            c.setColspan(4);
            c.setBackgroundColor(BaseColor.GREEN);
            c.setHorizontalAlignment(Element.ALIGN_CENTER);
            table1.addCell(c);
            table1.addCell("Student Name:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf2.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));

            table1.addCell("Class:");
            table1.addCell(new Paragraph((String) Dtf5.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Section:");
            table1.addCell(new Paragraph((String) Dtf22.getText() + "     " + "Phone.:" + Dtf20.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Registration No:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf1.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));
            table1.addCell("Session:");
            table1.addCell(new Paragraph("NA",
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Month:");
            table1.addCell(new Paragraph((String) Djc1.getSelectedItem(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            float[] ColumnWidths1 = new float[] { 12f, 19f, 10f, 24f };
            table1.setWidths(ColumnWidths1);
            table1.setWidthPercentage(113);
            document.add(table1);

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

            PdfPTable table = new PdfPTable(5);
            PdfPCell cc = new PdfPCell(new Paragraph("FEE INFORMATION"));
            cc.setBackgroundColor(BaseColor.GREEN);
            cc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cc.setColspan(5);
            table.addCell(cc);
            PdfPCell cell99 = new PdfPCell(new Paragraph("Sl No",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell90 = new PdfPCell(new Paragraph("Particulars",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell91 = new PdfPCell(new Paragraph("Cash",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell92 = new PdfPCell(new Paragraph("Cheque",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell93 = new PdfPCell(new Paragraph("Total",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell99);
            table.addCell(cell90);
            table.addCell(cell91);
            table.addCell(cell92);
            table.addCell(cell93);
            table.addCell("1");
            PdfPCell cell1 = new PdfPCell(new Paragraph("Registration Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell1);
            table.addCell(Dtf11.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("2");
            PdfPCell cell2 = new PdfPCell(new Paragraph("Admission/Re admission fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell2);
            table.addCell(Dtf12.getText());
            table.addCell("  ");
            table.addCell(" ");
            table.addCell("3");
            PdfPCell cell3 = new PdfPCell(new Paragraph("Building fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell3);
            table.addCell(Dtf13.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("4");
            PdfPCell cell4 = new PdfPCell(new Paragraph("Annual Charge",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell4);
            table.addCell(Dtf14.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("5");
            PdfPCell cell14 = new PdfPCell(new Paragraph("Security (Refundable)",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell14);
            table.addCell(Dtf17.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("6");
            PdfPCell cell5 = new PdfPCell(new Paragraph("Tution",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell5);
            table.addCell(Dtf6.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("7");
            PdfPCell cell6 = new PdfPCell(new Paragraph("Total pupils fund",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell6);
            table.addCell(Dtf16.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("8");
            PdfPCell cell7 = new PdfPCell(new Paragraph("Computer Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell7);
            table.addCell(Dtf7.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("9");
            PdfPCell cell8 = new PdfPCell(new Paragraph("Sports Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell8);
            table.addCell(Dtf15.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("10");
            PdfPCell cell9 = new PdfPCell(new Paragraph("House exam Fee",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell9);
            table.addCell(Dtf8.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("11");
            PdfPCell cell10 = new PdfPCell(new Paragraph("Conveyance Charge",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell10);
            table.addCell(Dtf18.getText());
            table.addCell(" ");
            //table.addCell(" ");
            table.addCell("");
            PdfPCell cell12 = new PdfPCell(new Paragraph("12",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));
            PdfPCell cell13 = new PdfPCell(new Paragraph("Grand Total",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));

            table.addCell(cell12);
            table.addCell(cell13);

            table.addCell(
                    String.valueOf((Integer.parseInt(Dtf11.getText())) + (Integer.parseInt(Dtf12.getText()))
                            + (Integer.parseInt(Dtf13.getText())) + (Integer.parseInt(Dtf14.getText()))
                            + (Integer.parseInt(Dtf17.getText())) + (Integer.parseInt(Dtf6.getText()))
                            + (Integer.parseInt(Dtf16.getText())) + (Integer.parseInt(Dtf7.getText()))
                            + (Integer.parseInt(Dtf15.getText())) + (Integer.parseInt(Dtf8.getText()))
                            + (Integer.parseInt(Dtf18.getText())) + (Integer.parseInt(Dtf9.getText()))));

            float[] ColumnWidths = new float[] { 8f, 25f, 11f, 10f, 10f };
            table.setWidths(ColumnWidths);
            table.setWidthPercentage(113);
            table.completeRow();
            document.add(table);
            document.add(new Chunk(
                    "# Fee once paid is not refundable .                      For Smart kid convent school     Signature    "));
            //document.add(new Chunk("# The monthly fee has to be deposited before 10th of every month                            Signature "));
            JOptionPane.showMessageDialog(this, "receipt printed..");

            Dtf21.setText(String.valueOf(Integer.parseInt(Dtf21.getText()) + 1));
            document.close();
            ;
        } catch (Exception ee) {
            JOptionPane.showMessageDialog(this, ee);
        }
    } else if (PRINTMODE.getSelectedIndex() == 1) {
        try {

            //mrpno=Integer.parseInt(DTFrpno.getText());
            BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            Font font1003 = new Font(unicode, 18, Font.ITALIC, new BaseColor(139, 0, 0));
            Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
            Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
            Font font1005 = new Font(unicode, 12, Font.UNDERLINE, new BaseColor(255, 0, 0));
            Font font1006 = new Font(unicode, 9, Font.BOLDITALIC, new BaseColor(101, 67, 33));
            Rectangle rect = new RectangleReadOnly(590, 460, 0);
            /////////////////////////////////////
            Font font100 = new Font(unicode, 10, Font.ITALIC, BaseColor.BLUE);
            Document document = new Document();
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Feeslipp(MONTHLY).pdf"));
            document.setPageSize(rect);
            document.open();
            // PdfContentByte cb = writer.getDirectContent();
            Font font111 = new Font(Font.FontFamily.COURIER, 16, Font.BOLD, BaseColor.ORANGE);
            com.itextpdf.text.Image image2 = com.itextpdf.text.Image
                    .getInstance("C:\\smart kid\\src\\frames\\logo.jpg");
            image2.scaleAbsolute(115f, 115f);
            image2.setAbsolutePosition(2, 350);
            document.add(image2);
            Paragraph p = new Paragraph();
            p.add(new Chunk("                                                                      "));
            //p.add(new Chunk("RECEIPT",font1005));
            //document.add(p);
            document.add(new Chunk("                  RECEIPT", font1003));
            document.add(new Paragraph("                             SMART KID CONVENT SCHOOL                 ",
                    font1003));
            // document.add(new Chunk("                          SMART KID CONVENT SCHOOL                 ",font1003));
            // document.add(new Chunk("                                                              413A/23,HEERA NAGAR GURGAON.                        ",font100));
            document.add(new Paragraph(
                    "                                                              413A/23,HEERA NAGAR GURGAON.                        ",
                    font100));
            // document.add(new Chunk("                                                                                            ph:9911752900,9891929835                 ",font100));
            document.add(new Paragraph(
                    "                                                                  ph:9911752900,9891929835                 ",
                    font100));
            // document.add(new Chunk("                                                          E-mail:info.smartkids@gmail.com",FontFactory.getFont(FontFactory.COURIER,9,Font.BOLDITALIC,BaseColor.DARK_GRAY)));
            document.add(new Paragraph("                                 E-mail:info.smartkids@gmail.com",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLDITALIC, BaseColor.DARK_GRAY)));
            document.add(new Paragraph("  "));
            PdfPTable table1 = new PdfPTable(4);
            PdfPCell c = new PdfPCell(new Paragraph("STUDENT PARTICULARS"));
            c.setColspan(4);
            c.setBackgroundColor(BaseColor.GREEN);
            c.setHorizontalAlignment(Element.ALIGN_CENTER);
            table1.addCell(c);
            table1.addCell("Student Name:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf2.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));
            table1.addCell("Class:");
            table1.addCell(new Paragraph(Dtf5.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Section:");
            table1.addCell(new Paragraph(Dtf21.getText() + "     " + "Phone.:" + Dtf20.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            table1.addCell("Registration No:");
            table1.addCell(new PdfPCell(new Paragraph(Dtf1.getText(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN))));
            table1.addCell("Month:");
            table1.addCell(new Paragraph((String) Djc1.getSelectedItem(),
                    FontFactory.getFont(FontFactory.COURIER, 12, Font.BOLDITALIC, BaseColor.GREEN)));
            float[] ColumnWidths1 = new float[] { 12f, 19f, 10f, 24f };
            table1.setWidths(ColumnWidths1);
            table1.setWidthPercentage(113);
            document.add(table1);

            document.add(new Paragraph("  "));
            PdfPTable table = new PdfPTable(5);
            PdfPCell cc = new PdfPCell(new Paragraph("FEE INFORMATION"));
            cc.setBackgroundColor(BaseColor.GREEN);
            cc.setHorizontalAlignment(Element.ALIGN_CENTER);
            cc.setColspan(5);
            table.addCell(cc);
            PdfPCell cell99 = new PdfPCell(new Paragraph("Sl No",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell90 = new PdfPCell(new Paragraph("Particulars",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell91 = new PdfPCell(new Paragraph("Cash",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell92 = new PdfPCell(new Paragraph("Cheque",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            PdfPCell cell93 = new PdfPCell(new Paragraph("Total",
                    FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell99);
            table.addCell(cell90);
            table.addCell(cell91);
            table.addCell(cell92);
            table.addCell(cell93);
            table.addCell("1");
            PdfPCell cell1 = new PdfPCell(new Paragraph("TUITION FEE",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell1);
            table.addCell(Dtf6.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("2");
            PdfPCell cell2 = new PdfPCell(new Paragraph("COMPUTER FEE",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell2);
            table.addCell(Dtf7.getText());
            table.addCell("  ");
            table.addCell(" ");
            table.addCell("3");
            PdfPCell cell5 = new PdfPCell(new Paragraph("HOUSE EXAM FEE",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell5);
            table.addCell(Dtf8.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("4");
            PdfPCell cell6 = new PdfPCell(new Paragraph("FINES",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell6);
            table.addCell(Dtf9.getText());
            table.addCell(" ");
            table.addCell(" ");
            table.addCell("5");
            PdfPCell cell7 = new PdfPCell(new Paragraph("OTHERS",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.NORMAL, BaseColor.BLACK)));
            table.addCell(cell7);
            table.addCell(Dtf10.getText());
            table.addCell(" ");

            table.addCell("");

            PdfPCell cell9 = new PdfPCell(new Paragraph("6",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));
            PdfPCell cell8 = new PdfPCell(new Paragraph("Grand Total",
                    FontFactory.getFont(FontFactory.COURIER, 9, Font.BOLD, BaseColor.BLACK)));

            table.addCell(cell7);
            table.addCell(cell8);
            table.addCell(String.valueOf((Integer.parseInt(Dtf6.getText())) + (Integer.parseInt(Dtf7.getText()))
                    + (Integer.parseInt(Dtf8.getText())) + (Integer.parseInt(Dtf9.getText()))
                    + (Integer.parseInt(Dtf10.getText()))));

            float[] ColumnWidths = new float[] { 8f, 25f, 11f, 10f, 10f };
            table.setWidths(ColumnWidths);
            table.setWidthPercentage(113);
            table.completeRow();
            document.add(table);
            document.add(new Chunk(
                    "# Fee once paid is not refundable .                                                   For smart kid convent School     "));
            document.add(new Chunk(
                    "# The monthly fee has to be deposited before 10th of every month                            Signature "));
            JOptionPane.showMessageDialog(this, "receipt printed..");

            Dtf21.setText(String.valueOf(Integer.parseInt(Dtf21.getText()) + 1));
            document.close();
            ;
        } catch (Exception ee) {
            JOptionPane.showMessageDialog(this, ee);
        }
    } // TODO add your handling code here:
}

From source file:Gui.admin.NouveauConsulterinfoAdherent.java

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

        String value1 = idadherenttxt.getText();
        String value2 = nomadherentTxt.getText();
        String value3 = prenomAdhrentTxt.getText();
        String value4 = adresseAdherentTxt.getText();
        String value5 = mdpAdherentTXT.getText();
        String value6 = telAdherentTXT.getText();
        String value7 = nbrReclamationsTxt.getText();

        try {//from   ww w  .j a v  a  2  s.co  m
            // pagesize.A4.rotate() pour voir le rapport dans IDE 
            com.itextpdf.text.Document document = new com.itextpdf.text.Document(PageSize.A4.rotate());
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("rapport.pdf"));

            if ((new File("rapport.pdf")).exists()) {

                Process p = Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler rapport.pdf");
                p.waitFor();

            } else {

                System.out.println("File is not exists");

            }

            document.open();
            // Date
            document.add(new Paragraph(new Date().toString()));
            document.add(new Paragraph("Rapport Statistiques",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 18, Font.BOLD, BaseColor.RED)));
            document.add(new Paragraph(
                    "--------------------------------------------------------------------------------------------------------------------------------------------------------------------"));

            // ajoute un tableau dans le rapport 

            //                  PdfPTable table = new PdfPTable(4);
            //                  
            //                   PdfPCell cell = new PdfPCell(new Paragraph("Informations Adhrents"));
            //                     // le titre du tableau 
            //                  cell.setColspan(10);
            //                  cell.setBackgroundColor(BaseColor.GREEN);
            //                  table.addCell(cell);

            //                  table.addCell("Id Adhrent");
            //                  table.addCell("Nom de l'adhrent");
            //                  table.addCell("Prnom de l'adhrent");
            //                  table.addCell("Numro de l'adhrent");
            //                  document.add(table);
            // le titre du tableau 

            // ajouter l'image dans le fichier pdf 
            Image image = Image.getInstance("statistiques.png");
            document.add(new Paragraph("statistiques.png"));
            document.add(image);

            // document.add(new Paragraph("Salut sindoud", FontFactory.getFont(FontFactory.TIMES_BOLD,18,Font.BOLD, BaseColor.BLUE)));

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

            PdfPTable table = new PdfPTable(6);
            PdfPCell cell = new PdfPCell(new Paragraph("Titre"));
            cell.setColspan(4);
            //  cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setBackgroundColor(BaseColor.GREEN);
            table.addCell("id de l'adherent");
            table.addCell(value1);
            table.addCell("Nom de l'adhrent");
            table.addCell(value2);
            table.addCell("Prnom de l'adhrent");
            table.addCell(value3);
            table.addCell("adresse de l'adhrent");
            table.addCell(value4);
            table.addCell("mot de passe de l'adherent");
            table.addCell(value5);
            table.addCell("tel de l'adherent ");
            table.addCell(value6);
            table.addCell("nombre de reclamations");
            table.addCell(value7);

            document.add(table);

            document.close();
            //com.itextpdf.text.Image image1= com.itextpdf.text.Image.getInstance("statistiques.png");
            // image1.scaleAbsolute(400,300);
            //document.add(image1);
            //PdfContentByte cb= writer.getDirectContent();
            JOptionPane.showMessageDialog(null, "rapport enregistr");
        }

        catch (DocumentException | IOException | InterruptedException | HeadlessException e) {

            JOptionPane.showMessageDialog(null, e);

        }
        //
    }

From source file:ihm.panneaux.GenererPdf.java

private void initComponement() throws FileNotFoundException, DocumentException, IOException {
    String DEST = "devis/devis-" + devis.getNumero() + ".pdf";
    OutputStream file = new FileOutputStream(new File(DEST));

    com.itextpdf.text.Document document = new com.itextpdf.text.Document();
    PdfWriter.getInstance((com.itextpdf.text.Document) document, file);
    // PAS TOUCHE
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(DEST));

    Rectangle rect = new Rectangle(30, 30, 550, 800);
    writer.setBoxSize("art", rect);
    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    writer.setPageEvent(event);//  w w  w  .  j  a va 2  s  . co  m
    document.open();
    PdfContentByte canvas = writer.getDirectContent();

    Image logo = Image.getInstance("images/logo.png");
    logo.scaleAbsolute(200, 57);

    // INFO DEVIS
    Image devisImg = Image.getInstance("images/imgDevis.png");
    devisImg.scaleAbsolute(110, 34);
    devisImg.setAbsolutePosition((PageSize.POSTCARD.getWidth() + 150),
            (PageSize.POSTCARD.getHeight() - devisImg.getScaledHeight()) * 2);
    Font fontImgDevis = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    Phrase numeroInfo = new Phrase("Numro  " + devis.getNumero(), fontImgDevis);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, numeroInfo, devisImg.getScaledWidth() + 413,
            devisImg.getScaledHeight() + 710, 0);
    Phrase dateInfo = new Phrase("Le  " + devis.getDate(), fontImgDevis);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, dateInfo, devisImg.getScaledWidth() + 420,
            devisImg.getScaledHeight() + 695, 0);
    Image devisImgBordure = Image.getInstance("images/bordureDevis.png");
    devisImgBordure.setAbsolutePosition((devisImg.getScaledWidth() + 318), devisImg.getScaledHeight() + 660);
    devisImgBordure.scaleAbsolute(120, 122);

    // INFO ENTREPRISE
    Font fontEntreprise = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.BOLD);
    Phrase coGerants = new Phrase("Co-grants : " + devis.getEntreprise().getCoGerant(), fontEntreprise);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, coGerants, devisImg.getScaledWidth() + 210,
            devisImg.getScaledHeight() + 660, 0);
    Phrase siege = new Phrase("Sige : " + devis.getEntreprise().getSiege(), fontEntreprise);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, siege, devisImg.getScaledWidth() + 149,
            devisImg.getScaledHeight() + 640, 0);
    Phrase tel = new Phrase("TEL : " + devis.getEntreprise().getTel(), fontEntreprise);
    ColumnText.showTextAligned(canvas, Element.ALIGN_RIGHT, tel, devisImg.getScaledWidth() + 113,
            devisImg.getScaledHeight() + 625, 0);
    Image bordureEntreprise = Image.getInstance("images/bordureEntreprise.png");
    bordureEntreprise.setAbsolutePosition(devisImg.getScaledWidth() - 80, devisImg.getScaledHeight() + 610);

    // INFO CLIENT
    Font fontClient = new Font(Font.FontFamily.TIMES_ROMAN, 11, Font.NORMAL);
    Phrase nomPrenom = new Phrase(devis.getClient().getNom() + " " + devis.getClient().getPrenom(), fontClient);
    Phrase commune = new Phrase(devis.getClient().getAdresse(), fontClient);
    Phrase adresse = new Phrase(devis.getClient().getCodePostale() + " " + devis.getClient().getCommune(),
            fontClient);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, nomPrenom, PageSize.A4.getWidth() - 280,
            devisImg.getScaledHeight() + 595, 0);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, commune, PageSize.A4.getWidth() - 280,
            devisImg.getScaledHeight() + 580, 0);
    ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, adresse, PageSize.A4.getWidth() - 280,
            devisImg.getScaledHeight() + 565, 0);

    document.add(logo);
    document.add(devisImg);
    document.add(devisImgBordure);
    document.add(bordureEntreprise);

    // AJOUT DES DONNEES DU TABLEAUX 

    float[] columnWidths = { 14, 3, 4, 3, 4 };
    Font fontCategorie = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD);
    fontCategorie.setColor(BaseColor.GREEN);

    PdfPTable table = new PdfPTable(columnWidths);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);

    table.setTotalWidth(PageSize.A4.getWidth() - 15);

    table.setSpacingBefore(150);

    table.setLockedWidth(true);

    Font Categorie = new Font(FontFamily.HELVETICA, 13, Font.BOLD);
    Font Chantier = new Font(FontFamily.HELVETICA, 11, Font.UNDERLINE);

    PdfPCell cellChantier = new PdfPCell(new Phrase("CHANTIER : " + chantier, Chantier));
    cellChantier.setColspan(3);
    cellChantier.setBorder(Rectangle.NO_BORDER);
    table.addCell(cellChantier);
    table.addCell(" ");
    table.addCell(" ");

    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");

    table.addCell(new Phrase("Dsignation", Categorie));
    PdfPCell unite = new PdfPCell(new Phrase("Unite", Categorie));
    PdfPCell quantite = new PdfPCell(new Phrase("Quantite", Categorie));
    PdfPCell prixht = new PdfPCell(new Phrase("Prix HT", Categorie));
    PdfPCell pvtht = new PdfPCell(new Phrase("Pvt HT", Categorie));

    unite.setHorizontalAlignment(Element.ALIGN_CENTER);
    quantite.setHorizontalAlignment(Element.ALIGN_CENTER);
    prixht.setHorizontalAlignment(Element.ALIGN_CENTER);
    pvtht.setHorizontalAlignment(Element.ALIGN_CENTER);

    unite.setBorder(Rectangle.NO_BORDER);
    quantite.setBorder(Rectangle.NO_BORDER);
    prixht.setBorder(Rectangle.NO_BORDER);
    pvtht.setBorder(Rectangle.NO_BORDER);

    table.addCell(unite);
    table.addCell(quantite);
    table.addCell(prixht);
    table.addCell(pvtht);

    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");
    table.addCell(" ");

    double htTotalParcour = 0;
    double ttcTotalParcour = 0;

    if (this.EquipementDeChantier.isEmpty() == false) {
        table.addCell(new Phrase("Equipement De Chantier", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");

        for (DevisContenu listeMaterielDevi : EquipementDeChantier) {

            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            /* BACKUP
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            table.addCell(listeMaterielDevi.getMateriel().getUnite());
            table.addCell(Double.toString(listeMaterielDevi.getQuantite()));
            table.addCell(Double.toString(listeMaterielDevi.getMateriel().getPrix())+"");
            table.addCell(Double.toString(listeMaterielDevi.getPvtHT())+"");
            */
            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (Couverture.isEmpty() == false) {
        table.addCell(new Phrase("Couverture", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Couverture) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (CouvertureArdoise.isEmpty() == false) {
        table.addCell(new Phrase("Couverture Ardoise", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : CouvertureArdoise) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (CouvertureTuile.isEmpty() == false) {
        table.addCell(new Phrase("Couverture Tuile", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : CouvertureTuile) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (this.Demoussage.isEmpty() == false) {
        table.addCell(new Phrase("Demoussage", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Demoussage) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");

    }
    if (this.Velux.isEmpty() == false) {
        table.addCell(new Phrase("Velux", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Velux) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");

    }
    if (this.Zinguerie.isEmpty() == false) {
        table.addCell(new Phrase("Zinguerie", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Zinguerie) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }
    if (Plancher.isEmpty() == false) {
        table.addCell(new Phrase("Plancher", fontCategorie));
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        for (DevisContenu listeMaterielDevi : Plancher) {
            table.addCell(listeMaterielDevi.getMateriel().getNom());
            PdfPCell cellunite = new PdfPCell(new Phrase(listeMaterielDevi.getMateriel().getUnite()));
            PdfPCell cellQuantite = new PdfPCell(new Phrase(Double.toString(listeMaterielDevi.getQuantite())));
            PdfPCell cellprix = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getMateriel().getPrix()) + ""));
            PdfPCell cellpvtHT = new PdfPCell(
                    new Phrase(Double.toString(listeMaterielDevi.getPvtHT()) + ""));
            cellunite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellQuantite.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellprix.setHorizontalAlignment(Element.ALIGN_CENTER);
            cellpvtHT.setHorizontalAlignment(Element.ALIGN_CENTER);

            cellunite.setBorder(Rectangle.NO_BORDER);
            cellQuantite.setBorder(Rectangle.NO_BORDER);
            cellprix.setBorder(Rectangle.NO_BORDER);
            cellpvtHT.setBorder(Rectangle.NO_BORDER);

            table.addCell(cellunite);
            table.addCell(cellQuantite);
            table.addCell(cellprix);
            table.addCell(cellpvtHT);

            ttcTotalParcour += listeMaterielDevi.getPvtHT();
            htTotalParcour += listeMaterielDevi.getPvtHT();
        }
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
        table.addCell(" ");
    }

    ttcTotalParcour = (ttcTotalParcour * devis.getTva() / 100) + ttcTotalParcour;

    LineDash solid = new SolidLine();
    PdfPCell cell, cell2, cellSOUSTOTAL, cellhttotal, tva, getTva, totalttc, gettotalttc;

    table.addCell(new Phrase(" "));
    table.addCell(new Phrase(" "));
    table.addCell(new Phrase(" "));
    table.addCell(new Phrase(" "));

    cell = new PdfPCell(new Phrase(""));
    cell.setBorder(PdfPCell.NO_BORDER);
    cell.setCellEvent(new CustomBorder(null, null, null, solid));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(cell);

    table.addCell(new Phrase(""));
    table.addCell(new Phrase(""));
    cellSOUSTOTAL = new PdfPCell(new Phrase("SOUS-TOTAL"));
    cellSOUSTOTAL.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    cellSOUSTOTAL.setBorder(Rectangle.NO_BORDER);
    table.addCell(cellSOUSTOTAL);
    table.addCell(new Phrase(""));
    double prixHT_2Chiffre = Math.round((htTotalParcour) * Math.pow(10, 2)) / Math.pow(10, 2);
    String httotal = String.valueOf(prixHT_2Chiffre);
    cellhttotal = new PdfPCell(new Phrase(httotal + ""));
    cellhttotal.setBorder(Rectangle.NO_BORDER);
    cellhttotal.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cellhttotal);

    table.addCell(new Phrase(""));
    table.addCell(new Phrase(""));
    tva = new PdfPCell(new Phrase("TVA"));
    tva.setBorder(Rectangle.NO_BORDER);
    tva.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(tva);

    getTva = new PdfPCell(new Phrase(devis.getTva() + "%"));
    getTva.setBorder(Rectangle.NO_BORDER);
    getTva.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(getTva);

    String tvaprix = String.valueOf(htTotalParcour * devis.getTva() / 100);
    double prixTVA_2Chiffre = Math.round(Double.parseDouble(tvaprix) * Math.pow(10, 2)) / Math.pow(10, 2);
    cell2 = new PdfPCell(new Phrase(Double.toString(prixTVA_2Chiffre) + ""));
    cell2.setBorder(PdfPCell.NO_BORDER);
    cell2.setCellEvent(new CustomBorder(null, null, null, solid));
    cell2.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell2);

    table.addCell("");
    table.addCell("");
    totalttc = new PdfPCell(new Phrase("Total TTC"));
    totalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    totalttc.setBorder(PdfPCell.NO_BORDER);
    table.addCell(totalttc);
    table.addCell("");
    double prixTTC_2Chiffre = Math.round(ttcTotalParcour * Math.pow(10, 2)) / Math.pow(10, 2);
    String ttctotal = String.valueOf(Double.toString(prixTTC_2Chiffre));
    gettotalttc = new PdfPCell(new Phrase(ttctotal + ""));
    gettotalttc.setBorder(PdfPCell.NO_BORDER);
    gettotalttc.setHorizontalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(gettotalttc);

    table.setSpacingAfter(10);

    document.add(table);

    Pattern p = Pattern.compile("[.^\\.]+");
    String texte = devis.getInformationComplementaire();

    Font infoComptBlue = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL);
    infoComptBlue.setColor(BaseColor.BLUE);
    Font infoComptRed = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL);
    infoComptRed.setColor(BaseColor.RED);
    Font infoComptBlack = new Font(Font.getFamily("TIMES_ROMAN"), 8, Font.NORMAL);
    infoComptBlack.setColor(BaseColor.BLACK);

    Paragraph infoComp = new Paragraph();
    Image BonPourAccord = null;
    BonPourAccord = Image.getInstance("images/BonPourAccord.png");
    infoComp.setAlignment(Element.ALIGN_LEFT);
    BonPourAccord.setAlignment(Image.TEXTWRAP | Image.ALIGN_RIGHT);

    String[] phrase = p.split(texte);
    for (int i = 0; i < phrase.length; i++) {
        if (i == 0 || i == 1) {
            infoComp.add(new Paragraph(phrase[i], infoComptBlue));
        }
        if (i == 2 || i == 3 || i == 4 || i == 5) {
            infoComp.add(new Paragraph(phrase[i], infoComptRed));

        }
        if (i > 5 && i <= 11)
            infoComp.add(new Paragraph(phrase[i], infoComptBlack));
        if (i > 11)
            infoComp.add(new Paragraph(phrase[i], infoComptRed));
    }
    /* A OPTIMISER */

    float taille_tableau = table.calculateHeights() + table.getRowHeight(table.getLastCompletedRowIndex());

    if (taille_tableau > 386) {
        document.newPage();
    }
    document.add(BonPourAccord);
    document.add(infoComp);

    document.close();

    EnvoieDevis envoie = new EnvoieDevis(null, true, session, devis);
    this.CouvertureArdoise.clear();
    this.CouvertureTuile.clear();
    this.Demoussage.clear();
    this.EquipementDeChantier.clear();
    this.Velux.clear();
    this.Zinguerie.clear();
    this.Couverture.clear();
    this.Plancher.clear();
}

From source file:pdf.PDFDesign.java

public PDFDesign(String s, String c, String sn, Map<String, String> fontMap) {
    size = s;//w w  w  . j  a va 2s.co m
    titleLineFixedHeight = 15.0f;
    priceFontInc = 0;
    textFontInc = 0;
    styleName = sn;
    fontPaths = new FontPaths(fontMap);
    nColumns = 6;
    switch (c) {
    case "black":
        color = BaseColor.BLACK;
        break;
    case "gray":
        color = BaseColor.DARK_GRAY;
        break;
    case "red":
        color = BaseColor.RED.darker();
        break;
    case "green":
        color = BaseColor.GREEN.darker().darker().darker();
        break;
    case "blue":
        color = BaseColor.BLUE.darker().darker().darker();
        break;
    default:
        this.color = BaseColor.BLACK;
    }
    switch (size) {
    case "3x5":
        cellHeight = 83.8f;
        break;
    case "3.5x5":
        cellHeight = 97.8f;
        break;
    case "3.5x6":
        priceFontInc = 8;
        cellHeight = 97.8f;
        nColumns = 5;
        break;
    case "3.5x7":
        cellHeight = 97.8f;
        nColumns = 4;
        break;
    case "4x6":
        titleLineFixedHeight = 26.0f;
        priceFontInc = 8;
        cellHeight = 117.0f;
        nColumns = 5;
        break;
    case "4x7":
        titleLineFixedHeight = 26.0f;
        priceFontInc = 8;
        cellHeight = 117.0f;
        nColumns = 4;
        break;
    case "5x6":
        titleLineFixedHeight = 30.0f;
        priceFontInc = 13;
        textFontInc = 2;
        cellHeight = 145.0f;
        nColumns = 5;
        break;
    case "5x7":
        titleLineFixedHeight = 30.0f;
        priceFontInc = 18;
        textFontInc = 3;
        cellHeight = 145.0f;
        nColumns = 4;
        break;
    case "6x7":
        titleLineFixedHeight = 34.0f;
        priceFontInc = 26;
        textFontInc = 5;
        cellHeight = 175.0f;
        nColumns = 4;
        break;
    }
    try {
        int normal = Font.NORMAL;
        int bold = Font.BOLD;

        droidsans = BaseFont.createFont(fontPaths.getPath("droidsans"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        BaseFont impact = BaseFont.createFont(fontPaths.getPath("impact"), BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);

        switch (styleName) {
        case "style1":
            BaseFont courier = BaseFont.createFont(fontPaths.getPath("courier"), BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            initValues(42f, new Font(courier, 12 + textFontInc, normal, color),
                    new Font(courier, 9 + textFontInc, normal, color),
                    new Font(impact, 43 + priceFontInc + textFontInc, normal, color),
                    new Font(courier, 20 + textFontInc, normal, color),
                    new Font(courier, 8 + textFontInc, normal, color));
            break;
        case "style2":
            BaseFont digital7 = BaseFont.createFont(fontPaths.getPath("digital7"), BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            initValues(42f, new Font(droidsans, 10 + textFontInc, normal, color),
                    new Font(droidsans, 7 + textFontInc, normal, color),
                    new Font(digital7, 55 + priceFontInc + textFontInc, normal, color),
                    new Font(digital7, 30, normal, color), new Font(droidsans, 7 + textFontInc, normal, color));
            break;
        case "style3":
            BaseFont modern = BaseFont.createFont(fontPaths.getPath("modern"), BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            initValues(40f, new Font(droidsans, 10 + textFontInc, normal, color),
                    new Font(droidsans, 7 + textFontInc, normal, color),
                    new Font(modern, 55 + priceFontInc + textFontInc, normal, color),
                    new Font(modern, 30, normal, color), new Font(droidsans, 7 + textFontInc, normal, color));
            break;
        case "style4":
            BaseFont gothic = BaseFont.createFont(fontPaths.getPath("gothic"), BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            initValues(40f, new Font(droidsans, 10 + textFontInc, normal, color),
                    new Font(droidsans, 7 + textFontInc, normal, color),
                    new Font(gothic, 48 + priceFontInc + textFontInc, bold, color),
                    new Font(gothic, 30, bold, color), new Font(droidsans, 7 + textFontInc, normal, color));
            break;
        case "style5":
            BaseFont bookman = BaseFont.createFont(fontPaths.getPath("bookman"), BaseFont.IDENTITY_H,
                    BaseFont.EMBEDDED);
            initValues(35f, new Font(droidsans, 10 + textFontInc, normal, color),
                    new Font(droidsans, 7 + textFontInc, normal, color),
                    new Font(bookman, 45 + priceFontInc + textFontInc, bold, color),
                    new Font(bookman, 25, normal, color), new Font(droidsans, 7 + textFontInc, normal, color));
            break;

        case "style6":
            initValues(45f, new Font(droidsans, 10 + textFontInc, normal, color),
                    new Font(droidsans, 7 + textFontInc, normal, color),
                    new Font(impact, 45 + priceFontInc + textFontInc, normal, color),
                    new Font(droidsans, 20 + textFontInc, normal, color),
                    new Font(droidsans, 7 + textFontInc, normal, color));
            break;

        default:
            System.out.println("[*] Unknown Style");
            break;
        }

    } catch (DocumentException | IOException ex) {
        System.out.println("[E] " + ex.getMessage());
    }
}

From source file:pidevhany.Controllers.GeneratePDF.java

public GeneratePDF(String ReponsesCorretes, String ReponsesFausses) throws FileNotFoundException, IOException {
    Document document = new Document();
    OutputStream outputStream = new FileOutputStream(
            new File("D:\\Esprit\\Atelier Java\\piweb\\pidevHany\\src\\pidevhany\\TestFile.pdf"));
    try {//from  www  . ja  v  a  2 s. c  o  m
        PdfWriter writer = PdfWriter.getInstance(document, outputStream);
        document.open();
        document.add(new Paragraph("Resultat du test :"));
        PdfPTable table = new PdfPTable(2); // 3 columns.
        table.setWidthPercentage(100); //Width 100%
        table.setSpacingBefore(10f); //Space before table
        table.setSpacingAfter(10f); //Space after table

        //Set Column widths
        float[] columnWidths = { 1f, 1f };
        table.setWidths(columnWidths);

        PdfPCell cell1 = new PdfPCell(new Paragraph(ReponsesCorretes));
        cell1.setBorderColor(BaseColor.BLUE);
        cell1.setPaddingLeft(10);
        cell1.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);

        PdfPCell cell2 = new PdfPCell(new Paragraph(ReponsesFausses));
        cell2.setBorderColor(BaseColor.GREEN);
        cell2.setPaddingLeft(10);
        cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);

        table.addCell(cell1);
        table.addCell(cell2);

        document.add(table);
        document.close();
        outputStream.close();
        writer.close();
    } catch (DocumentException e) {
        e.printStackTrace();
    }

}