Example usage for com.lowagie.text.pdf PdfPTable PdfPTable

List of usage examples for com.lowagie.text.pdf PdfPTable PdfPTable

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfPTable PdfPTable.

Prototype

public PdfPTable(PdfPTable table) 

Source Link

Document

Constructs a copy of a PdfPTable.

Usage

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI Informixpdf/*from  ww w . j  ava  2  s.  c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_InformixCldPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        //  document.add(aTable);
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable spaceTable = new PdfPTable(8);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    cell = new PdfPCell(new Phrase((i + 1) + ""));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("dbspace")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("owner")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase((String) tablesVO.get("fname")));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(
                            new Phrase(df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%"));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                }
            }
        }
        document.add(spaceTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable hhTable = new PdfPTable(8);
        float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        hhTable.setWidths(hhWidth);
        hhTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(8);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        // hhTable.endHeaders();

        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tablesVO.get("access") + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(tablesVO.get("locksheld") + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(seqscans));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(total_sorts));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new PdfPCell(new Phrase(dsksorts));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
            }
        }
        document.add(hhTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable lockTable = new PdfPTable(6);
        float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f };
        lockTable.setWidths(lockWidth);
        lockTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        // lockTable.endHeaders();

        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("username")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("hostname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("dbsname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase((String) tablesVO.get("tabname")));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new PdfPCell(new Phrase(desc));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
            }
        }
        document.add(lockTable);

        // Informix
        document.add(new Paragraph("\n"));
        PdfPTable logTable = new PdfPTable(9);
        float[] logWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        logTable.setWidths(logWidth);
        logTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setColspan(9);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("ID   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        logTable.addCell(cell);
        // logTable.endHeaders();

        List dblog = (ArrayList) dbinfo.get("informixlog");// 
        if (dblog != null && dblog.size() > 0) {
            for (int i = 0; i < dblog.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblog.get(i);
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("uniqid"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("size"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("used"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_used"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_current"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_backed_up"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_archived"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("is_temp"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                logTable.addCell(cell);
            }
        }
        document.add(logTable);

        // InformixIO
        document.add(new Paragraph("\n"));
        PdfPTable ioTable = new PdfPTable(10);
        float[] ioWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        ioTable.setWidths(ioWidth);
        ioTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("IO   ", titleFont));
        cell.setColspan(10);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        cell = new PdfPCell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        ioTable.addCell(cell);
        // ioTable.endHeaders();

        List dbio = (ArrayList) dbinfo.get("iolist");// IO
        if (dbio != null && dbio.size() > 0) {
            for (int i = 0; i < dbio.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbio.get(i);
                cell = new PdfPCell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("chunknum"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("reads"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("pagesread"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("writes"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("pageswritten"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mreads"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mpagesread"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mwrites"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
                cell = new PdfPCell(new Phrase(String.valueOf(tablesVO.get("mpageswritten"))));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                ioTable.addCell(cell);
            }
        }
        document.add(ioTable);

        // 
        document.add(new Paragraph("\n"));
        PdfPTable eventTable = new PdfPTable(2);
        float[] eventWidths = { 220f, 220f };
        eventTable.setWidths(eventWidths);
        eventTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        document.add(eventTable);

        document.add(new Paragraph("\n"));
        // 
        addEventLisToPdf(document);
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI date 2010-11-11  pdf//from   w  w  w  . ja va 2s  .  c o  m
 * @param filename
 */
public void createReportPingPdf(String filename) {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL);
        String dbtype = (String) reportHash.get("dbtype");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        document.add(title);
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;
        Paragraph context = new Paragraph(contextString, contextFont1);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        PdfPTable aTable = new PdfPTable(4);
        float[] widths = { 220f, 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(""));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell = new PdfPCell(new Phrase(reportHash.get("pingnow") + "%"));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new PdfPCell(new Phrase((String) maxping.get("ping")));
        cell = new PdfPCell(new Phrase(reportHash.get("pingmin") + "%"));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(reportHash.get("avgpingcon") + "%"));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.MIDDLE);// 
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 
            document.add(img1);
        }
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI pdf/*ww w  .  jav a  2  s .  c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_EventPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String ip = (String) reportHash.get("ip");
        String typename = (String) reportHash.get("typename");
        DBVo vo = (DBVo) reportHash.get("vo");
        String downnum = (String) reportHash.get("downnum");
        String count = (Integer) reportHash.get("count") + "";
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Hashtable maxping = (Hashtable) reportHash.get("ping");
        String hostname = (String) reportHash.get("dbname");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        PdfPTable dbTable = new PdfPTable(5);
        float[] cellWidths = { 220f, 220f, 220f, 220f, 220f };
        dbTable.setWidths(cellWidths);
        dbTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("IP", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(vo.getDbName(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(ip, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(typename, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(downnum, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new PdfPCell(new Phrase(count, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        document.add(dbTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable eventTable = new PdfPTable(6);
        float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        eventTable.setWidths(eventWidths);
        eventTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        int index = 0;
        java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
        List list = (ArrayList) reportHash.get("list");
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                index++;
                EventList eventlist = (EventList) list.get(i);
                Date cc = eventlist.getRecordtime().getTime();
                Integer eventid = eventlist.getId();
                String eventlocation = eventlist.getEventlocation();
                String content = eventlist.getContent();
                String level = String.valueOf(eventlist.getLevel1());
                String status = String.valueOf(eventlist.getManagesign());
                String s = status;
                String showlevel = null;
                String act = "";
                if ("1".equals(level)) {
                    showlevel = "";
                } else if ("2".equals(level)) {
                    showlevel = "";
                } else {
                    showlevel = "";
                }
                if ("0".equals(status)) {
                    status = "";
                }
                if ("1".equals(status)) {
                    status = "";
                }
                if ("2".equals(status)) {
                    status = "";
                }
                String rptman = eventlist.getReportman();
                String rtime1 = _sdf.format(cc);
                cell = new PdfPCell(new Phrase(String.valueOf(index), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                if ("3".equals(level)) {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.red);
                    eventTable.addCell(cell);
                } else if ("2".equals(level)) {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.orange);
                    eventTable.addCell(cell);
                } else {
                    cell = new PdfPCell(new Phrase(showlevel, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    cell.setBackgroundColor(Color.yellow);
                    eventTable.addCell(cell);
                }
                cell = new PdfPCell(new Phrase(content, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rtime1, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(rptman, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
                cell = new PdfPCell(new Phrase(status, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                eventTable.addCell(cell);
            }
        }

        document.add(eventTable);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI MySQL pdf/*from   w w  w.  j  av a 2  s. c  o m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportMySQLSelfPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Vector val = (Vector) reportHash.get("Val");
        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingnow")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("pingmax")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon")));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        //  document.add(aTable);
        img.scalePercent(76);
        document.add(aTable);
        document.add(img);

        document.add(new Paragraph("\n"));
        PdfPTable aTable1 = new PdfPTable(2);
        float[] width = { 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("     ", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        if (val != null && val.size() > 0) {
            for (int i = 0; i < val.size(); i++) {
                Hashtable return_value = (Hashtable) val.get(i);
                if (return_value != null && return_value.size() > 0) {
                    String name = return_value.get("variable_name").toString();
                    String value = return_value.get("value").toString();
                    if (name.equalsIgnoreCase("Max_used_connections")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_first")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_key")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_prev")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd")) {
                        name = "H";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Open_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Opened_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_cached")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_connected")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_created")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_running")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_immediate")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_waited")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_read_requests")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_reads")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("log_slow_queries")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("slow_launch_time")) {
                        name = "Slow_launch_threads";
                    }
                    cell = new PdfPCell(new Phrase(name, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new PdfPCell(new Phrase(value));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    // aTable1.endHeaders();
                }
            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(aTable1);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI MySQLpdf/*w  ww  . ja  v a 2s  .  c o m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_MySQLCldPdf(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String typename = (String) reportHash.get("typename");
        String runstr = (String) reportHash.get("runstr");
        String grade = (String) reportHash.get("grade");
        String pingnow = (String) reportHash.get("pingnow");
        String pingmin = (String) reportHash.get("pingmin");
        String pingconavg = (String) reportHash.get("pingconavg");
        DBVo vo = (DBVo) reportHash.get("vo");
        Vector val = (Vector) reportHash.get("Val");
        if (val == null) {
            val = new Vector();
        }
        List sessionlist = (ArrayList) reportHash.get("sessionlist");
        if (sessionlist == null) {
            sessionlist = new ArrayList();
        }
        Hashtable tablesHash = (Hashtable) reportHash.get("tablesHash");
        if (tablesHash == null) {
            tablesHash = new Hashtable();
        }
        Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");
        if (tableinfo_v == null) {
            tableinfo_v = new Vector();
        }
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        document.add(new Paragraph("\n"));
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        PdfPTable dbTable = new PdfPTable(5);
        float[] cellWidths = { 220f, 220f, 220f, 220f, 220f };
        dbTable.setWidths(cellWidths);
        dbTable.setWidthPercentage(100);
        PdfPCell dbCell = null;
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setColspan(5);
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("IP", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(vo.getDbName(), contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(ip, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(typename, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(runstr, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new PdfPCell(new Phrase(grade, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);

        PdfPTable aTable = new PdfPTable(3);
        float[] widths = { 220f, 220f, 220f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(pingnow + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(pingmin + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase(pingconavg + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        // img.setAbsolutePosition(0, 0);
        img.scalePercent(76);
        img.setAlignment(Image.MIDDLE);// 
        document.add(dbTable);
        document.add(new Paragraph("\n"));
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable xnTable = new PdfPTable(2);
        float[] width = { 220f, 220f };
        xnTable.setWidths(width);
        xnTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("     ", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        xnTable.addCell(cell);
        if (val != null && val.size() > 0) {
            for (int i = 0; i < val.size(); i++) {
                Hashtable return_value = (Hashtable) val.get(i);
                if (return_value != null && return_value.size() > 0) {
                    String name = return_value.get("variable_name").toString();
                    String value = return_value.get("value").toString();
                    if (name.equalsIgnoreCase("Max_used_connections")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_first")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_key")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_prev")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd")) {
                        name = "H";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Open_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Opened_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_cached")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_connected")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_created")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_running")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_immediate")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_waited")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_read_requests")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_reads")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("log_slow_queries")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("slow_launch_time")) {
                        name = "Slow_launch_threads";
                    }
                    cell = new PdfPCell(new Phrase(name, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    xnTable.addCell(cell);
                    cell = new PdfPCell(new Phrase(value, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    xnTable.addCell(cell);
                    // xnTable.endHeaders();
                }
            }
        }
        document.add(xnTable);
        document.add(new Paragraph("\n"));
        // 
        PdfPTable connTable = new PdfPTable(6);
        float[] cwidth = { 220f, 220f, 220f, 220f, 220f, 220f };
        connTable.setWidths(cwidth);
        connTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("      ", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        connTable.addCell(cell);
        if (sessionlist != null && sessionlist.size() > 0) {
            int rowI = 1;
            for (int i = 0; i < sessionlist.size(); i++) {
                List ipsessionlist = (List) sessionlist.get(i);
                if (ipsessionlist != null && ipsessionlist.size() > 0) {
                    for (int k = 0; k < ipsessionlist.size(); k++) {
                        String[] sessions = (String[]) ipsessionlist.get(k);
                        if (sessions != null && sessions.length == 5) {
                            cell = new PdfPCell(new Phrase(String.valueOf(rowI), contextFont));
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                            connTable.addCell(cell);
                            cell = new PdfPCell(new Phrase(sessions[4], contextFont));
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                            connTable.addCell(cell);
                            cell = new PdfPCell(new Phrase(sessions[0], contextFont));
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                            connTable.addCell(cell);
                            cell = new PdfPCell(new Phrase(sessions[1], contextFont));
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                            connTable.addCell(cell);
                            cell = new PdfPCell(new Phrase(sessions[2], contextFont));
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                            connTable.addCell(cell);
                            cell = new PdfPCell(new Phrase(sessions[3], contextFont));
                            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                            connTable.addCell(cell);
                            // connTable.endHeaders();
                            rowI++;
                        }
                    }
                }
            }
        }
        document.add(connTable);
        document.add(new Paragraph("\n"));
        // 
        PdfPTable tabTable = new PdfPTable(5);
        float[] tabwidth = { 220f, 220f, 220f, 220f, 220f };
        tabTable.setWidths(tabwidth);
        tabTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("      ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        tabTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        tabTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        tabTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        tabTable.addCell(cell);
        cell = new PdfPCell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        tabTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        tabTable.addCell(cell);
        String[] dbs = vo.getDbName().split(",");
        if (dbs != null && dbs.length > 0) {
            int rowI = 1;
            for (int i = 0; i < dbs.length; i++) {
                String dbStr = dbs[i];
                // System.out.println(dbStr+"====="+tablesHash.size());
                if (tablesHash.containsKey(dbStr)) {
                    List tableslist = (List) tablesHash.get(dbStr);
                    if (tableslist != null && tableslist.size() > 0) {
                        for (int k = 0; k < tableslist.size(); k++) {
                            String[] tables = (String[]) tableslist.get(k);
                            if (tables != null && tables.length == 4) {
                                cell = new PdfPCell(new Phrase(String.valueOf(rowI), contextFont));
                                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                                tabTable.addCell(cell);
                                cell = new PdfPCell(new Phrase(tables[0], contextFont));
                                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                                tabTable.addCell(cell);
                                cell = new PdfPCell(new Phrase(tables[1], contextFont));
                                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                                tabTable.addCell(cell);
                                cell = new PdfPCell(new Phrase(tables[2], contextFont));
                                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                                tabTable.addCell(cell);
                                cell = new PdfPCell(new Phrase(tables[3], contextFont));
                                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                                tabTable.addCell(cell);
                                // tabTable.endHeaders();
                                rowI++;
                            }
                        }
                    }
                }
            }
        }
        document.add(tabTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable stateTable = new PdfPTable(3);
        float[] swidth = { 220f, 220f, 220f };
        stateTable.setWidths(swidth);
        stateTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("    ", titleFont));
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        stateTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        stateTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        stateTable.addCell(cell);
        cell = new PdfPCell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        stateTable.addCell(cell);
        if (tableinfo_v != null) {
            int rowI = 1;
            for (int i = 0; i < tableinfo_v.size(); i++) {
                Hashtable ht = (Hashtable) tableinfo_v.get(i);
                String size = ht.get("variable_name").toString();
                String free = ht.get("value").toString();
                if (size.equalsIgnoreCase("auto_increment_increment")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("auto_increment_offset")) {
                    size = "AUTO_INCREMENT";
                }
                if (size.equalsIgnoreCase("automatic_sp_privileges")) {
                    size = "automatic_sp_privileges";
                }
                if (size.equalsIgnoreCase("back_log")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("basedir")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("binlog_cache_size")) {
                    size = "SQL";
                }
                if (size.equalsIgnoreCase("bulk_insert_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_client")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_connection")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_database")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_filesystem")) {
                    size = "character_set_filesystem";
                }
                if (size.equalsIgnoreCase("character_set_results")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_server")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_system")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_sets_dir")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("collation_connection")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("collation_database")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("collation_server")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("completion_type")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("concurrent_insert")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("connect_timeout")) {
                    size = "Bad handshake";
                }
                if (size.equalsIgnoreCase("datadir")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("date_format")) {
                    size = "date_format()";
                }
                if (size.equalsIgnoreCase("datetime_format")) {
                    size = "datetime_format()";
                }
                if (size.equalsIgnoreCase("default_week_format")) {
                    size = "WEEK() ";
                }
                if (size.equalsIgnoreCase("delay_key_write")) {
                    size = "DELAY_KEY_WRITE";
                }
                if (size.equalsIgnoreCase("delayed_insert_limit")) {
                    size = "INSERT DELAYEDSELECT";
                }
                if (size.equalsIgnoreCase("delayed_insert_timeout")) {
                    size = "INSERT DELAYEDINSERT";
                }
                if (size.equalsIgnoreCase("delayed_queue_size")) {
                    size = "INSERT DELAYED";
                }
                if (size.equalsIgnoreCase("div_precision_increment")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("engine_condition_pushdown")) {
                    size = "NDB";
                }
                if (size.equalsIgnoreCase("expire_logs_days")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("flush")) {
                    size = "flushmysqld";
                }
                if (size.equalsIgnoreCase("flush_time")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("ft_boolean_syntax")) {
                    size = "IN BOOLEAN MODE";
                }
                if (size.equalsIgnoreCase("ft_max_word_len")) {
                    size = "FULLTEXT";
                }
                if (size.equalsIgnoreCase("ft_min_word_len")) {
                    size = "FULLTEXT";
                }
                if (size.equalsIgnoreCase("ft_query_expansion_limit")) {
                    size = "WITH QUERY EXPANSION";
                }
                if (size.equalsIgnoreCase("ft_stopword_file")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("group_concat_max_len")) {
                    size = "GROUP_CONCAT()";
                }
                if (size.equalsIgnoreCase("have_archive")) {
                    size = "mysqldARCHIVE";
                }
                if (size.equalsIgnoreCase("have_bdb")) {
                    size = "mysqldBDB";
                }
                if (size.equalsIgnoreCase("have_blackhole_engine")) {
                    size = "mysqldBLACKHOLE";
                }
                if (size.equalsIgnoreCase("have_compress")) {
                    size = "zlib";
                }
                if (size.equalsIgnoreCase("have_crypt")) {
                    size = "crypt()";
                }
                if (size.equalsIgnoreCase("have_csv")) {
                    size = "mysqldARCHIVE";
                }
                if (size.equalsIgnoreCase("have_example_engine")) {
                    size = "mysqldEXAMPLE";
                }
                if (size.equalsIgnoreCase("have_federated_engine")) {
                    size = "mysqldFEDERATED";
                }
                if (size.equalsIgnoreCase("have_geometry")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("have_innodb")) {
                    size = "mysqldInnoDB";
                }
                if (size.equalsIgnoreCase("have_isam")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("have_ndbcluster")) {
                    size = "mysqldNDB CLUSTER";
                }
                if (size.equalsIgnoreCase("have_openssl")) {
                    size = "mysqld/SSL()";
                }
                if (size.equalsIgnoreCase("have_query_cache")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("have_raid")) {
                    size = "mysqldRAID";
                }
                if (size.equalsIgnoreCase("have_rtree_keys")) {
                    size = "RTREE";
                }
                if (size.equalsIgnoreCase("have_symlink")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("init_connect")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("init_file")) {
                    size = "--init-file";
                }
                if (size.equalsIgnoreCase("init_slave")) {
                    size = "SQL";
                }
                if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_autoextend_increment")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) {
                    size = "32WindowsAWE";
                }
                if (size.equalsIgnoreCase("innodb_buffer_pool_size")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_checksums")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_commit_concurrency")) {
                    size = "innodb_commit_concurrency";
                }
                if (size.equalsIgnoreCase("innodb_concurrency_tickets")) {
                    size = "innodb_concurrency_tickets";
                }
                if (size.equalsIgnoreCase("innodb_data_file_path")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_data_home_dir")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_doublewrite")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_fast_shutdown")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_file_io_threads")) {
                    size = "InnoDBI/O";
                }
                if (size.equalsIgnoreCase("innodb_file_per_table")) {
                    size = "InnoDB.ibd";
                }
                if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_flush_method")) {
                    size = "InnoDBfsync()";
                }
                if (size.equalsIgnoreCase("innodb_force_recovery")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_log_arch_dir")) {
                    size = " ";
                }
                if (size.equalsIgnoreCase("innodb_log_archive")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_log_buffer_size")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_log_file_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_log_files_in_group")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_log_group_home_dir")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_max_purge_lag")) {
                    size = "INSERT,UPDATEDELETE";
                }
                if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_open_files")) {
                    size = "InnoDB.ibd";
                }
                if (size.equalsIgnoreCase("innodb_support_xa")) {
                    size = "InnoDBXA";
                }
                if (size.equalsIgnoreCase("innodb_sync_spin_loops")) {
                    size = "innodb_sync_spin_loops";
                }
                if (size.equalsIgnoreCase("innodb_table_locks")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_thread_concurrency")) {
                    size = "InnoDBInnoDB";
                }
                if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) {
                    size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status";
                }
                if (size.equalsIgnoreCase("interactive_timeout")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("join_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("key_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("key_cache_age_threshold")) {
                    size = "(sub-chain)(sub-chain)";
                }
                if (size.equalsIgnoreCase("key_cache_block_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("key_cache_division_limit")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("language")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("large_files_support")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("large_page_size")) {
                    size = "large_page_size";
                }
                if (size.equalsIgnoreCase("large_pages")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("license")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("local_infile")) {
                    size = "LOCALLOAD DATA INFILE";
                }
                if (size.equalsIgnoreCase("log")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_bin")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_bin_trust_function_creators")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_error")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_slave_updates")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_slow_queries")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_warnings")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("long_query_time")) {
                    size = "Slow_queries";
                }
                if (size.equalsIgnoreCase("low_priority_updates")) {
                    size = "sqlSELECTLOCK TABLE READ";
                }
                if (size.equalsIgnoreCase("lower_case_file_system")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("lower_case_table_names")) {
                    size = "1";
                }
                if (size.equalsIgnoreCase("max_allowed_packet")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("max_binlog_cache_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_binlog_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_connect_errors")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_connections")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_delayed_threads")) {
                    size = "INSERT DELAYED";
                }
                if (size.equalsIgnoreCase("max_error_count")) {
                    size = "SHOW ERRORSSHOW WARNINGS";
                }
                if (size.equalsIgnoreCase("max_heap_table_size")) {
                    size = "MEMORY (HEAP)";
                }
                if (size.equalsIgnoreCase("max_insert_delayed_threads")) {
                    size = "INSERT DELAYED(max_delayed_threads)";
                }
                if (size.equalsIgnoreCase("max_join_size")) {
                    size = "max_join_size";
                }
                if (size.equalsIgnoreCase("max_length_for_sort_data")) {
                    size = "filesort";
                }
                if (size.equalsIgnoreCase("max_prepared_stmt_count")) {
                    size = "max_prepared_stmt_count";
                }
                if (size.equalsIgnoreCase("max_relay_log_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_seeks_for_key")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_sort_length")) {
                    size = "BLOBTEXT";
                }
                if (size.equalsIgnoreCase("max_sp_recursion_depth")) {
                    size = "max_sp_recursion_depth";
                }
                if (size.equalsIgnoreCase("max_tmp_tables")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_user_connections")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("max_write_lock_count")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("multi_range_count")) {
                    size = "multi_range_count";
                }
                if (size.equalsIgnoreCase("myisam_data_pointer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("myisam_max_sort_file_size")) {
                    size = "MyISAMMySQL";
                }
                if (size.equalsIgnoreCase("myisam_recover_options")) {
                    size = "myisam-recover";
                }
                if (size.equalsIgnoreCase("myisam_repair_threads")) {
                    size = "1Repair by sortingMyISAM";
                }
                if (size.equalsIgnoreCase("myisam_sort_buffer_size")) {
                    size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM";
                }
                if (size.equalsIgnoreCase("myisam_stats_method")) {
                    size = "MyISAMNULL";
                }
                if (size.equalsIgnoreCase("named_pipe")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_buffer_length")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_read_timeout")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_retry_count")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_write_timeout")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("new")) {
                    size = "MySQL 4.04.1";
                }
                if (size.equalsIgnoreCase("old_passwords")) {
                    size = "MySQLpre-4.1-style";
                }
                if (size.equalsIgnoreCase("open_files_limit")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("optimizer_prune_level")) {
                    size = " 0";
                }
                if (size.equalsIgnoreCase("optimizer_search_depth")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("pid_file")) {
                    size = "ID (PID)";
                }
                if (size.equalsIgnoreCase("prepared_stmt_count")) {
                    size = "prepared_stmt_count";
                }
                if (size.equalsIgnoreCase("port")) {
                    size = "TCP/IP";
                }
                if (size.equalsIgnoreCase("preload_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("protocol_version")) {
                    size = "MySQL/";
                }
                if (size.equalsIgnoreCase("query_alloc_block_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_limit")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_min_res_unit")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("query_cache_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_type")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) {
                    size = "WRITE";
                }
                if (size.equalsIgnoreCase("query_prealloc_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("range_alloc_block_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("read_buffer_size")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("read_only")) {
                    size = "ON";
                }
                if (size.equalsIgnoreCase("read_only")) {
                    size = "ON";
                }
                if (size.equalsIgnoreCase("relay_log_purge")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("read_rnd_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("secure_auth")) {
                    size = "--secure-authMySQL(4.1)";
                }
                if (size.equalsIgnoreCase("shared_memory")) {
                    size = "(Windows)";
                }
                if (size.equalsIgnoreCase("shared_memory_base_name")) {
                    size = "(Windows)";
                }
                if (size.equalsIgnoreCase("server_id")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("skip_external_locking")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("skip_networking")) {
                    size = "(TCP/IP)";
                }
                if (size.equalsIgnoreCase("skip_show_database")) {
                    size = "SHOW DATABASESSHOW DATABASES";
                }
                if (size.equalsIgnoreCase("slave_compressed_protocol")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("slave_load_tmpdir")) {
                    size = "LOAD DATA INFILE";
                }
                if (size.equalsIgnoreCase("slave_net_timeout")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("slave_skip_errors")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("slave_transaction_retries")) {
                    size = "SQLslave_transaction_retries";
                }
                if (size.equalsIgnoreCase("slow_launch_time")) {
                    size = "Slow_launch_threads";
                }
                if (size.equalsIgnoreCase("sort_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("sql_mode")) {
                    size = "SQL";
                }
                if (size.equalsIgnoreCase("storage_engine")) {
                    size = "table_typeisMySQL 5.1,storage_engine";
                }
                if (size.equalsIgnoreCase("sync_binlog")) {
                    size = "sync_binlog'thMySQL";
                }
                if (size.equalsIgnoreCase("sync_frm")) {
                    size = "1,.frm";
                }
                if (size.equalsIgnoreCase("system_time_zone")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("table_cache")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("table_type")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("thread_cache_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("thread_stack")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("time_format")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("time_zone")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("tmp_table_size")) {
                    size = "MySQLMyISAM";
                }
                if (size.equalsIgnoreCase("tmpdir")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("transaction_alloc_block_size")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("transaction_prealloc_size")) {
                    size = "transaction_alloc_blocks";
                }
                if (size.equalsIgnoreCase("tx_isolation")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("updatable_views_with_limit")) {
                    size = "LIMIT";
                }
                if (size.equalsIgnoreCase("version")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("version_bdb")) {
                    size = "BDB";
                }
                if (size.equalsIgnoreCase("version_comment")) {
                    size = "configure--with-commentMySQL";
                }
                if (size.equalsIgnoreCase("version_compile_machine")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("version_compile_os")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("wait_timeout")) {
                    size = "";
                }
                cell = new PdfPCell(new Phrase(String.valueOf(rowI), contextFont));// mark
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                stateTable.addCell(cell);
                cell = new PdfPCell(new Phrase(size, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                stateTable.addCell(cell);
                cell = new PdfPCell(new Phrase(free, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                stateTable.addCell(cell);
                rowI++;
            }
        }
        document.add(stateTable);
        document.add(new Paragraph("\n"));

        // 
        PdfPTable eventTable = new PdfPTable(2);
        float[] eventWidths = { 220f, 220f };
        eventTable.setWidths(eventWidths);
        eventTable.setWidthPercentage(100);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase((String) reportHash.get("downnum"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        cell = new PdfPCell(new Phrase(reportHash.get("count") + "", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        eventTable.addCell(cell);
        document.add(eventTable);

        document.add(new Paragraph("\n"));
        // 
        addEventLisToPdf(document);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_cabinetPdf(String filename, String room) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;//  w  w w  .  j a va  2 s  . c o m
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // new File(filename)
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        //         Paragraph title = new Paragraph(room + "", titleFont);
        // 
        //         title.setAlignment(Element.ALIGN_CENTER);
        //         // title.setFont(titleFont);
        //         document.add(title);
        List cabinetlist = (List) reportHash.get("cabinetlist");

        //         Paragraph context = new Paragraph();
        //         // 
        //         context.setAlignment(Element.ALIGN_LEFT);
        ////         context.setFont(contextFont);
        //         // 
        //         context.setSpacingBefore(5);
        //         // 
        //         context.setFirstLineIndent(6);
        //         document.add(context);
        //         document.add(new Paragraph("\n"));
        PdfPTable aTable = new PdfPTable(6);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase(room + "", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("U", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("U", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("U", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("U(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        Cabinet cabinet = null;
        if (cabinetlist != null && cabinetlist.size() > 0) {
            for (int i = 0; i < cabinetlist.size(); i++) {

                cabinet = (Cabinet) cabinetlist.get(i);
                cell = new PdfPCell(new Phrase(1 + i + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                String cc = cabinet.getName();
                cell = new PdfPCell(new Phrase(cabinet.getName(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(cabinet.getAllu(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(cabinet.getUseu(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(cabinet.getTempu(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(cabinet.getRateu(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

            }
        }
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_equipmentPdf(String filename, String roomname, String cabinetname, String uselect,
        String unumber, String rate) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;/*  ww w . j  ava2  s.com*/
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // new File(filename)
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        //         Paragraph title = new Paragraph(room + "", titleFont);
        // 
        //         title.setAlignment(Element.ALIGN_CENTER);
        //         // title.setFont(titleFont);
        //         document.add(title);
        List equipmentlist = (List) reportHash.get("equipmentlist");

        //         Paragraph context = new Paragraph();
        //         // 
        //         context.setAlignment(Element.ALIGN_LEFT);
        ////         context.setFont(contextFont);
        //         // 
        //         context.setSpacingBefore(5);
        //         // 
        //         context.setFirstLineIndent(6);
        //         document.add(context);
        //         document.add(new Paragraph("\n"));
        PdfPTable aTable = new PdfPTable(6);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase(roomname + cabinetname + "", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + roomname, titleFont));
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + cabinetname, titleFont));
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("U:" + uselect, titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + unumber, titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + rate, titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        EquipmentReport equipmentReport = null;
        if (equipmentlist != null && equipmentlist.size() > 0) {
            for (int i = 0; i < equipmentlist.size(); i++) {

                equipmentReport = (EquipmentReport) equipmentlist.get(i);
                cell = new PdfPCell(new Phrase(1 + i + "", contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(equipmentReport.getEquipmentname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

                cell = new PdfPCell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(equipmentReport.getOperation(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(equipmentReport.getContactname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(equipmentReport.getContactphone(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

            }
        }
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_OperEquipmentPdf(String filename, String opername, String contactname,
        String contactphone) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;//w  w  w  . j a v a2s . c o m
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        // new File(filename)
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        //         Paragraph title = new Paragraph(room + "", titleFont);
        // 
        //         title.setAlignment(Element.ALIGN_CENTER);
        //         // title.setFont(titleFont);
        //         document.add(title);
        List equipmentlist = (List) reportHash.get("equipmentlist");

        //         Paragraph context = new Paragraph();
        //         // 
        //         context.setAlignment(Element.ALIGN_LEFT);
        ////         context.setFont(contextFont);
        //         // 
        //         context.setSpacingBefore(5);
        //         // 
        //         context.setFirstLineIndent(6);
        //         document.add(context);
        //         document.add(new Paragraph("\n"));
        PdfPTable aTable = new PdfPTable(7);
        PdfPCell cell = null;
        cell = new PdfPCell(new Phrase(opername + "", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + opername, titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + contactname, titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase(":" + contactphone, titleFont));
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("U", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("IP", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new PdfPCell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        OperCabinet operCabinet = null;
        if (equipmentlist != null && equipmentlist.size() > 0) {
            for (int i = 0; i < equipmentlist.size(); i++) {

                operCabinet = (OperCabinet) equipmentlist.get(i);
                cell = new PdfPCell(new Phrase(operCabinet.getRoomname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(operCabinet.getCabinetname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

                cell = new PdfPCell(new Phrase(operCabinet.getUseu(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(operCabinet.getEquipmentname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(operCabinet.getIpaddress(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(operCabinet.getContactname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new PdfPCell(new Phrase(operCabinet.getContactphone(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

            }
        }
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.ainfosec.macresponse.report.RtfGenerator.java

License:Open Source License

private static void createDataSection(Paragraph paragraph, DisplayObject displayObject) {
    if (displayObject == null || displayObject.getObjects() == null) {
        return;//from  www  .j  av a2s.com
    }

    // See if the DisplayObject has a list or a single object
    if (displayObject.getObjects().size() == 1) {
        TreeObject treeObject = displayObject.getObjects().get(0); // There's only 1 item

        // For each column, create/add a label with the title and the data
        int i = 0;
        for (String columnName : displayObject.getColumnNames()) {
            StringBuffer sb = new StringBuffer();

            // Add the column title
            sb.append(displayObject.getColumnTitles()[i]);
            sb.append(": ");

            // Get the value of the field
            try {
                Field field = treeObject.getClass().getDeclaredField(columnName);
                String val = (String) field.get(treeObject);
                if (val == null) {
                    val = "";
                }
                // Add the value
                sb.append(val);
                sb.append("\n");
            } catch (NoSuchFieldException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // Put the string into the paragraph
            paragraph.add(sb.toString());
            i++;
        }
    } else {
        PdfPTable table = new PdfPTable(displayObject.getColumnTitles().length);
        table.setWidthPercentage(100);
        table.setHorizontalAlignment(Element.ALIGN_CENTER);

        for (String columnName : displayObject.getColumnTitles()) {
            table.getDefaultCell().setBackgroundColor(Color.CYAN);
            table.addCell(columnName);
            table.getDefaultCell().setBackgroundColor(Color.WHITE);
        }

        for (TreeObject to1 : displayObject.getObjects()) {
            for (String columnName : displayObject.getColumnNames()) {
                try {
                    Field field = to1.getClass().getDeclaredField(columnName);
                    String val = (String) field.get(to1);
                    if (val == null) {
                        val = "";
                    }
                    table.addCell(val);
                } catch (NoSuchFieldException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        table.getDefaultCell().setColspan(displayObject.getColumnTitles().length);
        table.getDefaultCell().setBorder(SWT.NONE);
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

        // TODO Paul number the tables
        table.addCell("Table: " + displayObject.getTitle());
        document.add(new RtfTable(document, table));
    }
}

From source file:com.allinfinance.system.util.PdfUtil.java

License:Open Source License

public static void create(String mchtId, String selMchtId, String path, List<Object[]> list,
        LinkedHashMap<String, List<Object[]>> map, Set<String> set) throws Exception {

    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);

    ///* w  w w .  jav a 2 s . c om*/
    Font font17 = new Font(bfChinese, 17, Font.BOLD);
    Font font8 = new Font(bfChinese, 8, Font.NORMAL);
    Font font9 = new Font(bfChinese, 9, Font.NORMAL);
    Font font9Bold = new Font(bfChinese, 9, Font.BOLD);
    Font font8Red = new Font(bfChinese, 8, Font.NORMAL);
    font8Red.setColor(Color.RED);
    Font font8Green = new Font(bfChinese, 8, Font.NORMAL);
    font8Green.setColor(Color.GREEN);

    logger.info("Starting build document...");

    Document document = new Document(PageSize.A4, 36, 36, 36, 36);
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();
    LINECANVAS border = new LINECANVAS();

    //
    float[] widths = { 0.1f, 0.35f, 0.35f, 0.1f, 0.1f };
    PdfPTable table = new PdfPTable(widths);
    table.setWidthPercentage(100);
    table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
    table.getDefaultCell().setFixedHeight(12);

    //CELL
    PdfPCell cellMchntId = new PdfPCell(new Paragraph(mchtId, font8));
    cellMchntId.setBorder(PdfPCell.BOTTOM);
    cellMchntId.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell cellMchntName = new PdfPCell(new Paragraph(InformationUtil.getMchtName(mchtId), font8));
    cellMchntName.setBorder(PdfPCell.BOTTOM);
    cellMchntName.setHorizontalAlignment(Element.ALIGN_CENTER);

    String point = InformationUtil.getCurPaperPoint(selMchtId);
    PdfPCell cellPoint;
    cellPoint = new PdfPCell(new Paragraph(point, font8Red));
    cellPoint.setBorder(PdfPCell.NO_BORDER);
    cellPoint.setHorizontalAlignment(Element.ALIGN_CENTER);

    PdfPCell cellLevel;
    String level = InformationUtil.getCurPaperLevel(selMchtId);
    if (Integer.valueOf(point) >= 60) {
        cellLevel = new PdfPCell(new Paragraph(level, font8Green));
    } else {
        cellLevel = new PdfPCell(new Paragraph(level, font8Red));
    }
    cellLevel.setBorder(PdfPCell.NO_BORDER);
    cellLevel.setHorizontalAlignment(Element.ALIGN_CENTER);

    //
    Image img = Image.getInstance(
            ServletActionContext.getServletContext().getResource("/ext/resources/images/Title_logo.gif"));
    img.scalePercent(70);
    float w = img.getScaledWidth();
    float h = img.getScaledHeight();
    writer.getDirectContent().addImage(img, w, 0, 0, h, 36, PageSize.A4.getHeight() - 36 - h);

    //
    PdfPCell cell = new PdfPCell(new Paragraph("?", font17));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setColspan(5);
    cell.setFixedHeight(h);
    cell.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell);

    cell = new PdfPCell();
    cell.setFixedHeight(20);
    cell.setColspan(5);
    cell.setBorder(PdfPCell.NO_BORDER);
    table.addCell(cell);

    table.addCell(new Paragraph("?", font8));
    table.addCell(cellMchntId);
    table.addCell(" ");
    table.addCell(new Paragraph(": ", font8));
    table.addCell(cellPoint);

    table.addCell(new Paragraph("??", font8));
    table.addCell(cellMchntName);
    table.addCell(" ");
    table.addCell(new Paragraph(": ", font8));
    table.addCell(cellLevel);

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

    //?
    PdfPTable t = new PdfPTable(1);

    Iterator<Object[]> it0 = list.iterator();
    int i = 1;
    while (it0.hasNext()) {
        Object[] obj = it0.next();
        PdfPCell c = new PdfPCell();
        c.addElement(new Paragraph("Q" + String.valueOf(i++) + "" + obj[1].toString(), font9Bold));
        List<Object[]> opts = map.get(obj[0].toString());
        String opt = "";
        Iterator<Object[]> it1 = opts.iterator();
        while (it1.hasNext()) {
            Object[] o = it1.next();
            if (set.contains(o[0])) {
                opt += "? ";
                opt += o[1].toString();
                opt += "         ";
            } else {
                opt += " ";
                opt += o[1].toString();
                opt += "         ";
            }
        }
        c.addElement(new Paragraph(opt.trim(), font9));
        c.setBorder(PdfPCell.NO_BORDER);
        if (i - 1 != list.size()) {
            c.setCellEvent(border);
        }
        t.addCell(c);
    }

    PdfPTable oTable = new PdfPTable(1);
    oTable.setWidthPercentage(100);
    PdfPCell ce = new PdfPCell(t);
    ce.setBorderColor(Color.GRAY);
    oTable.addCell(ce);

    document.add(oTable);

    document.close();

    logger.info("Finish build document...");

}