Example usage for com.itextpdf.text FontFactory TIMES_ROMAN

List of usage examples for com.itextpdf.text FontFactory TIMES_ROMAN

Introduction

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

Prototype

String TIMES_ROMAN

To view the source code for com.itextpdf.text FontFactory TIMES_ROMAN.

Click Source Link

Document

This is a possible value of a base 14 type 1 font

Usage

From source file:ems.memu.java

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

    JFileChooser dialog = new JFileChooser();
    dialog.setSelectedFile(new File("Employees Report.pdf"));
    int dialogResult = dialog.showSaveDialog(null);
    if (dialogResult == JFileChooser.APPROVE_OPTION) {
        String filePath = dialog.getSelectedFile().getPath();

        try {//  w  ww.j  a v a2  s  .  c  om
            // TODO add your handling code here:

            String sql = "select * from empinfo";

            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();

            Document myDocument = new Document();
            PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath));
            PdfPTable table = new PdfPTable(13);
            myDocument.open();

            float[] columnWidths = new float[] { 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8 };
            table.setWidths(columnWidths);

            table.setWidthPercentage(100); //set table width to 100%

            myDocument.add(new Paragraph("Employees List",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD)));
            myDocument.add(new Paragraph(new Date().toString()));
            myDocument.add(new Paragraph(
                    "-------------------------------------------------------------------------------------------"));
            table.addCell(new PdfPCell(
                    new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(new Paragraph("Date of Birth",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Email", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Telephone", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Address", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Department", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Gender", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Status", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Date Hired", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Job Title", FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.BOLD))));

            while (rs.next()) {

                table.addCell(new PdfPCell(new Paragraph(rs.getString(1),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(2),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(3),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(4),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(5),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(6),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(7),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(11),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(17),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(14),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(16),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(13),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(15),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.PLAIN))));

            }

            myDocument.add(table);
            myDocument.add(new Paragraph(
                    "--------------------------------------------------------------------------------------------"));
            myDocument.close();
            JOptionPane.showMessageDialog(null, "Report was successfully generated");

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

        } finally {

            try {
                rs.close();
                pst.close();

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

            }
        }
    }
}

From source file:ems.memu.java

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    JFileChooser dialog = new JFileChooser();
    dialog.setSelectedFile(new File("Employee Deduction Report.pdf"));
    int dialogResult = dialog.showSaveDialog(null);
    if (dialogResult == JFileChooser.APPROVE_OPTION) {
        String filePath = dialog.getSelectedFile().getPath();

        try {/*from  www.  j  av  a 2  s  .co  m*/
            // TODO add your handling code here:

            String sql = "select * from deduction";

            pst = conn.prepareStatement(sql);
            rs = pst.executeQuery();

            Document myDocument = new Document();
            PdfWriter myWriter = PdfWriter.getInstance(myDocument, new FileOutputStream(filePath));
            PdfPTable table = new PdfPTable(7);
            myDocument.open();

            float[] columnWidths = new float[] { 8, 8, 8, 8, 8, 8, 8 };
            table.setWidths(columnWidths);

            table.setWidthPercentage(100); //set table width to 100%

            myDocument.add(new Paragraph("Employees Deduction List",
                    FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD)));
            myDocument.add(new Paragraph(new Date().toString()));
            myDocument.add(new Paragraph(
                    "-------------------------------------------------------------------------------------------"));
            table.addCell(new PdfPCell(
                    new Paragraph("ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("First Name", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Surname", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Salary", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(new Paragraph("Deduction Amount",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(new Paragraph("Deduction Reason",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));
            table.addCell(new PdfPCell(
                    new Paragraph("Employee ID", FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.BOLD))));

            while (rs.next()) {
                table.addCell(new PdfPCell(new Paragraph(rs.getString(1),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(2),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(3),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(4),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(5),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(6),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));
                table.addCell(new PdfPCell(new Paragraph(rs.getString(7),
                        FontFactory.getFont(FontFactory.TIMES_ROMAN, 9, Font.PLAIN))));

            }

            myDocument.add(table);
            myDocument.add(new Paragraph(
                    "--------------------------------------------------------------------------------------------"));
            myDocument.close();
            JOptionPane.showMessageDialog(null, "Report was successfully generated");

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

        } finally {

            try {
                rs.close();
                pst.close();

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

            }
        }
    }

}

From source file:Forms.AddCustomers.java

private void cardBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cardBtnActionPerformed
    String name = fNameTxt.getText() + " " + lNameTxt.getText();
    String cid = cusIdTxt.getText();
    Document document = new Document();
    Rectangle test = new Rectangle(350, 200);
    BaseColor color = new BaseColor(63, 72, 204);
    test.setBackgroundColor(color);//w  w  w. java 2s  . co m
    document.setPageSize(test);

    File theDir = new File("E:\\CustomerCard");

    // if the directory does not exist, create it
    if (!theDir.exists()) {
        //System.out.println("creating directory: " + directoryName);
        boolean result = false;

        try {
            theDir.mkdir();
            result = true;
        } catch (SecurityException se) {
            System.out.println(se.getMessage());
        }
    }

    try {
        PdfWriter.getInstance(document, new FileOutputStream("E:\\CustomerCard\\card(" + cid + ").pdf"));

        document.open();
        //Image image;

        //image = Image.getInstance("api.png");

        //document.add(image);

        document.add(new Paragraph("           Customer Discount Card",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 16, Font.BOLD, BaseColor.GRAY)));
        document.add(new Paragraph("     "));
        document.add(new Paragraph("              Name : " + name,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("     "));
        document.add(new Paragraph("              Card ID: " + cid,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.close();

        try {
            //Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "+"E:\\CustomerCard\\card("+cid+").pdf");
            Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler "
                    + "C:\\Users\\Vidu\\Desktop\\CustomerIDCard\\card(" + cid + ").pdf");
        } catch (Exception ex) {
            Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex);
        }
        //document.add(new Paragraph(date,FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL,BaseColor.BLACK)));
        fNameTxt.setText("");
        lNameTxt.setText("");
        cusIdTxt.setText("");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:Forms.CloseCash.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    String sql = "SELECT * FROM `cash` WHERE 1";

    Date dNow = new Date();

    SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy");
    String date = "" + ft.format(dNow);

    File theDir = new File("E:\\Reports");

    // if the directory does not exist, create it
    if (!theDir.exists()) {
        //System.out.println("creating directory: " + directoryName);
        boolean result = false;

        try {//from   w  w  w  . j a  va2 s . co  m
            theDir.mkdir();
            result = true;
        } catch (SecurityException se) {
            //handle it
        }
    }

    try {

        Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/nafis", "root",
                "");
        Statement s = (Statement) con.prepareStatement(sql);

        ResultSet rs = s.executeQuery(sql);

        Document document = new Document(PageSize.A5);
        PdfWriter.getInstance(document, new FileOutputStream("E:\\Reports\\report(" + date + ").pdf"));
        document.open();
        Image image = Image.getInstance("api.png");
        document.add(image);
        document.add(new Paragraph("UNITY POS REPORS",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.BLUE)));
        document.add(new Paragraph(date,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));

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

        PdfPTable table = new PdfPTable(4);
        //table.addCell("Date");
        //table.addCell("Cash In/Out");

        PdfPCell cell = new PdfPCell(new Phrase("Date"));
        cell.setBackgroundColor(BaseColor.DARK_GRAY);
        table.addCell(cell);
        PdfPCell ce = new PdfPCell(new Phrase("Cash In/Out"));
        ce.setBackgroundColor(BaseColor.DARK_GRAY);
        table.addCell(ce);
        PdfPCell c = new PdfPCell(new Phrase("Cause"));
        c.setBackgroundColor(BaseColor.DARK_GRAY);
        table.addCell(c);
        PdfPCell cel = new PdfPCell(new Phrase("Amount"));
        cel.setBackgroundColor(BaseColor.DARK_GRAY);
        table.addCell(cel);

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

        float in = 0, out = 0;
        while (rs.next()) {
            String dateof = rs.getString(5);
            String inout = rs.getString(2);
            String cause = rs.getString(3);
            String amount = rs.getString(4);

            if (inout.equalsIgnoreCase("Cash In")) {
                in = in + Float.parseFloat(amount);
            } else {
                out = out + Float.parseFloat(amount);
            }

            PdfPTable t = new PdfPTable(4);
            t.addCell(dateof);
            t.addCell(inout);
            t.addCell(cause);
            t.addCell(amount);
            document.add(t);
        }

        System.out.println("in=" + in + "out=" + out);
        document.add(new Paragraph("  "));
        document.add(new Paragraph("Total Invested: " + out,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("Total Return: " + in,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("Total Earned: " + (in - out),
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("  "));
        document.add(new Paragraph(
                "--------------------------------------------------------------------------------------"));
        document.close();
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "problem in memoo");
    }

    ///////////////////////////
    //to open pdf invoice
    try {
        Runtime.getRuntime()
                .exec("rundll32 url.dll,FileProtocolHandler " + "E:\\Reports\\report(" + date + ").pdf");
    } catch (IOException ex) {
        Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:Forms.SellPage.java

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

    CashType c = new CashType();
    c.setVisible(true);/* w  w w  .  ja va 2s . com*/

    c.jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            String receive = c.jTextField1.getText();
            if (receive.equalsIgnoreCase("")) {
                JOptionPane.showMessageDialog(null, "Enter Amount");
            } else if (!receive.matches("[0-9]+")) {
                JOptionPane.showMessageDialog(null, "Enter Valid Amount");
                c.jTextField1.setText("");
            } else {
                float rec = Float.parseFloat(receive);
                //create sell
                String b = "sellno" + jTextField3.getText();

                if (CreatingSell(b)) {
                    System.out.println("Success is final");
                }

                ///code for updatng solddtime

                if (new SoldTimeUpdater().getToday(b)) {
                    System.out.println("soldtime updated");
                }

                ////code for updating sold

                String sq = "SELECT * FROM " + b;

                try {

                    Connection con = (Connection) DriverManager
                            .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");
                    Statement s = (Statement) con.prepareStatement(sq);

                    ResultSet rs = s.executeQuery(sq);

                    while (rs.next()) {
                        String name = rs.getString(2);
                        String price = rs.getString(4);
                        String buy_price = rs.getString(7);
                        String type = rs.getString(8);
                        String qua = rs.getString(3);

                        if (new SellTable().SearchExistItem(name, price + "", "sold")) {

                            new SellTable().updateItem("sold", name, Float.parseFloat(price), qua);

                        }

                        else if (new SellTable().addItem("sold", name, Float.parseFloat(price), " 2%",
                                Float.parseFloat(buy_price), type, qua)) {

                        } else {
                            JOptionPane.showMessageDialog(null, "problem");
                        }
                    }

                } catch (Exception e) {

                }

                //code for invoice

                float a = 0;

                int length;
                String sql = "SELECT * FROM " + b;

                File theDir = new File("E:\\Recept");

                // if the directory does not exist, create it
                if (!theDir.exists()) {
                    //System.out.println("creating directory: " + directoryName);
                    boolean result = false;

                    try {
                        theDir.mkdir();
                        result = true;
                    } catch (SecurityException se) {
                        //handle it
                    }
                }

                try {

                    Connection con = (Connection) DriverManager
                            .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");
                    Statement s = (Statement) con.prepareStatement(sql);

                    ResultSet rs = s.executeQuery(sql);

                    Document document = new Document();

                    Rectangle test = new Rectangle(223, 380);
                    document.setPageSize(test);
                    PdfWriter.getInstance(document, new FileOutputStream("E:\\Recept\\" + b + ".pdf"));
                    document.open();
                    document.addCreationDate();
                    document.add(new Paragraph("                        INVOICE",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    //document.add(new Paragraph("--------------------------------------------------------",FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL,BaseColor.BLACK)));
                    document.add(new Paragraph("          " + new Date().toString(),
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph("                      INVOICE NO:" + jTextField3.getText(),
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph("Product                 Qty          Price         Total",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.UNDERLINE, BaseColor.BLACK)));
                    //document.add(new Paragraph("--------------------------------------------------------",FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL,BaseColor.BLACK)));

                    while (rs.next()) {
                        String name = rs.getString(2);
                        String qua = rs.getString(3);
                        String rate = rs.getString(4);
                        String amount = rs.getString(6);
                        a = a + Float.parseFloat(amount);
                        if (name.length() <= 25) {
                            length = name.length();
                        } else {
                            length = 25;
                        }
                        document.add(new Paragraph(name.substring(0, length),
                                FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                        document.add(new Paragraph(
                                "                               " + qua + "             " + rate
                                        + "            " + amount + "",
                                FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                        //document.add(new Paragraph("                                        ",FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL,BaseColor.BLACK)));
                        //t.addCell(rate);
                        //t.addCell(amount);

                    }

                    //document.add(new Paragraph("                                   "));
                    //document.add(new Paragraph("                                   "));
                    document.add(new Paragraph("--------------------------------------------------------",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph(
                            "                                                Total=" + a + "tk",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));

                    //document.add(new Paragraph("                                   "));
                    //document.add(new Paragraph("                                   "));
                    if (jTextField6.getText().equalsIgnoreCase("") == false) {
                        float dis = Float.parseFloat(jTextField6.getText());
                        a = a - ((a * dis) / 100);

                        document.add(new Paragraph(
                                "Customer ID =" + jTextField4.getText() + "  After Discount=" + a + "tk",
                                FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    }
                    if (jTextField8.getText().equalsIgnoreCase("") == false) {
                        float dis = Float.parseFloat(jTextField8.getText());
                        a = a - ((a * dis) / 100);

                        document.add(new Paragraph(
                                "Discount =" + jTextField8.getText() + "%    After Discount=" + a + "tk",
                                FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    }

                    if (jTextField7.getText().equalsIgnoreCase("") == false) {
                        float vat = Float.parseFloat(jTextField7.getText());
                        float v = (a * vat) / 100;
                        a = a + ((a * vat) / 100);

                        document.add(new Paragraph(
                                "Vat =" + jTextField7.getText() + "%               Vat=" + v + "tk",
                                FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));

                    }
                    document.add(new Paragraph("                                     Net Amount=" + a + "tk",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph("                              Receive Amount=" + rec + "tk",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph(
                            "                             Returned Amount=" + (rec - a) + "tk     ",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));

                    document.add(new Paragraph("         Goods Once Sold Can not be Return",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph("--------------------------------------------------------",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));
                    document.add(new Paragraph("             Unity Point Of Sales System",
                            FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.NORMAL, BaseColor.BLACK)));

                    document.close();
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(null, "problem in memoo");
                }

                ///////////////////////////
                //to open pdf invoice
                try {

                    Runtime.getRuntime()
                            .exec("rundll32 url.dll,FileProtocolHandler " + "E:\\Recept\\" + b + ".pdf");
                } catch (IOException ex) {
                    Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex);
                }

                ////update todaySell

                Date dNow = new Date();

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

                String date = "" + ft.format(dNow);

                if (new updatingTodaySell().checkdate(date)) {

                    System.out.println("updating");
                    String read = "SELECT * FROM " + b;

                    try {

                        Connection con = (Connection) DriverManager
                                .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");

                        Statement s = (Statement) con.prepareStatement(read);

                        ResultSet rs = s.executeQuery(read);

                        while (rs.next()) {

                            String name = rs.getString(2);
                            String price = rs.getString(4);
                            String buy_price = rs.getString(7);
                            String type = rs.getString(8);
                            String qua = rs.getString(3);

                            if (new updatingTodaySell().searchtodaysell(name, buy_price)) {

                                System.out.println(qua);
                                new updatingTodaySell().update(name, qua, buy_price, date);
                                System.out.println("update done");
                            } else {

                                new updatingTodaySell().add(name, qua, price, buy_price, type, date);

                            }

                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                } else {

                    String sqldrop = "DELETE FROM `todaysell` WHERE 1";

                    try {

                        Connection con = (Connection) DriverManager
                                .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");

                        Statement s = (Statement) con.prepareStatement(sqldrop);

                        s.execute(sqldrop);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    String adddate = "INSERT INTO `todaysell`(`no`, `name`, `quantity`, `price`, `buyprice`, `type`, `date`) VALUES (NULL,'a','0','0','0','NULL','"
                            + date + "')";

                    try {

                        Connection con = (Connection) DriverManager
                                .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");

                        Statement s = (Statement) con.prepareStatement(adddate);

                        s.execute(adddate);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    String read = "SELECT * FROM " + b;

                    try {

                        Connection con = (Connection) DriverManager
                                .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");

                        Statement s = (Statement) con.prepareStatement(read);

                        ResultSet rs = s.executeQuery(read);

                        while (rs.next()) {

                            String name = rs.getString(2);
                            String price = rs.getString(4);
                            String buy_price = rs.getString(7);
                            String type = rs.getString(8);
                            String qua = rs.getString(3);

                            new updatingTodaySell().add(name, qua, price, buy_price, type, date);
                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }

                //droping previous sell
                int num = Integer.parseInt(jTextField3.getText());
                String ab = "sellno" + num;

                String sql1 = "SELECT * FROM information_schema.tables WHERE table_schema = 'nafis' AND table_name = '"
                        + ab + "' LIMIT 1";

                try {
                    Connection con = (Connection) DriverManager
                            .getConnection("jdbc:mysql://localhost:3306/nafis", "root", "");

                    Statement s = (Statement) con.prepareStatement(sql1);

                    ResultSet rs = s.executeQuery(sql1);

                    if (rs.next()) {
                        if (new SellTable().dropTable(ab)) {

                            System.out.println("droped table " + ab);
                        } else {
                            JOptionPane.showMessageDialog(null, "problem cancelling");
                        }

                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }

                //To update the number of sellno in db

                new SellTable().updateSellNumber();
                sellno = new SellTable().getSellNumber();
                //To show sellno in frame
                jTextField3.setText(sellno + 1 + "");

                new SellTable().createtable("sellno" + jTextField3.getText());
                retreve();

                retreve("sellno" + jTextField3.getText());

                //

                ///clear discount
                jLabel12.setText("");
                jTextField4.setText("");
                jTextField5.setText("");
                jTextField6.setText("");
                jTextField2.setText("");

                c.dispose();

            }

        }

        private void matches(String string) {
            throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }

    });

}

From source file:frames.main.java

private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
    try {// w ww. jav  a 2  s  . c o m

        BaseFont unicode = BaseFont.createFont("c:/windows/fonts/ALGER.ttf", BaseFont.IDENTITY_H,
                BaseFont.EMBEDDED);

        // Font font11113 = new Font(unicode, 16, Font.BOLD,BaseColor(2,2,2));
        ///////////////////////////////////////////////dark brown//////////////////////////////////////////////////////
        Font font1003 = new Font(unicode, 16, Font.BOLD, new BaseColor(101, 67, 33));
        Font font1008 = new Font(unicode, 20, Font.BOLD, new BaseColor(101, 67, 33));
        /////////////////////////////////////
        ///////////////////////////////////////////////dark red//////////////////////////////////////////////////////
        Font font1004 = new Font(unicode, 14, Font.BOLD, new BaseColor(139, 0, 0));
        Font font1005 = new Font(unicode, 14, Font.BOLD, new BaseColor(255, 0, 0));

        /////////////////////////////////////
        Font font100 = new Font(unicode, 8, Font.ITALIC, BaseColor.BLUE);
        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("SMART-TC.pdf"));
        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(125f, 125f);
        image2.setAbsolutePosition(31, 700);
        document.add(image2);
        com.itextpdf.text.Image ing = com.itextpdf.text.Image.getInstance("C:\\smart kid\\src\\frames\\BC.jpg");
        ing.setAbsolutePosition(1, 200);
        document.add(ing);
        Font font1111 = new Font(unicode, 16, Font.BOLD, BaseColor.ORANGE);
        Font font11111 = new Font(unicode, 14, Font.BOLD, BaseColor.ORANGE);
        java.awt.Font awtPlainFont = new java.awt.Font("ALGERIAN", java.awt.Font.PLAIN, 10);
        document.add(new Paragraph("                                    SMART KIDS CONVENT SCHOOL", font1008));
        document.add(new Paragraph(
                "                                                   HEERA NAGAR (GURGAON)         ", font1003));
        document.add(
                new Chunk("                                       SCHOLOR'S REGISTER AND TRANSFER CERTIFICATE",
                        font1005));
        document.add(new Paragraph("                                    "));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("                            ", font111));
        Font font41 = new Font(Font.FontFamily.HELVETICA, 9, Font.BOLD, new BaseColor(0, 0, 0));
        Font font23 = new Font(Font.FontFamily.HELVETICA, 12, Font.BOLD, new BaseColor(92, 64, 51));
        Font font1 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0));
        Font font11 = new Font(Font.FontFamily.HELVETICA, 12, Font.ITALIC, new BaseColor(148, 0, 211));
        Font font31 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(990000));
        Font font2 = new Font(Font.FontFamily.COURIER, 18, Font.ITALIC | Font.UNDERLINE);
        Font font3 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(255, 255, 200));

        document.add(new Paragraph(
                "Ref No:  " + TC16.getText() + "                         " + new java.util.Date().toString(),
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("    "));
        String ho4 = TC1.getText();
        Paragraph p1 = new Paragraph();
        p1.add(new Chunk("NAME OF STUDENT        :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p1.add(new Chunk(ho4, font11));
        document.add(p1);

        String ho5 = TC2.getText();
        Paragraph p2 = new Paragraph();
        p2.add(new Chunk("FATHER'S NAME          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p2.add(new Chunk(ho5, font11));
        document.add(p2);

        String ho6 = TC3.getText();
        Paragraph p93 = new Paragraph();
        p93.add(new Chunk("MOTHER'S NAME          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p93.add(new Chunk(ho6, font11));
        document.add(p93);

        Font font15 = new Font(Font.FontFamily.HELVETICA, 10, Font.BOLD, new BaseColor(0, 0, 0));
        String ho8 = TC1.getText();
        String tt = TC4.getText();
        Paragraph p4 = new Paragraph();

        p4.add(new Chunk("RELIGION               :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p4.add(new Chunk(tt, font11));

        document.add(p4);
        // document.add(new Paragraph("                                            ",font1003));
        String kk = TC5.getText();
        Paragraph p5 = new Paragraph();
        p5.add(new Chunk("CASTE OF SCHOLOR       :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p5.add(new Chunk(kk, font11));
        document.add(p5);

        String ho10 = TC10.getText();
        Paragraph p6 = new Paragraph();
        p6.add(new Chunk("ADDRESS                :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p6.add(new Chunk(ho10, font11));
        document.add(p6);

        Paragraph p8 = new Paragraph();
        p8.add(new Chunk("DATE OF BIRTH          :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p8.add(new Chunk(TC9.getText(), font11));
        document.add(p8);
        Paragraph p9 = new Paragraph();
        p9.add(new Chunk("SECTION                :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p9.add(new Chunk(TC7.getText(), font11));
        document.add(p9);
        Paragraph p10 = new Paragraph();
        p10.add(new Chunk("REGISTRATION NO:       :",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLACK)));
        p10.add(new Chunk(TC8.getText(), font11));
        document.add(p10);
        document.add(new Paragraph("                                       "));

        PdfPTable table = new PdfPTable(8);
        String vacume = "";
        table.addCell("Class");
        table.addCell("Date of Admission");
        table.addCell("Date of Promotion");
        table.addCell("Date of Removal");
        table.addCell("Cause of Removal");
        table.addCell("Year");
        table.addCell("Conduct and Work");
        table.addCell("Sign");

        PdfPCell cell10 = new PdfPCell(new Paragraph("NURSERY", font100));
        table.addCell(cell10);
        if (TC6.getSelectedIndex() == 0) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell111 = new PdfPCell(new Paragraph("LKG", font100));
        table.addCell(cell111);
        if (TC6.getSelectedIndex() == 1) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell1 = new PdfPCell(new Paragraph("UKG", font100));
        table.addCell(cell1);
        if (TC6.getSelectedIndex() == 2) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell2 = new PdfPCell(new Paragraph("STD-1", font100));
        table.addCell(cell2);
        if (TC6.getSelectedIndex() == 3) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell3 = new PdfPCell(new Paragraph("STD-2", font100));
        table.addCell(cell3);
        if (TC6.getSelectedIndex() == 4) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell4 = new PdfPCell(new Paragraph("STD-3", font100));
        table.addCell(cell4);
        if (TC6.getSelectedIndex() == 5) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell5 = new PdfPCell(new Paragraph("STD-4", font100));
        table.addCell(cell5);
        if (TC6.getSelectedIndex() == 6) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell6 = new PdfPCell(new Paragraph("STD-5", font100));
        table.addCell(cell6);
        if (TC6.getSelectedIndex() == 7) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }
        PdfPCell cell8 = new PdfPCell(new Paragraph("STD-6", font100));
        table.addCell(cell8);
        if (TC6.getSelectedIndex() == 8) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell9 = new PdfPCell(new Paragraph("STD-7", font100));
        table.addCell(cell9);
        if (TC6.getSelectedIndex() == 9) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        PdfPCell cell18 = new PdfPCell(new Paragraph("STD-8", font100));
        table.addCell(cell18);
        if (TC6.getSelectedIndex() == 2) {
            PdfPCell cell11 = new PdfPCell(new Paragraph(TC11.getText(), font100));
            PdfPCell cell12 = new PdfPCell(
                    new Paragraph(((JTextField) TC12.getDateEditor().getUiComponent()).getText(), font100));
            PdfPCell cell13 = new PdfPCell(
                    new Paragraph(((JTextField) TC13.getDateEditor().getUiComponent()).getText(), font100));
            ;
            PdfPCell cell14 = new PdfPCell(new Paragraph(TC14.getText(), font100));
            PdfPCell cell15 = new PdfPCell(new Paragraph((String) TC15.getSelectedItem(), font100));
            PdfPCell cell16 = new PdfPCell(new Paragraph(TC17.getText(), font100));
            table.addCell(cell11);
            table.addCell(cell12);
            table.addCell(cell13);
            table.addCell(cell14);
            table.addCell(cell15);
            table.addCell(cell16);
            table.addCell("");
        } else {
            for (int i = 0; i < 7; i++)
                table.addCell(vacume);
        }

        float[] ColumnWidths = new float[] { 8f, 12f, 12f, 12f, 22f, 8f, 15f, 7f };
        table.setWidths(ColumnWidths);
        table.setWidthPercentage(106);
        table.setHorizontalAlignment(Element.ALIGN_LEFT);
        document.add(table);

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "1. I certified that the entries as regard details of the student have been duly checked from the 'Admission form' and that they are complete.",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK)));
        // document.add(new Paragraph("                                                                                                        "));

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "2. Certified that the above Students register have been posted up-to date of students leaving as required by the departmental rules.",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, Font.NORMAL, BaseColor.BLACK)));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "Prepared by:-" + "                                " + "Date:-" + " "
                        + new java.util.Date().toString() + "                      " + "Principal's Sign:-",
                FontFactory.getFont(FontFactory.TIMES_BOLD, 12, Font.NORMAL, BaseColor.BLACK)));

        document.add(new Paragraph("                                       "));
        document.add(new Paragraph(
                "----------------------------------------------------------------------------------------------------------------------------------"));
        document.add(new Paragraph("An ISO 9001:2008 Certified School(Certificate Number:NOR/0712M/1505)",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE)));
        document.add(new Paragraph("(Run By:Smart Educational Society)Regd.No.(DR/GGN/285)",
                FontFactory.getFont(FontFactory.COURIER, 12, Font.NORMAL, BaseColor.BLUE)));
        document.add(new Paragraph(
                "413A/23,Gali No:-2,Heera Nagar,Near Rajendra Hospital,Khandsa Road,Gurgaon(Haryana)",
                FontFactory.getFont(FontFactory.COURIER, 10, Font.NORMAL, BaseColor.BLUE)));
        cb.saveState();
        cb.setColorStroke(BaseColor.BLACK);
        cb.rectangle(2, 2, 588, 828);
        cb.stroke();
        cb.restoreState();
        JOptionPane.showMessageDialog(this, "it is saved");
        document.close();
    } catch (Exception ee) {
        JOptionPane.showMessageDialog(this, ee);
    } // TODO add your handling code here:
}

From source file:helpers.PDFHeaderFooter.java

@Override
public void onEndPage(PdfWriter writer, Document document) {
    Rectangle rect = writer.getBoxSize("art");
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(""), rect.getLeft(),
            rect.getBottom(), 0);//  w  ww .  ja va2  s  .c o  m
    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER,
            new Phrase("Copyright @" + new SetDateCreated().getYear() + " (Wellington Mapiku)",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 7, Font.ITALIC, BaseColor.DARK_GRAY)),
            rect.getRight(), rect.getBottom(), 0);
}

From source file:Inventario.Inventario2.java

public void createDocument(String filename, String extension) throws DocumentException, FileNotFoundException {
        try {// ww w . j a  va 2 s .  co m

            Document document = new Document(PageSize.LETTER, 50, 50, 85, 50);
            document.addAuthor("Inventario");
            document.addTitle("Reporte de Inventario Compra-Venta");

            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
            writer.setInitialLeading(16);
            Rectangle rct = new Rectangle(80, 104, 500, 688);
            writer.setBoxSize("art", rct);
            HeaderFooter event = new HeaderFooter();
            writer.setPageEvent(event);

            document.open();
            Paragraph parrafo2 = new Paragraph("Reportes de Inventario",
                    FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.GRAY));
            parrafo2.setAlignment(0);
            document.add(parrafo2);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.add(Chunk.NEWLINE);
            document.close();
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }

From source file:logica.Generar_pdf.java

public void ConvertirPDF(int num, String nombre, String nombre2, String cedula, String cedula2,
        String direccion, String direccion2, String telefono, String telefono2, String sede, String tipo,
        String observacion, int peso, int declaracion_precio, int precio_neto, int precio_seguro,
        int precio_impuesto, int total_envio, String forma_pago, String fecha) throws FileNotFoundException {
    String nombre_pdf = "Factura No " + num + ".pdf";
    System.out.println(nombre_pdf);
    try {//from   www .  j a va 2 s . co m
        //Creamos documento indicando el tamao y margenes
        Document documento = new Document(PageSize.LETTER, 20, 20, 20, 20);

        //Creamos el PDF y lo instanceamos para poder escribir sobre el
        PdfWriter.getInstance(documento, new FileOutputStream(nombre_pdf)).setInitialLeading(20);

        //Abrimos el documento
        documento.open();
        System.out.println("Documento Abierto");

        //Anexamos el texto a un objeto Pharagraph
        Paragraph parametro = new Paragraph("Factura Envio de Paquete No. " + num,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK));
        parametro.setAlignment(1);
        Paragraph parametro17 = new Paragraph("Fecha: " + fecha,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 14, Font.BOLD, BaseColor.BLACK));
        parametro17.setAlignment(1);
        Paragraph parametro2 = new Paragraph("Datos Remitente",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro3 = new Paragraph("Nombre: " + nombre + "        Telefono: " + telefono,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro4 = new Paragraph("Cedula: " + cedula + "        Direccin: " + direccion,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro5 = new Paragraph("Datos Destinatario",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro6 = new Paragraph("Nombre: " + nombre2 + "        Telefono: " + telefono2,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro7 = new Paragraph("Cedula: " + cedula2 + "        Direccin: " + direccion2,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));

        Paragraph parametro8 = new Paragraph("Datos Envio",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro9 = new Paragraph("Tipo de Envio: " + tipo + "        Observacin: " + observacion,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro10 = new Paragraph(
                "Peso: " + peso + "        Declaracin precio Envio: " + declaracion_precio,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro11 = new Paragraph("Datos Pago",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK));
        Paragraph parametro12 = new Paragraph("Precio de Envio Neto: " + precio_neto,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro13 = new Paragraph("Precio Seguro:  " + precio_seguro,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro14 = new Paragraph("Excedente Impuesto:  " + precio_impuesto,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro15 = new Paragraph("Total Envio:  " + total_envio,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));
        Paragraph parametro16 = new Paragraph("Forma de Pago:  " + forma_pago,
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK));

        //Escribimos sobre el
        documento.add(parametro);
        documento.add(parametro17);
        documento.add(parametro2);
        documento.add(parametro3);
        documento.add(parametro4);
        documento.add(parametro5);
        documento.add(parametro6);
        documento.add(parametro7);
        documento.add(parametro8);
        documento.add(parametro9);
        documento.add(parametro10);
        documento.add(parametro11);
        documento.add(parametro12);
        documento.add(parametro13);
        documento.add(parametro14);
        documento.add(parametro15);
        documento.add(parametro16);

        //Cerrar documento
        documento.close();

        //Mensaje de Exito
        JOptionPane.showMessageDialog(null, "PDF Creado con exito.");

    } catch (DocumentException de) {
        System.out.println("Error...");
    }

}

From source file:om.edu.squ.squportal.portlet.tsurvey.dao.pdf.TeachingSurveyPdfImpl.java

License:Open Source License

/**
 * //from   w  w w .  java2s.c  om
 * method name  : getPdfSurveyAnalysis
 * @param object
 * @param semesterYear
 * @param questionByYear
 * @param questionSetNo
 * @param byos
 * @param inputStream
 * @param res
 * @return
 * @throws DocumentException
 * @throws IOException
 * TeachingSurveyPdfImpl
 * return type  : OutputStream
 * 
 * purpose      : Generate PDF content
 *
 * Date          :   Mar 28, 2016 7:21:04 PM
 */
public OutputStream getPdfSurveyAnalysis(Object object, String semesterYear, String questionByYear,
        int questionSetNo, ByteArrayOutputStream byos, InputStream inputStream, ResourceResponse res)
        throws DocumentException, IOException {

    Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, BaseColor.BLACK);

    PdfReader pdfTemplate = new PdfReader(inputStream);
    PdfStamper pdfStamper = new PdfStamper(pdfTemplate, byos);
    Survey survey = (Survey) object;
    String sectionNos = "";
    String seatsTaken = "";
    DecimalFormat formatter = new DecimalFormat("###.##");

    String RIGHT = Constants.RIGHT;
    String CENTER = Constants.CENTER;
    String LEFT = Constants.LEFT;

    pdfStamper.getAcroFields().setField("txtCourse", survey.getCourseCode() + " / " + survey.getCourseName());
    pdfStamper.getAcroFields().setField("txtCollegeName", survey.getCollegeName());

    for (SurveyResponse resp : survey.getSurveyResponses()) {
        sectionNos = sectionNos + resp.getSectionNo() + " ";
        seatsTaken = String.valueOf(resp.getSeatsTaken());
    }

    pdfStamper.getAcroFields().setField("txtSectionNo", sectionNos);
    pdfStamper.getAcroFields().setField("txtDepartmentName", survey.getDepartmentName());
    pdfStamper.getAcroFields().setField("txtEmpName", survey.getEmpName());
    pdfStamper.getAcroFields().setField("txtStudentRegistered", seatsTaken);

    pdfStamper.getAcroFields().setField("txtSemesterYear", semesterYear);

    pdfStamper.getAcroFields().setGenerateAppearances(true);

    /* ****************** */

    PdfPTable table = new PdfPTable(13);

    table.addCell(getPdfCell("", 2, 0, font, LEFT));
    table.addCell(getPdfCell(
            UtilProperty.getMessage("prop.course.teaching.survey.analysis.course.teaching.items", null), 2, 0,
            font, CENTER));
    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.response.number", null), 0,
                    6, font, CENTER));
    table.addCell(getPdfCell(
            UtilProperty.getMessage("prop.course.teaching.survey.analysis.response.percentage", null), 2, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.mean", null), 0, 4,
            font, CENTER));

    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.disagree.strong", null), 0,
                    0, font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.disagree", null), 0,
            0, font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.agree", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.agree.strong", null),
            0, 0, font, CENTER));
    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.applicable.not", null), 0,
                    0, font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.total", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.sect", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.crs", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.dept", null), 0, 0,
            font, CENTER));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.col", null), 0, 0,
            font, CENTER));

    /* ---------------------------------------------------------------------------- */
    table.addCell(getPdfCell("", 0, 0, font));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.course.items", null),
            0, 12, font, CENTER));

    int cTotal = 0;
    float cPctVal = 0f;
    float cSectionMean = 0f;
    float cCourseMean = 0f;
    float cDepart = 0f;
    float cCollege = 0f;
    int rowCount = 0;

    for (SurveyResponse sures : survey.getSurveyResponses()) {
        for (Analysis analysis : sures.getAnalysisList()) {
            if (analysis.getQuestion().equals("Q2") || analysis.getQuestion().equals("Q14")
                    || analysis.getQuestion().equals(questionByYear)) {
                /***  First part    ***/
                table.addCell(getPdfCell(analysis.getQuestion(), 0, 0, font));
                table.addCell(
                        getPdfCell(
                                UtilProperty.getMessage("prop.course.teaching.survey.analysis.set"
                                        + questionSetNo + ".question" + analysis.getQuestionLabel(), null),
                                0, 0, font, LEFT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongDisagree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDisAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getNotApplicable()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getTotal()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getPercentageResponse()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getSectionMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCourseMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDepartmentMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCollegeMean()), 0, 0, font, RIGHT));

                cTotal = cTotal + analysis.getTotal();
                cPctVal = cPctVal + analysis.getPercentageResponse();
                cSectionMean = cSectionMean + analysis.getSectionMean();
                cCourseMean = cCourseMean + analysis.getCollegeMean();
                cDepart = cDepart + analysis.getDepartmentMean();
                cCollege = cCollege + analysis.getCollegeMean();
                rowCount = rowCount + 1;

            }
        }
    }

    /***  First part - Summary   ***/
    table.addCell(getPdfCell(String.valueOf(""), 0, 0, font));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.summary", null), 0,
            0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(""), 0, 5, font));
    table.addCell(getPdfCell(String.valueOf(cTotal), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cPctVal / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cSectionMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCourseMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cDepart / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCollege / rowCount)), 0, 0, font, RIGHT));

    table.addCell(getPdfCell("", 0, 13, font));

    table.addCell(getPdfCell("", 0, 0, font));
    table.addCell(
            getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.teaching.items", null), 0,
                    12, font, LEFT));

    cTotal = 0;
    cPctVal = 0f;
    cSectionMean = 0f;
    cCourseMean = 0f;
    cDepart = 0f;
    cCollege = 0f;
    rowCount = 0;
    for (SurveyResponse sures : survey.getSurveyResponses()) {
        for (Analysis analysis : sures.getAnalysisList()) {
            if (!(analysis.getQuestion().equals("Q2") || analysis.getQuestion().equals("Q14")
                    || analysis.getQuestion().equals(questionByYear))) {

                table.addCell(getPdfCell(analysis.getQuestion(), 0, 0, font));
                table.addCell(
                        getPdfCell(
                                UtilProperty.getMessage("prop.course.teaching.survey.analysis.set"
                                        + questionSetNo + ".question" + analysis.getQuestionLabel(), null),
                                0, 0, font, LEFT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongDisagree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDisAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getStrongAgree()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getNotApplicable()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getTotal()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getPercentageResponse()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getSectionMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCourseMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getDepartmentMean()), 0, 0, font, RIGHT));
                table.addCell(getPdfCell(String.valueOf(analysis.getCollegeMean()), 0, 0, font, RIGHT));

                cTotal = cTotal + analysis.getTotal();
                cPctVal = cPctVal + analysis.getPercentageResponse();
                cSectionMean = cSectionMean + analysis.getSectionMean();
                cCourseMean = cCourseMean + analysis.getCollegeMean();
                cDepart = cDepart + analysis.getDepartmentMean();
                cCollege = cCollege + analysis.getCollegeMean();
                rowCount = rowCount + 1;

            }

        }

    }

    /***  Second part - Summary   ***/
    table.addCell(getPdfCell(String.valueOf(""), 0, 0, font));
    table.addCell(getPdfCell(UtilProperty.getMessage("prop.course.teaching.survey.analysis.summary", null), 0,
            0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(""), 0, 5, font));
    table.addCell(getPdfCell(String.valueOf(cTotal), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cPctVal / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cSectionMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCourseMean / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cDepart / rowCount)), 0, 0, font, RIGHT));
    table.addCell(getPdfCell(String.valueOf(formatter.format(cCollege / rowCount)), 0, 0, font, RIGHT));

    if (!survey.getMessage().equals("")) {
        table.addCell(getPdfCell("", 0, 13, font));
        table.addCell(getPdfCell("", 0, 0, font));
        table.addCell(getPdfCell(survey.getMessage(), 0, 12, font, CENTER));
    }

    table.setTotalWidth(750);
    table.setLockedWidth(true);
    table.setWidths(new float[] { 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 });

    ColumnText column = new ColumnText(pdfStamper.getOverContent(1));
    Rectangle rectPage1 = new Rectangle(120, 20, 659, 480);

    column.setSimpleColumn(rectPage1);
    column.addElement(table);

    int status = column.go();

    pdfStamper.setFormFlattening(true);

    pdfStamper.close();

    pdfTemplate.close();

    res.setContentType("application/pdf");

    return res.getPortletOutputStream();

}