Example usage for com.lowagie.text Image LEFT

List of usage examples for com.lowagie.text Image LEFT

Introduction

In this page you can find the example usage for com.lowagie.text Image LEFT.

Prototype

int LEFT

To view the source code for com.lowagie.text Image LEFT.

Click Source Link

Document

this is a kind of image alignment.

Usage

From source file:ambit.data.qmrf.Qmrf_Xml_Pdf.java

License:Open Source License

public void headerTable(Document pdfdoc, org.w3c.dom.Document xmldoc) {
    try {//from  ww w . j a  va2s .  c o m
        int header_font_size = 10;
        Image png_left = Image
                .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png"));
        Image png_right = Image
                .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png"));
        png_left.setAlignment(Image.LEFT);
        png_right.setAlignment(Image.RIGHT);
        png_left.scalePercent(60);
        png_right.scalePercent(60);
        //png.scaleAbsolute(76, 67);
        //png.setAlignment(Image.MIDDLE);

        PdfPCell cell;

        float[] widths = { 1f, 5f, 1f };
        float[] widths1 = { 1f };
        PdfPTable table = new PdfPTable(widths);
        PdfPTable table1 = new PdfPTable(widths1);

        table.setWidthPercentage(100);

        cell = new PdfPCell();
        cell.setMinimumHeight(70);
        cell.addElement(new Chunk(png_left, +14, -40));
        table.addCell(cell);

        String Text = "";
        try {

            Text = findNodeValue(xml_QMRF_number, xmldoc);
            Chunk ident_title = new Chunk("QMRF identifier (JRC Inventory):");
            Chunk ident_text = new Chunk(Text);

            Font bi_font = new Font(baseFont, header_font_size, Font.BOLDITALIC);
            Font i_font = new Font(baseFont, header_font_size, Font.ITALIC);

            ident_title.setFont(bi_font);
            ident_text.setFont(i_font);
            Paragraph p = new Paragraph();
            p.add(ident_title);
            p.add(ident_text);
            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);

            ident_title = new Chunk("QMRF Title:");
            Phrase textPhrase = new Phrase();
            createNodePhrase("QSAR_title", xmldoc, textPhrase, i_font);
            ident_title.setFont(bi_font);

            p = new Paragraph();
            p.add(ident_title);
            p.add(textPhrase);
            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);

            java.util.Date now = new java.util.Date();
            java.text.DateFormat df = java.text.DateFormat.getDateInstance();
            String date = df.format(now);
            ident_title = new Chunk("Printing Date:");
            ident_text = new Chunk(date);
            ident_title.setFont(bi_font);
            ident_text.setFont(i_font);
            p = new Paragraph();
            p.add(ident_title);
            p.add(ident_text);

            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);

            p = new Paragraph("");
            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);
            cell = new PdfPCell(table1);
            cell.setPadding(0f);
            table.addCell(cell);

        } catch (Throwable x) {
            x.printStackTrace();

        }

        //table.addCell(new PdfPCell(png, true));
        cell.addElement(new Chunk(png_right, +14, -40));
        table.addCell(cell);
        pdfdoc.add(table);
        pdfdoc.add(new Paragraph(16));

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

From source file:ambit.io.PDFWriter.java

License:Open Source License

public void writeMolecule(IMolecule molecule) {
    Object value;//from w  w  w. ja va  2s  .c om

    try {

        //give it a chance to create a header just before the first write
        if (!writingStarted) {
            if (header == null)
                setHeader(molecule.getProperties());
            writeHeader();
            writingStarted = true;
        }

        Paragraph p = new Paragraph("");
        String s;
        for (int i = 0; i < header.size(); i++) {
            StringBuffer b = new StringBuffer();
            b.append(header.getList().get(i));
            b.append(" = ");
            value = molecule.getProperty(header.getList().get(i));
            if (i == smilesIndex) {

                if (value == null) //no SMILES available
                    try {
                        value = ""; //sg.createSMILES(molecule);
                    } catch (Exception x) {
                        logger.error("Error while createSMILES\t", x.getMessage());
                        value = "";
                    }
            }
            if (value != null) {
                if (value instanceof Number) {
                    s = value.toString();
                } else {
                    s = value.toString();

                }

                b.append(s);
                p.add(new Paragraph(b.toString()));
            }

        }
        BufferedImage image = imageTools.getImage(molecule);
        image.flush();

        Image png_struc = Image.getInstance(image, Color.white);
        png_struc.setAlignment(Image.LEFT);
        png_struc.scalePercent(100);

        PdfPCell cell = new PdfPCell();
        cell.setMinimumHeight(cell.height());
        cell.addElement(png_struc);
        table.addCell(cell);

        cell = new PdfPCell(p);
        cell.setBackgroundColor(Color.white);
        table.addCell(cell);

    } catch (Exception x) {
        logger.error("ERROR while writing Molecule: ", x.getMessage());
        logger.debug(x);
        x.printStackTrace();
    }

}

From source file:ambit2.core.io.PDFWriter.java

License:Open Source License

public void writeMolecule(IMolecule molecule) {
    Object value;/*ww w  . j  av a  2s  . co  m*/

    try {

        //give it a chance to create a header just before the first write
        if (!writingStarted) {
            if (header == null)
                setHeader(molecule.getProperties());
            writeHeader();
            writingStarted = true;
        }

        Paragraph p = new Paragraph("");
        String s;
        for (int i = 0; i < header.size(); i++) {
            StringBuffer b = new StringBuffer();
            b.append(header.get(i));
            b.append(" = ");
            value = molecule.getProperty(header.get(i));
            if (i == smilesIndex) {

                if (value == null) //no SMILES available
                    try {
                        value = ""; //sg.createSMILES(molecule);
                    } catch (Exception x) {
                        logger.log(Level.WARNING, "Error while createSMILES\t", x);
                        value = "";
                    }
            }
            if (value != null) {
                if (value instanceof Number) {
                    s = value.toString();
                } else {
                    s = value.toString();

                }

                b.append(s);
                p.add(new Paragraph(b.toString()));
            }

        }
        BufferedImage image = imageTools.getImage(molecule);
        image.flush();

        Image png_struc = Image.getInstance(image, Color.white);
        png_struc.setAlignment(Image.LEFT);
        png_struc.scalePercent(100);

        PdfPCell cell = new PdfPCell();
        cell.setMinimumHeight(cell.height());
        cell.addElement(png_struc);
        table.addCell(cell);

        cell = new PdfPCell(p);
        cell.setBackgroundColor(Color.white);
        table.addCell(cell);

    } catch (Exception x) {
        logger.log(Level.SEVERE, "Error while writing molecule", x);
    }

}

From source file:ambit2.data.qmrf.Qmrf_Xml_Pdf.java

License:Open Source License

public void headerTable(Document pdfdoc, org.w3c.dom.Document xmldoc) {
    try {//from   w  w  w.  j a  v  a2  s.  c  o m
        int header_font_size = 10;
        Image png_left = Image
                .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png"));
        Image png_right = Image
                .getInstance(Qmrf_Xml_Pdf.class.getClassLoader().getResource("ambit/data/qmrf/logo.png"));
        png_left.setAlignment(Image.LEFT);
        png_right.setAlignment(Image.RIGHT);
        png_left.scalePercent(60);
        png_right.scalePercent(60);
        //png.scaleAbsolute(76, 67);
        //png.setAlignment(Image.MIDDLE);

        PdfPCell cell;

        float[] widths = { 1f, 5f, 1f };
        float[] widths1 = { 1f };
        PdfPTable table = new PdfPTable(widths);
        PdfPTable table1 = new PdfPTable(widths1);

        table.setWidthPercentage(100);

        cell = new PdfPCell();
        cell.setMinimumHeight(70);
        cell.addElement(new Chunk(png_left, +14, -40));
        table.addCell(cell);

        String Text = "";
        try {

            Text = findNodeValue(xml_QMRF_number, xmldoc);
            Chunk ident_title = new Chunk("QMRF identifier (ECB Inventory):");
            Chunk ident_text = new Chunk(Text);

            Font bi_font = new Font(baseFont, header_font_size, Font.BOLDITALIC);
            Font i_font = new Font(baseFont, header_font_size, Font.ITALIC);

            ident_title.setFont(bi_font);
            ident_text.setFont(i_font);
            Paragraph p = new Paragraph();
            p.add(ident_title);
            p.add(ident_text);
            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);

            ident_title = new Chunk("QMRF Title:");
            Phrase textPhrase = new Phrase();
            createNodePhrase("QSAR_title", xmldoc, textPhrase, i_font);
            ident_title.setFont(bi_font);

            p = new Paragraph();
            p.add(ident_title);
            p.add(textPhrase);
            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);

            java.util.Date now = new java.util.Date();
            java.text.DateFormat df = java.text.DateFormat.getDateInstance();
            String date = df.format(now);
            ident_title = new Chunk("Printing Date:");
            ident_text = new Chunk(date);
            ident_title.setFont(bi_font);
            ident_text.setFont(i_font);
            p = new Paragraph();
            p.add(ident_title);
            p.add(ident_text);

            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);

            p = new Paragraph("");
            cell = new PdfPCell(p);
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            table1.addCell(cell);
            cell = new PdfPCell(table1);
            cell.setPadding(0f);
            table.addCell(cell);

        } catch (Throwable x) {
            x.printStackTrace();

        }

        //table.addCell(new PdfPCell(png, true));
        cell.addElement(new Chunk(png_right, +14, -40));
        table.addCell(cell);
        pdfdoc.add(table);
        pdfdoc.add(new Paragraph(16));

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

From source file:ambit2.db.reporters.PDFReporter.java

protected void writeMolecule(IAtomContainer molecule) {
    Object value;//w ww.j a v  a 2s  .  co  m

    try {

        Paragraph p = new Paragraph("");

        String s;

        for (Property property : header) {
            StringBuffer b = new StringBuffer();
            b.append(property.getLabel());
            b.append(" = ");
            value = molecule.getProperty(property);

            if (value != null) {
                if (value instanceof Number) {
                    s = value.toString();
                } else {
                    s = value.toString();
                }
                b.append(s);

                Chunk chunk = new Chunk(b.toString());
                chunk.setFont(font);
                p.add(new Paragraph(chunk));
            }

        }

        BufferedImage image = depict.getImage(molecule);
        image.flush();

        Image png_struc = Image.getInstance(image, Color.white);
        png_struc.setAlignment(Image.LEFT);
        png_struc.scalePercent(100);

        PdfPCell cell = new PdfPCell();
        cell.setMinimumHeight(cell.height());
        cell.addElement(png_struc);
        table.addCell(cell);

        cell = new PdfPCell(p);
        cell.setBackgroundColor(Color.white);
        table.addCell(cell);

    } catch (Exception x) {
        logger.log(java.util.logging.Level.FINE, x.getMessage(), x);
    }

}

From source file:ambit2.io.PDFWriter.java

License:Open Source License

public void writeMolecule(IMolecule molecule) {
    Object value;//from   ww w  . j a v a 2 s . c o m

    try {

        //give it a chance to create a header just before the first write
        if (!writingStarted) {
            if (header == null)
                setHeader(molecule.getProperties());
            writeHeader();
            writingStarted = true;
        }

        Paragraph p = new Paragraph("");
        String s;
        for (int i = 0; i < header.size(); i++) {
            StringBuffer b = new StringBuffer();
            b.append(header.get(i));
            b.append(" = ");
            value = molecule.getProperty(header.get(i));
            if (i == smilesIndex) {

                if (value == null) //no SMILES available
                    try {
                        value = ""; //sg.createSMILES(molecule);
                    } catch (Exception x) {
                        logger.error("Error while createSMILES\t", x.getMessage());
                        value = "";
                    }
            }
            if (value != null) {
                if (value instanceof Number) {
                    s = value.toString();
                } else {
                    s = value.toString();

                }

                b.append(s);
                p.add(new Paragraph(b.toString()));
            }

        }
        BufferedImage image = imageTools.getImage(molecule);
        image.flush();

        Image png_struc = Image.getInstance(image, Color.white);
        png_struc.setAlignment(Image.LEFT);
        png_struc.scalePercent(100);

        PdfPCell cell = new PdfPCell();
        cell.setMinimumHeight(cell.height());
        cell.addElement(png_struc);
        table.addCell(cell);

        cell = new PdfPCell(p);
        cell.setBackgroundColor(Color.white);
        table.addCell(cell);

    } catch (Exception x) {
        logger.error("ERROR while writing Molecule: ", x.getMessage());
        logger.debug(x);
        x.printStackTrace();
    }

}

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

public void createReport_networkDoc(String file) throws DocumentException, IOException {
    String runmodel = PollingEngine.getCollectwebflag();
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String Ping = (String) reportHash.get("Ping");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);/*from w  ww .j  a  v a2s  .co m*/
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();
    Vector netifVector = (Vector) reportHash.get("netifVector");
    Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash");
    List reportports = (List) reportHash.get("reportports");
    Vector iprouterVector = (Vector) reportHash.get("iprouterVector");

    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    Hashtable Disk = (Hashtable) reportHash.get("Disk");
    String hostname = (String) reportHash.get("equipname");
    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable maxping = (Hashtable) reportHash.get("ping");

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

    String[] netIfItemch = { "", "", "", "(M)", "", "", "" };
    String[] ipRouterItemch = { "", "", "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" };
    String[] diskItemch = { "", "", "", "i-node", "i-node" };
    String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" };
    String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)",
            "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)",
            "bgp(14)" };
    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);

    Paragraph title = new Paragraph(hostname + "", titleFont);
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    String contextString = ":" + impReport.getTimeStamp() + " \n"// 
            + ":" + sdf.format(cc);

    Paragraph context = new Paragraph(contextString, titleFont);
    // 
    context.setAlignment(Element.ALIGN_LEFT);
    // context.setFont(contextFont);
    // 
    context.setSpacingBefore(5);
    // 
    context.setFirstLineIndent(5);
    document.add(context);
    //  Table 
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    float[] widths = { 220f, 300f, 220f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 
    aTable.endHeaders();

    Cell cellt0 = new Cell("");
    cellt0.setBackgroundColor(Color.LIGHT_GRAY);
    cellt0.setHorizontalAlignment(Element.ALIGN_CENTER);
    cellt0.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cellt0.setRowspan(2);
    Cell cellt1 = new Cell("");
    cellt1.setBackgroundColor(Color.LIGHT_GRAY);
    Cell cellt2 = new Cell("");
    cellt2.setBackgroundColor(Color.LIGHT_GRAY);
    Cell cellt3 = new Cell("");
    cellt3.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cellt0);
    aTable.addCell(cellt1);
    aTable.addCell(cellt2);
    aTable.addCell(cellt3);

    // aTable.addCell("3.2",Ping+"%");
    // Cell cellt4 = new Cell("");
    // cellt4.setBackgroundColor(Color.LIGHT_GRAY);
    // aTable.addCell(cellt4);
    aTable.addCell(Ping + "%");
    aTable.addCell((String) maxping.get("pingmax"));
    aTable.addCell((String) maxping.get("avgpingcon"));
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "ConnectUtilization" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.LEFT);// 
    document.add(aTable);
    document.add(img);
    // document.add(new Paragraph("\n"));
    // document.close();
    Table aTable1 = new Table(4);
    float[] width = { 220f, 300f, 220f, 220f };
    aTable1.setWidths(width);
    aTable1.setWidth(100); //  90%
    aTable1.setAlignment(Element.ALIGN_CENTER);// 
    aTable1.setAutoFillEmptyCells(true); // 
    aTable1.setBorderWidth(1); // 
    aTable1.setBorderColor(new Color(0, 125, 255)); // 
    aTable1.setPadding(2);// 
    aTable1.setSpacing(0);// 
    aTable1.setBorder(2);// 
    aTable1.endHeaders();

    cellt0 = new Cell("CPU");
    cellt0.setBackgroundColor(Color.LIGHT_GRAY);
    cellt0.setHorizontalAlignment(Element.ALIGN_CENTER);
    cellt0.setVerticalAlignment(Element.ALIGN_MIDDLE);

    cellt1 = new Cell("");
    cellt1.setBackgroundColor(Color.LIGHT_GRAY);
    cellt2 = new Cell("");
    cellt2.setBackgroundColor(Color.LIGHT_GRAY);
    cellt3 = new Cell("");
    cellt3.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cellt0);
    aTable1.addCell(cellt1);
    aTable1.addCell(cellt2);
    aTable1.addCell(cellt3);
    // aTable.addCell("3.2",Ping+"%");
    aTable1.addCell("");

    aTable1.addCell((String) CPU.get("cpu") + "%");
    aTable1.addCell((String) CPU.get("cpumax"));
    aTable1.addCell((String) CPU.get("avgcpu"));
    cellt0.setRowspan(2);
    Image img1 = Image.getInstance(
            ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.MIDDLE);// 
    document.add(aTable1);
    document.add(img1);

    if (netifVector != null && netifVector.size() > 0) {
        Table aTable2 = new Table(8);
        float[] width2 = { 300f, 220f, 220f, 180f, 300f, 180f, 220f, 220f };
        aTable2.setWidths(width2);
        aTable2.setWidth(100); //  100%
        aTable2.setAlignment(Element.ALIGN_CENTER);// 
        aTable2.setAutoFillEmptyCells(true); // 
        aTable2.setBorderWidth(1); // 
        aTable2.setBorderColor(new Color(0, 125, 255)); // 
        aTable2.setPadding(2);// 
        aTable2.setSpacing(0);// 
        aTable2.setBorder(2);// 
        aTable2.endHeaders();
        Cell c = new Cell("");
        c.setBackgroundColor(Color.LIGHT_GRAY);
        c.setRowspan(netifVector.size() + 1);
        c.setHorizontalAlignment(Element.ALIGN_CENTER);
        c.setVerticalAlignment(Element.ALIGN_MIDDLE);
        aTable2.addCell(c);
        // 
        // allRow = allRow;
        for (int i = 0; i < netIfItemch.length; i++) {
            Cell cell = new Cell(netIfItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable2.addCell(cell);
        }
        Color color = new Color(204, 204, 255);
        // 
        for (int i = 0; i < netifVector.size(); i++) {
            // aTable2.addCell("");
            String[] strs = (String[]) netifVector.get(i);
            String ifname = strs[1];
            String index = strs[0];
            for (int j = 0; j < strs.length; j++) {
                if (j == 1) {
                    String linkuse = "";
                    if (portconfigHash != null && portconfigHash.size() > 0) {
                        if (portconfigHash.get(ip + ":" + index) != null)
                            linkuse = (String) portconfigHash.get(ip + ":" + index);
                    }
                    Cell cell1 = new Cell(strs[j]);
                    Cell cell2 = new Cell(linkuse);
                    if (i % 2 != 0) {
                        cell1.setBackgroundColor(color);
                        cell2.setBackgroundColor(color);
                    }
                    aTable2.addCell(cell1);
                    aTable2.addCell(cell2);
                } else if (j > 1) {
                    Cell cell3 = new Cell(strs[j]);
                    if (i % 2 != 0) {
                        cell3.setBackgroundColor(color);
                    }
                    aTable2.addCell(cell3);
                } else {
                    Cell cell4 = new Cell(strs[j]);
                    if (i % 2 != 0) {
                        cell4.setBackgroundColor(color);
                    }
                    aTable2.addCell(cell4);
                }
            } // end 
        }
        document.add(aTable2);
    }
    if ("0".equals(runmodel)) {
        // 
        if (iprouterVector != null && iprouterVector.size() > 0) {
            Table aTable3 = new Table(7);
            float[] width2 = { 240f, 200f, 300f, 300f, 220f, 180f, 300f };
            aTable3.setWidths(width2);
            aTable3.setWidth(100); //  100%
            aTable3.setAlignment(Element.ALIGN_CENTER);// 
            aTable3.setAutoFillEmptyCells(true); // 
            aTable3.setBorderWidth(1); // 
            aTable3.setBorderColor(new Color(0, 125, 255)); // 
            aTable3.setPadding(2);// 
            aTable3.setSpacing(0);// 
            aTable3.setBorder(2);// 
            aTable3.endHeaders();
            aTable3.addCell("");
            // 
            // allRow = allRow+1;
            for (int i = 0; i < ipRouterItemch.length; i++) {
                Cell cell = new Cell(ipRouterItemch[i]);
                aTable3.addCell(cell);

            }

            // 

            for (int i = 0; i < iprouterVector.size(); i++) {
                aTable3.addCell("");
                /* allRow = allRow + 1; */

                IpRouter iprouter = (IpRouter) iprouterVector.get(i);
                Cell cell = new Cell(iprouter.getIfindex());
                aTable3.addCell(cell);
                Cell cell1 = new Cell(iprouter.getDest());
                aTable3.addCell(cell1);
                Cell cell2 = new Cell(iprouter.getNexthop());
                aTable3.addCell(cell2);
                Cell cell3 = new Cell(iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")]);
                aTable3.addCell(cell3);
                Cell cell4 = new Cell(iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")]);
                aTable3.addCell(cell4);
                Cell cell5 = new Cell(iprouter.getMask());
                aTable3.addCell(cell5);
            }
            document.add(aTable3);
        }
    } else {
        // 
        List routerList = (ArrayList) reportHash.get("routerList");
        Table aTable3 = new Table(7);
        float[] width2 = { 240f, 200f, 300f, 300f, 220f, 180f, 300f };
        aTable3.setWidths(width2);
        aTable3.setWidth(100); //  100%
        aTable3.setAlignment(Element.ALIGN_CENTER);// 
        aTable3.setAutoFillEmptyCells(true); // 
        aTable3.setBorderWidth(1); // 
        aTable3.setBorderColor(new Color(0, 125, 255)); // 
        aTable3.setPadding(2);// 
        aTable3.setSpacing(0);// 
        aTable3.setBorder(2);// 
        aTable3.endHeaders();
        aTable3.addCell("");
        // 
        // allRow = allRow+1;
        for (int i = 0; i < ipRouterItemch.length; i++) {
            Cell cell = new Cell(ipRouterItemch[i]);
            aTable3.addCell(cell);

        }
        if (routerList != null) {
            for (int i = 0; i < routerList.size(); i++) {
                aTable3.addCell("");
                RouterNodeTemp iprouter = (RouterNodeTemp) routerList.get(i);
                Cell cell = new Cell(iprouter.getIfindex());
                aTable3.addCell(cell);
                Cell cell1 = new Cell(iprouter.getDest());
                aTable3.addCell(cell1);
                Cell cell2 = new Cell(iprouter.getNexthop());
                aTable3.addCell(cell2);
                Cell cell3 = new Cell(iprouter.getType());
                aTable3.addCell(cell3);
                Cell cell4 = new Cell(iprouter.getProto());
                aTable3.addCell(cell4);
                Cell cell5 = new Cell(iprouter.getMask());
                aTable3.addCell(cell5);
            }
            document.add(aTable3);
        }
    }
    // doc

    if (reportports != null && reportports.size() > 0) {
        // 

        // aTable4.addCell("");
        for (int i = 0; i < reportports.size(); i++) {
            Table aTable4 = new Table(2);
            float[] width2 = { 300f, 300f };
            aTable4.setWidths(width2);
            aTable4.setWidth(100); //  100%
            aTable4.setAlignment(Element.ALIGN_CENTER);// 
            aTable4.setAutoFillEmptyCells(true); // 
            aTable4.setBorderWidth(1); // 
            aTable4.setBorderColor(new Color(0, 125, 255)); // 
            aTable4.setPadding(2);// 
            aTable4.setSpacing(0);// 
            aTable4.setBorder(2);// 
            aTable4.endHeaders();
            // SysLogger.info(reportports.get(i).getClass()+"=============================================");
            com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports
                    .get(i);
            /*
             * tmpLabel = new Label(0, allRow, "" +
             * portconfig.getPortindex() + "(" + portconfig.getName() +
             * ")", b_labelFormat);
             * 
             * sheet.addCell(tmpLabel);
             */
            Cell cell = new Cell("" + portconfig.getPortindex() + "(" + portconfig.getName() + ")");
            aTable4.addCell(cell);
            if (portconfig.getLinkuse() == null)
                portconfig.setLinkuse("");
            Cell cell1 = new Cell(":" + portconfig.getLinkuse());
            aTable4.addCell(cell1);
            document.add(aTable4);
            // 
            Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath()
                    + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png");
            img2.setAbsolutePosition(0, 0);
            img2.setAlignment(Image.LEFT);// 
            // sheet,0,0,5,1,,,
            img2.scalePercent(67);
            document.add(img2);
        }
    } // 
    if (impReport.getChart() != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                    impReport.getChart().getWidth(), impReport.getChart().getHeight());
        } catch (IOException ioe) {
        }
        /*
         * WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos
         * .toByteArray());
         */
        Image img2 = Image.getInstance(baos.toByteArray());
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.LEFT);// 
        img.scalePercent(67);
        document.add(img2);
    }

    document.close();
}

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

public void createReport_hostDoc(String file) throws DocumentException, IOException {
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");

    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);//from  w  ww  .  j  a va2 s  .  c  o m
    // WritableSheet sheet = wb.createSheet(hostname + "", 0);
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    if (CPU == null)
        CPU = new Hashtable();
    String Ping = (String) reportHash.get("Ping");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    Hashtable Disk = (Hashtable) reportHash.get("Disk");

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable maxping = (Hashtable) reportHash.get("ping");

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

    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    String[] diskItem = { "AllSize", "UsedSize", "Utilization" };
    String[] diskItemch = { "", "", "" };
    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    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, titleFont);
    // 
    context.setAlignment(Element.ALIGN_LEFT);
    // context.setFont(contextFont);
    // 
    context.setSpacingBefore(5);
    // 
    context.setFirstLineIndent(5);
    document.add(context);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    float[] widths = { 220f, 300f, 220f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 
    aTable.endHeaders();
    Cell cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    aTable.addCell(Ping + "%");
    aTable.addCell((String) maxping.get("pingmax"));
    aTable.addCell((String) maxping.get("avgpingcon"));
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "ConnectUtilization" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.LEFT);// 
    document.add(aTable);
    document.add(img);

    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    Table aTable1 = new Table(4);
    float[] width = { 220f, 300f, 220f, 220f };
    aTable1.setWidths(width);
    aTable1.setWidth(100); //  90%
    aTable1.setAlignment(Element.ALIGN_CENTER);// 
    aTable1.setAutoFillEmptyCells(true); // 
    aTable1.setBorderWidth(1); // 
    aTable1.setBorderColor(new Color(0, 125, 255)); // 
    aTable1.setPadding(2);// 
    aTable1.setSpacing(0);// 
    aTable1.setBorder(2);// 
    aTable1.endHeaders();

    cell = new Cell();
    cell.addElement(new Paragraph("CPU", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);

    aTable1.addCell(cpu + "%");
    aTable1.addCell(cpumax);
    aTable1.addCell(avgcpu);

    Image img1 = Image.getInstance(
            ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.MIDDLE);// 
    document.add(aTable1);
    document.add(img1);

    if (Memory != null && Memory.size() > 0) {
        Table aTable2 = new Table(6);
        float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        aTable2.setWidth(100); //  90%
        aTable2.setAlignment(Element.ALIGN_CENTER);// 
        aTable2.setAutoFillEmptyCells(true); // 
        aTable2.setBorderWidth(1); // 
        aTable2.setBorderColor(new Color(0, 125, 255)); // 
        aTable2.setPadding(2);// 
        aTable2.setSpacing(0);// 
        aTable2.setBorder(2);// 
        aTable2.endHeaders();
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        // 

        for (int i = 0; i < memoryItemch.length; i++) {
            cell = new Cell(memoryItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            // cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            aTable2.addCell(cell);
        }
        // 
        for (int i = 0; i < Memory.size(); i++) {
            aTable2.addCell("");
            Hashtable mhash = (Hashtable) (Memory.get(new Integer(i)));
            String name = (String) mhash.get("name");
            Cell cell1 = new Cell(name);
            aTable2.addCell(cell1);
            for (int j = 0; j < memoryItem.length; j++) {
                String value = "";
                if (mhash.get(memoryItem[j]) != null) {
                    value = (String) mhash.get(memoryItem[j]);
                }
                Cell cell2 = new Cell(value);
                aTable2.addCell(cell2);
            }
            String value = "";
            if (memMaxHash.get(name) != null) {
                value = (String) memMaxHash.get(name);
                Cell cell3 = new Cell(value);
                aTable2.addCell(cell3);
            }
            String avgvalue = "";
            if (memAvgHash.get(name) != null) {
                avgvalue = (String) memAvgHash.get(name);
                aTable2.addCell(avgvalue);
            }

        } // end 
          // 
        Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "memory" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 
        document.add(aTable2);
        document.add(img2);
    } else {
        Table aTable2 = new Table(6);
        float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        aTable2.setWidth(100); //  90%
        aTable2.setAlignment(Element.ALIGN_CENTER);// 
        aTable2.setAutoFillEmptyCells(true); // 
        aTable2.setBorderWidth(1); // 
        aTable2.setBorderColor(new Color(0, 125, 255)); // 
        aTable2.setPadding(2);// 
        aTable2.setSpacing(0);// 
        aTable2.setBorder(2);// 
        aTable2.endHeaders();
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        // 

        for (int i = 0; i < memoryItemch.length; i++) {
            cell = new Cell(memoryItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable2.addCell(cell);
        }
        // 
        String[] names = null;
        HostNodeDao dao = new HostNodeDao();
        HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0);
        // Monitoriplist monitor = monitorManager.getByIpaddress(ip);
        if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) {
            names = new String[] { "PhysicalMemory", "VirtualMemory" };
        } else {
            names = new String[] { "PhysicalMemory", "SwapMemory" };
        }
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            aTable2.addCell("");
            cell = new Cell(names[i]);
            aTable2.addCell(cell);

            for (int j = 0; j < memoryItem.length; j++) {
                // 
                String value = "";
                Cell cell1 = new Cell(value);
                aTable2.addCell(cell1);
            }
            String value = "";
            if (memMaxHash.get(name) != null) {
                value = (String) memMaxHash.get(name);
                Cell cell2 = new Cell(value);
                aTable2.addCell(cell2);
            } else {
                Cell cell3 = new Cell(value);
                aTable2.addCell(cell3);
            }
            String avgvalue = "";
            if (memAvgHash.get(name) != null) {
                avgvalue = (String) memAvgHash.get(name);
                Cell cell4 = new Cell(avgvalue);
                aTable2.addCell(cell4);
            } else {
                Cell cell5 = new Cell(avgvalue);
                aTable2.addCell(cell5);
            }

        } // end 
          // 
        Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "memory" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 
        document.add(aTable2);
        document.add(img2);

    }
    Table aTable3 = new Table(5);
    float[] widthss1 = { 220f, 440f, 150f, 150f, 220f };
    aTable3.setWidths(widthss1);
    aTable3.setWidth(100); //  90%
    aTable3.setAlignment(Element.ALIGN_CENTER);// 
    aTable3.setAutoFillEmptyCells(true); // 
    aTable3.setBorderWidth(1); // 
    aTable3.setBorderColor(new Color(0, 125, 255)); // 
    aTable3.setPadding(2);// 
    aTable3.setSpacing(0);// 
    aTable3.setBorder(2);// 
    aTable3.endHeaders();
    if (Disk != null && Disk.size() > 0) {
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable3.addCell(cell);
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable3.addCell(cell);

        for (int i = 0; i < diskItemch.length; i++) {
            cell = new Cell(diskItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable3.addCell(cell);
        }
        // 

        for (int i = 0; i < Disk.size(); i++) {
            aTable3.addCell("");
            Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i)));
            String name = (String) diskhash.get("name");
            cell = new Cell(name);
            aTable3.addCell(cell);
            for (int j = 0; j < diskItem.length; j++) {
                String value = "";
                if (diskhash.get(diskItem[j]) != null) {
                    value = (String) diskhash.get(diskItem[j]);
                }
                Cell cell1 = new Cell(value);
                // System.out.println(value+"================value===============");
                aTable3.addCell(cell1);
            }
        } // end 
          // 
        Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "disk" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 
        document.add(aTable3);
        document.add(img3);

    }
    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 img3 = Image.getInstance(baos.toByteArray());
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 

        document.add(img3);
    }
    document.close();
}

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

public void createReport_pingDoc(String file) throws DocumentException, IOException {
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");

    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);/*  ww w  .  ja  v  a  2 s .  c  o m*/
    // WritableSheet sheet = wb.createSheet(hostname + "", 0);
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    if (CPU == null)
        CPU = new Hashtable();
    String Ping = (String) reportHash.get("Ping");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    Hashtable Disk = (Hashtable) reportHash.get("Disk");

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable maxping = (Hashtable) reportHash.get("ping");

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

    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    String[] diskItem = { "AllSize", "UsedSize", "Utilization" };
    String[] diskItemch = { "", "", "" };
    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    Paragraph title = new Paragraph(hostname + "");
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    String contextString = ":" + impReport.getTimeStamp() + " \n"// 
            + ":" + starttime + "  " + totime;
    Paragraph context = new Paragraph(contextString);
    // 
    context.setAlignment(Element.ALIGN_LEFT);
    // context.setFont(contextFont);
    // 
    context.setSpacingBefore(5);
    // 
    context.setFirstLineIndent(5);
    document.add(context);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    float[] widths = { 220f, 300f, 220f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 
    aTable.endHeaders();

    aTable.addCell("");
    aTable.addCell("");
    aTable.addCell("");
    aTable.addCell("");
    // aTable.addCell("3.2",Ping+"%");
    aTable.addCell("");
    aTable.addCell(Ping + "%");
    aTable.addCell((String) maxping.get("pingmax"));
    aTable.addCell((String) maxping.get("avgpingcon"));
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "ConnectUtilization" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.LEFT);// 
    document.add(aTable);
    document.add(img);
    document.close();
}

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

public void createReport_ServicePingDoc(String file) throws DocumentException, IOException {
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");

    String servicename = (String) reportHash.get("servicename");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);/*from w w  w  . j a v  a2 s . c  o  m*/

    String Ping = (String) reportHash.get("Ping");
    Hashtable ping = (Hashtable) reportHash.get("ping");

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

    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    Paragraph title = new Paragraph(servicename + "");
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    String contextString = ":" + impReport.getTimeStamp() + " \n"// 
            + ":" + starttime + "  " + totime;
    Paragraph context = new Paragraph(contextString);
    // 
    context.setAlignment(Element.ALIGN_LEFT);
    // context.setFont(contextFont);
    // 
    context.setSpacingBefore(5);
    // 
    context.setFirstLineIndent(5);
    document.add(context);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    float[] widths = { 220f, 300f, 220f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 
    aTable.endHeaders();

    aTable.addCell("");
    aTable.addCell("");
    aTable.addCell("");
    aTable.addCell("");
    aTable.addCell("");
    aTable.addCell(Ping + "%");
    aTable.addCell((String) ping.get("minPing") + "%");
    aTable.addCell((String) ping.get("avgPing") + "%");
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "pingConnect" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.LEFT);// 
    document.add(aTable);
    document.add(img);
    document.close();
}