Example usage for com.lowagie.text Paragraph setSpacingBefore

List of usage examples for com.lowagie.text Paragraph setSpacingBefore

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph setSpacingBefore.

Prototype

public void setSpacingBefore(float spacing) 

Source Link

Document

Sets the spacing before this paragraph.

Usage

From source file:appli_etudiants.ExportPDF.java

public static void main(Etudiants etudiant)
        throws SQLException, FileNotFoundException, BadElementException, IOException {
    try {//from  w ww. j  a  va 2 s .  c  o m
        Document document = new Document(PageSize.A4);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/tesPDF.pdf"));
        document.open();
        PdfContentByte canvas = writer.getDirectContentUnder();
        Image image = Image.getInstance("c:/fond_cv.jpg");
        image.setAbsolutePosition(0, 80);
        canvas.saveState();
        PdfGState state = new PdfGState();
        state.setFillOpacity(0.6f);
        canvas.setGState(state);
        canvas.addImage(image);
        canvas.restoreState();

        LineSeparator lineSepa = new LineSeparator();
        lineSepa.setLineColor(new Color(21, 96, 189));
        Paragraph para1 = new Paragraph();
        Paragraph para2 = new Paragraph(etudiant.getAdresse_rue());
        Paragraph para3 = new Paragraph(etudiant.getAdresse_cp() + " " + etudiant.getAdresse_ville());
        Paragraph para4 = new Paragraph(etudiant.getCourriel(),
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189)));
        Paragraph para5 = new Paragraph(etudiant.getTel_personnel());
        Paragraph para6 = new Paragraph(etudiant.getTel_professionnel());
        Paragraph para7 = new Paragraph(etudiant.getSite_web());
        para1.add(new Chunk(etudiant.getPrenom(),
                FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD, new Color(21, 96, 189))));
        para1.add(
                new Chunk(" " + etudiant.getNom(), FontFactory.getFont(FontFactory.HELVETICA, 20, Font.BOLD)));

        Image image1 = Image.getInstance(DaoS4.getPhoto());
        image1.scalePercent(50);
        image1.setAlignment(Image.RIGHT | Image.TEXTWRAP);
        image1.scaleAbsolute(94, 94);
        document.add(image1);

        document.add(para1);
        document.add(para2);
        document.add(para3);
        document.add(para4);
        document.add(para5);
        document.add(para6);
        para7.setSpacingAfter(25f);
        document.add(para7);
        Paragraph para8 = new Paragraph(DaoS4.getLibelleTitre());
        para8.setSpacingBefore(25f);
        para8.setSpacingAfter(20f);
        document.add(para8);

        Paragraph para9 = new Paragraph(new Chunk("EXPERIENCE PROFESSIONELLE",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para9.setSpacingBefore(15f);
        para9.setSpacingAfter(15f);
        document.add(para9);
        document.add(lineSepa);
        Paragraph para10 = new Paragraph(DaoS4.getLibelleExpPro());
        para10.setSpacingAfter(15f);
        document.add(para10);

        Paragraph para11 = new Paragraph(new Chunk("FORMATION",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para11.setSpacingBefore(15f);
        para11.setSpacingAfter(15f);
        document.add(para11);
        document.add(lineSepa);
        Paragraph para12 = new Paragraph(DaoS4.getLibelleFormation());
        para12.setSpacingAfter(15f);
        document.add(para12);

        Paragraph para13 = new Paragraph(new Chunk("INFORMATIQUE",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para13.setSpacingBefore(15f);
        para13.setSpacingAfter(15f);
        document.add(para13);
        document.add(lineSepa);
        Paragraph para14 = new Paragraph(DaoS4.getLibelleInformatique());
        para14.setSpacingAfter(15f);
        document.add(para14);

        Paragraph para15 = new Paragraph(new Chunk("LANGUE",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para15.setSpacingBefore(15f);
        para15.setSpacingAfter(15f);
        document.add(para15);
        document.add(lineSepa);
        Paragraph para16 = new Paragraph(DaoS4.getLibelleLangue());
        para16.setSpacingAfter(15f);
        document.add(para16);

        Paragraph para17 = new Paragraph(new Chunk("CENTRES D'INTERET",
                FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(21, 96, 189))));
        para17.setSpacingBefore(15f);
        para17.setSpacingAfter(15f);
        document.add(para17);
        document.add(lineSepa);
        Paragraph para18 = new Paragraph(DaoS4.getLibelleInteret());
        para18.setSpacingAfter(15f);
        document.add(para18);

        document.close();
    } catch (DocumentException ex) {
        Logger.getLogger(ExportPDF.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:be.fedict.eid.tsl.Tsl2PdfExporter.java

License:Open Source License

protected void addTitle(final String titleText, final Font titleFont, final int align,
        final float spacingBefore, final float spacingAfter, final Document doc) throws DocumentException {
    final Paragraph titlePara = new Paragraph(titleText, titleFont);
    titlePara.setAlignment(align);//  w  w w .j av a  2s . c  o  m
    titlePara.setSpacingBefore(spacingBefore);
    titlePara.setSpacingAfter(spacingAfter);
    doc.add(titlePara);
}

From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java

License:Open Source License

public static void createLaborwertTable(Patient patient, String filename, LinkedList<String[]> laborBlatt,
        String footerText) throws IOException, DocumentException {

    // step 1//  w ww.j a  v  a 2  s.c  om
    Document document = new Document(PageSize.A4);

    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
    // step 3
    writer.setBoxSize("art", rect);

    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    event.setHeaderText(
            patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")");
    event.setFooterText(footerText);
    writer.setPageEvent(event);

    document.setMargins(56, 72, 60, 60);

    // step 3
    document.open();

    if (laborBlatt.size() == 0) {
        Paragraph p = new Paragraph(new Chunk("Keine Laborwerte vorhanden", fontTimesTitle));
        p.setSpacingBefore(20f);
        document.add(p);
    } else {

        document.add(createTable2(laborBlatt));
    }

    // step 5
    document.close();

}

From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java

License:Open Source License

public static void createDiagnosenSheet(Patient patient, String filename, String footerText)
        throws DocumentException, IOException {

    StringBuffer sb = new StringBuffer("Diagnosen:\n");
    sb.append(patient.getDiagnosen());//  ww  w.  j a v  a 2  s.  c om
    sb.append("\n");
    sb.append("Persnliche Anamnese:\n");
    sb.append(patient.getPersAnamnese());
    sb.append("\n");

    // step 1
    Document document = new Document(PageSize.A4);

    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
    // step 3
    //Rectangle rect = new Rectangle(30, 30, 559, 800);
    writer.setBoxSize("art", rect);

    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    event.setHeaderText(
            patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")");
    event.setFooterText(footerText);
    writer.setPageEvent(event);

    document.setMargins(36, 72, 60, 60);

    // step 3
    document.open();

    document.add(new Chunk("")); // << this will do the trick. 

    if (patient.getDiagnosen().length() > 0) {
        Paragraph p = new Paragraph("Diagnosen:", fontTimesTitle);
        p.setSpacingAfter(10f);
        document.add(p);

        String[] chunksDiag = patient.getDiagnosen().toString().split("(?m)^\\s*$");
        for (String chunk : chunksDiag) {
            document.add(new Paragraph(chunk, fontTimes));
        }
    } else {
        document.add(new Paragraph("Keine Diagnosen vorhanden", fontTimes));

    }

    if (patient.getPersAnamnese().length() > 0) {
        Paragraph p = new Paragraph("Persnliche Anamnese:", fontTimesTitle);
        p.setSpacingBefore(10f);
        p.setSpacingAfter(10f);

        document.add(p);

        String[] chunksAnam = patient.getPersAnamnese().toString().split("(?m)^\\s*$");
        for (String chunk : chunksAnam) {
            document.add(new Paragraph(chunk, fontTimes));
        }
    } else {
        document.add(new Paragraph("Keine Persnliche Anamnese vorhanden", fontTimes));

    }

    // step 5
    document.close();

}

From source file:ch.gpb.elexis.kgexporter.pdf.PdfHandler.java

License:Open Source License

public static void createFixMediSheet(Patient patient, String filename, String footerText)
        throws DocumentException, IOException {
    Prescription[] prescriptions = patient.getFixmedikation();
    StringBuffer sb = new StringBuffer();
    for (Prescription prescription : prescriptions) {
        //System.out.println("Prescription: " + prescription.getLabel() + "/" + prescription.getDosis());
        sb.append(prescription.getLabel());
        sb.append("\r\n");
    }//from w  w  w . ja  va  2s  .c o m

    // step 1
    Document document = new Document(PageSize.A4);

    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(filename));
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
    // step 3
    //Rectangle rect = new Rectangle(30, 30, 559, 800);
    writer.setBoxSize("art", rect);

    HeaderFooterPageEvent event = new HeaderFooterPageEvent();
    event.setHeaderText(
            patient.getVorname() + " " + patient.getName() + " (" + patient.getGeburtsdatum() + ")");
    event.setFooterText(footerText);
    writer.setPageEvent(event);

    document.setMargins(36, 72, 60, 60);

    // step 3
    document.open();

    document.add(new Chunk("")); // << this will do the trick. 

    if (sb.length() > 0) {
        Paragraph p = new Paragraph("Fixmedikation:", fontTimesTitle);
        p.setSpacingAfter(10f);
        document.add(p);

        String[] chunksDiag = sb.toString().split("(?m)^\\s*$");
        for (String chunk : chunksDiag) {
            document.add(new Paragraph(chunk, fontTimes));
        }
    } else {

        //document.add(new Paragraph("Keine Medikationen vorhanden", fontTimes));
        Paragraph p = new Paragraph(new Chunk("Keine Medikationen vorhanden", fontTimesTitle));
        p.setSpacingBefore(20f);
        document.add(p);

    }

    // step 5
    document.close();

}

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

public void createWordReport_hardware(String filename) {
    try {//from   w ww  .  ja va  2  s. c om
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        Document document = new Document(PageSize.A4);
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        fileName = filename;
        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("");
        title.setAlignment(Element.ALIGN_CENTER);
        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);

        Table aTable = new Table(4);
        float[] widths = { 100f, 100f, 300f, 100f };
        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("");
        Vector deviceV = (Vector) reportHash.get("deviceV");
        for (int m = 0; m < deviceV.size(); m++) {
            Devicecollectdata devicedata = (Devicecollectdata) deviceV.get(m);
            String name = devicedata.getName();
            String type = devicedata.getType();
            String status = devicedata.getStatus();
            aTable.addCell(m + 1 + "");
            aTable.addCell(type);
            aTable.addCell(name);
            aTable.addCell(status);
        }
        document.add(aTable);
        document.close();
        // System.out.println("abcdefg");
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

/**
 * @author sunqichang///from   ww  w .  j a v  a2  s.co m
 * @param filename
 *            
 * @param type
 *            pdfdoc
 */
public void createReport_hardwareNew(String filename, String type) {
    try {
        int diskcount = Integer.parseInt(request.getParameter("diskcount"));
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        List networkList = (List) reportHash.get("networkList");
        List serverList = (List) reportHash.get("serverList");
        List dbList = (List) reportHash.get("dbList");
        List midwareList = (List) reportHash.get("midwareList");
        Document document = new Document(PageSize.A4);
        if ("doc".equalsIgnoreCase(type)) {
            RtfWriter2.getInstance(document, new FileOutputStream(filename));
        } else {
            PdfWriter.getInstance(document, new FileOutputStream(filename));
        }
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        Font fontChineseTitle = new Font(bfChinese, 14, Font.BOLD);
        Font fontChineseRow = new Font(bfChinese, 12, Font.NORMAL);
        fileName = filename;
        document.open();
        Paragraph title = new Paragraph("", fontChineseTitle);
        title.setAlignment(Element.ALIGN_CENTER);
        document.add(title);
        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;
        Paragraph context = new Paragraph(contextString, fontChineseTitle);
        context.setAlignment(Element.ALIGN_CENTER);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        Iterator networkIt = null;
        if (networkList != null) {
            networkIt = networkList.iterator();
        }
        Iterator serverIt = null;
        if (serverList != null) {
            serverIt = serverList.iterator();
        }
        Iterator dbIt = null;
        if (dbList != null) {
            dbIt = dbList.iterator();
        }
        Iterator midwareIt = null;
        if (midwareList != null) {
            midwareIt = midwareList.iterator();
        }
        String[] networkTitle = { "", "", "", "", "IP", "" };
        String[] serverTitle = { "", "", "", "", "IP", "", "" };
        String[] dbTitle = { "", "", "", "IP" };
        String[] midwareTitle = { "", "", "", "IP" };
        Table table = new Table(9);
        table.setWidth(100);
        table.setAlignment(Element.ALIGN_CENTER);// 
        table.setAutoFillEmptyCells(true); // 
        table.setBorderWidth(1); // 
        table.setBorderColor(new Color(0, 125, 255)); // 
        table.setPadding(2);// 
        table.setSpacing(0);// 
        table.setBorder(2);// 
        for (int i = 0; i < networkTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(networkTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(networkList.size() + 1);
            }
            if (i == 1 || i == 4 || i == 3) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (networkIt != null) {
            while (networkIt.hasNext()) {
                Cell cell1 = new Cell();
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell4 = new Cell();
                Cell cell5 = new Cell();
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) networkIt.next();
                cell1.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell2.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getType(), fontChineseRow));
                cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell5.addElement(
                        new Paragraph(String.valueOf(monitorNodeDTO.getEntityNumber()), fontChineseRow));
                cell1.setColspan(2);
                // cell2.setColspan(2);
                cell3.setColspan(2);
                cell4.setColspan(2);
                // cell5.setColspan(2);
                table.addCell(cell1);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
                table.addCell(cell5);
            }
        }
        for (int i = 0; i < serverTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(serverTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(diskcount + 1 + serverList.size());
            }
            if (i == 5 || i == 6) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (serverIt != null) {
            while (serverIt.hasNext()) {
                Cell cell1 = new Cell();
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell44 = new Cell();
                cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell44.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorNodeDTO monitorNodeDTO = (MonitorNodeDTO) serverIt.next();
                AssetHelper helper = new AssetHelper();
                List<StatisNumer> diskList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Disk");
                List<StatisNumer> memList = helper.getAssetList(monitorNodeDTO.getIpAddress(), "Memory");
                cell1.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell2.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getType(), fontChineseRow));
                cell44.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell1.setRowspan(diskList.size() + 2);
                cell2.setRowspan(diskList.size() + 2);
                cell3.setRowspan(diskList.size() + 2);
                cell44.setRowspan(diskList.size() + 2);
                table.addCell(cell1);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell44);
                Iterator<StatisNumer> diskIt = diskList.iterator();
                int flag = 0;
                int rowspan = diskList.size() + 2;
                double sum = 0;
                while (diskIt.hasNext()) {
                    if (flag == 0 || flag == rowspan / 2) {
                        if (flag == 0) {
                            Cell cellt1 = new Cell();
                            Cell cellt2 = new Cell();
                            cell1.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cellt1.add(new Paragraph("", fontChineseRow));
                            cellt2.add(new Paragraph("", fontChineseRow));
                            table.addCell(cellt1);
                            table.addCell(cellt2);
                        }
                        Iterator<StatisNumer> memIt = memList.iterator();
                        while (memIt.hasNext()) {
                            StatisNumer numer = memIt.next();
                            if (flag == rowspan / 2) {
                                flag++;
                                continue;
                            }
                            Cell cell6 = new Cell();
                            Cell cell7 = new Cell();
                            cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
                            cell6.addElement(new Paragraph(numer.getName(), fontChineseRow));
                            cell7.addElement(new Paragraph(numer.getCurrent(), fontChineseRow));
                            if (flag == 0) {
                                cell6.setRowspan(rowspan / 2);
                                cell7.setRowspan(rowspan / 2);
                                table.addCell(cell6);
                                table.addCell(cell7);
                                break;
                            } else {
                                cell6.setRowspan(rowspan - rowspan / 2);
                                cell7.setRowspan(rowspan - rowspan / 2);
                                table.addCell(cell6);
                                table.addCell(cell7);
                            }
                        }
                    }
                    Cell cell4 = new Cell();
                    Cell cell5 = new Cell();
                    cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    StatisNumer numer = diskIt.next();
                    cell4.addElement(new Paragraph(numer.getName(), fontChineseRow));
                    cell5.addElement(new Paragraph(numer.getCurrent(), fontChineseRow));
                    table.addCell(cell4);
                    table.addCell(cell5);
                    sum = Arith.add(sum, Double.parseDouble(numer.getCurrent().replaceAll("[a-zA-Z]", "")));
                    flag++;
                }
                Cell cell6 = new Cell();
                Cell cell7 = new Cell();
                cell6.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell7.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell6.addElement(new Paragraph("", fontChineseRow));
                cell7.addElement(new Paragraph(Arith.round(sum, 2) + "G", fontChineseRow));
                table.addCell(cell6);
                table.addCell(cell7);
            }
        }
        for (int i = 0; i < dbTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(dbTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(dbList.size() + 1);
            }
            if (i == 3) {
                cell.setColspan(4);
            } else if (i != 0) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (dbIt != null) {
            while (dbIt.hasNext()) {
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell4 = new Cell();
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorDBDTO monitorNodeDTO = (MonitorDBDTO) dbIt.next();
                cell2.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getDbtype(), fontChineseRow));
                cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell2.setColspan(2);
                cell3.setColspan(2);
                cell4.setColspan(4);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
            }
        }
        for (int i = 0; i < midwareTitle.length; i++) {
            Cell cell = new Cell();
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.addElement(new Paragraph(midwareTitle[i], fontChineseTitle));
            if (i == 0) {
                cell.setRowspan(midwareList.size() + 1);
            }
            if (i == 3) {
                cell.setColspan(4);
            } else if (i != 0) {
                cell.setColspan(2);
            }
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            table.addCell(cell);
        }
        if (midwareIt != null) {
            while (midwareIt.hasNext()) {
                Cell cell2 = new Cell();
                Cell cell3 = new Cell();
                Cell cell4 = new Cell();
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                MonitorMiddlewareDTO monitorNodeDTO = (MonitorMiddlewareDTO) midwareIt.next();
                cell2.addElement(new Paragraph(monitorNodeDTO.getAlias(), fontChineseRow));
                cell3.addElement(new Paragraph(monitorNodeDTO.getCategory(), fontChineseRow));
                cell4.addElement(new Paragraph(monitorNodeDTO.getIpAddress(), fontChineseRow));
                cell2.setColspan(2);
                cell3.setColspan(2);
                cell4.setColspan(4);
                table.addCell(cell2);
                table.addCell(cell3);
                table.addCell(cell4);
            }
        }
        document.add(table);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

public void createPdfReport_hardware(String filename) {
    try {//from ww w.  j  a  v  a  2 s .co m
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        fileName = 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, 10, Font.NORMAL);
        Paragraph title = new Paragraph("", 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 Phrase("\n"));
        Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
        PdfPTable aTable = new PdfPTable(4);
        float[] widths = { 100f, 100f, 300f, 100f };
        aTable.setWidths(widths);
        aTable.setWidthPercentage(100);
        aTable.addCell(new Phrase("", contextFont));
        aTable.addCell(new Phrase("", contextFont));
        aTable.addCell(new Phrase("", contextFont));
        aTable.addCell(new Phrase("", contextFont));
        Vector deviceV = (Vector) reportHash.get("deviceV");
        for (int m = 0; m < deviceV.size(); m++) {
            Devicecollectdata devicedata = (Devicecollectdata) deviceV.get(m);
            String name = devicedata.getName();
            String type = devicedata.getType();
            String status = devicedata.getStatus();
            aTable.addCell(new Phrase(m + 1 + "", contextFont));
            aTable.addCell(new Phrase(type, contextFont));
            aTable.addCell(new Phrase(name, contextFont));
            aTable.addCell(new Phrase(status, contextFont));
        }
        /*
         * Image img =
         * Image.getInstance(ResourceCenter.getInstance().getSysPath() +
         * "/resource/image/jfreechart/" + newip + "ConnectUtilization" +
         * ".png");
         * 
         * img.setAlignment(Image.LEFT);//  img.scalePercent(75);
         * document.add(aTable); document.add(img);
         */
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

public void createReportusa_oraPDF(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;/*from   w w w  . j a va  2s . c om*/
        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 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);
        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, 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((String) maxping.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((String) maxping.get("pingmin")));// HONGLI
        // MODIFY
        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.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("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}

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

public void createReportusa_oraDoc(String filename) throws DocumentException, IOException {
    try {//from www  .  ja va 2 s . c  o m
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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);
        // System.out.println("newi ========================"+newip);
        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.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        Table aTable = new Table(4);
        float[] widths = { 220f, 220f, 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 = null;
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell("");
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new Cell(new Phrase((String)
        // maxping.get("pingmax"),contextFont));
        cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new Cell(new Phrase((String)
        // maxping.get("ping"),contextFont));
        cell = new Cell(new Phrase((String) maxping.get("pingmin"), contextFont));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), 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");
        document.add(aTable);
        document.add(img);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}