Example usage for com.lowagie.text FontFactory HELVETICA_BOLD

List of usage examples for com.lowagie.text FontFactory HELVETICA_BOLD

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory HELVETICA_BOLD.

Prototype

String HELVETICA_BOLD

To view the source code for com.lowagie.text FontFactory HELVETICA_BOLD.

Click Source Link

Document

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

Usage

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addTextItem(TextServiceItem t) throws DocumentException {

    String text = t.getText().replace(Song.CHORUS_MARK, "").replace(Song.SLIDE_BREAK, "");

    Paragraph p;/*  w w  w  .  ja v  a2 s .  c  om*/

    p = new Paragraph(t.getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16));
    document.add(p);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    p = new Paragraph(text, FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    document.newPage();
}

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addSongChordsSimple(Song s) throws DocumentException {

    // If we don't have the chords saved, skip it
    if (s.getChordsSimplified().trim().equals(""))
        return;/*from   ww  w  . j  av a2 s  . c  o m*/

    addSongHeader(s);

    Paragraph p;

    p = new Paragraph("("
            + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS SIMPLE") + ")",
            FontFactory.getFont(FontFactory.HELVETICA, 8));
    document.add(p);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    String text[] = s.getChordsSimplified().replace(Song.CHORUS_MARK, " ").replace(Song.SLIDE_BREAK, " ")
            .split("\n");

    addSongChords(text);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    if (exportGuitarTabs) {
        p = new Paragraph(s.getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD));
        guitarTabs.add(p);

        p = new Paragraph("("
                + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS COMPLETE")
                + ")", FontFactory.getFont(FontFactory.HELVETICA, 8));
        guitarTabs.add(p);

        guitarTabs.addAll(addChordsShape(Song.getUsedChords(s.getChordsSimplified())));
    }

    document.newPage();

}

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addSongChordsComplete(Song s) throws DocumentException {

    // If we don't have the chords saved, skip it
    if (s.getChordsComplete().trim().equals(""))
        return;/*from   w ww  .  j ava 2  s .c o m*/

    addSongHeader(s);

    Paragraph p;

    p = new Paragraph(
            "(" + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS COMPLETE")
                    + ")",
            FontFactory.getFont(FontFactory.HELVETICA, 8));
    document.add(p);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    String text[] = s.getChordsComplete().replace(Song.CHORUS_MARK, " ").replace(Song.SLIDE_BREAK, " ")
            .split("\n");
    addSongChords(text);

    p = new Paragraph(" ", FontFactory.getFont(FontFactory.HELVETICA));
    document.add(p);

    if (exportGuitarTabs) {
        p = new Paragraph(s.getTitle(), FontFactory.getFont(FontFactory.HELVETICA_BOLD));
        guitarTabs.add(p);
        p = new Paragraph("("
                + java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("CHORDS COMPLETE")
                + ")", FontFactory.getFont(FontFactory.HELVETICA, 8));
        guitarTabs.add(p);

        guitarTabs.addAll(addChordsShape(Song.getUsedChords(s.getChordsComplete())));
    }

    document.newPage();

}

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

public void addGuitarTabs() throws DocumentException {

    document.newPage();/*from  www .j av a 2s. c o  m*/

    Paragraph p = new Paragraph(
            java.util.ResourceBundle.getBundle("datasoul/internationalize").getString("GUITAR TABS"),
            FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16));
    document.add(p);

    for (Paragraph p2 : guitarTabs) {
        document.add(p2);
    }

}

From source file:gov.medicaid.services.impl.ExportServiceBean.java

License:Apache License

/**
 * Creates a header cell./*  w w  w. j  a va2s.  c  o m*/
 * 
 * @param text
 *            the header text
 * @param colspan
 *            the span of the header
 * @return the generated cell.
 */
private static PdfPCell createHeaderCell(String text, int colspan) {
    PdfPCell header = new PdfPCell(new Phrase(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD)));
    header.setBorder(Rectangle.BOTTOM);
    header.setColspan(colspan);
    return header;
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Creates a header cell.// w w w .jav  a 2 s  . c om
 *
 * @param text the header text
 * @param colspan the span of the header
 * @return the generated cell.
 */
public static PdfPCell createHeaderCell(String text, int colspan) {
    PdfPCell header = new PdfPCell(new Phrase(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD)));
    header.setBorder(Rectangle.BOTTOM);
    header.setColspan(colspan);
    return header;
}

From source file:gov.medicaid.services.util.PDFHelper.java

License:Apache License

/**
 * Adds a label to the given table.//from   www . jav a2  s  .  c  om
 *
 * @param table the table to add to
 * @param label the label text
 */
public static void addLabel(PdfPTable table, String label) {
    PdfPCell key = new PdfPCell(
            new Phrase(Util.defaultString(label), FontFactory.getFont(FontFactory.HELVETICA_BOLD, 8)));
    key.setBorder(Rectangle.NO_BORDER);
    table.addCell(key);
}

From source file:org.areasy.common.doclet.document.Fonts.java

License:Open Source License

public static Font getFont(int faceType, int style, int size) {
    Font font = null;//from  w w w  .  j  a  v  a 2 s  .  com
    String lookup = String.valueOf(faceType);
    String fontFile = fontTable.getProperty(lookup);

    int fontStyle = Font.NORMAL;
    Color color = COLOR_BLACK;

    if ((style & LINK) != 0) {
        fontStyle += Font.UNDERLINE;
        color = COLOR_LINK;
    } else if ((style & UNDERLINE) != 0)
        fontStyle += Font.UNDERLINE;

    if ((style & STRIKETHROUGH) != 0)
        fontStyle += Font.STRIKETHRU;

    if (fontFile != null) {

        File file = new File(DefaultConfiguration.getWorkDir(), fontFile);
        if (file.exists() && file.isFile()) {

            try {
                String encoding = encTable.getProperty(lookup, BaseFont.CP1252);
                BaseFont bfComic = BaseFont.createFont(file.getAbsolutePath(), encoding, BaseFont.EMBEDDED);

                if ((style & AbstractConfiguration.ITALIC) > 0) {
                    if ((style & AbstractConfiguration.BOLD) > 0)
                        fontStyle += Font.BOLDITALIC;
                    else
                        fontStyle += Font.ITALIC;
                } else if ((style & AbstractConfiguration.BOLD) > 0)
                    fontStyle += Font.BOLD;

                if (fontStyle != Font.NORMAL)
                    font = new Font(bfComic, size, fontStyle, color);
                else
                    font = new Font(bfComic, size);

                if (font == null)
                    throw new IllegalArgumentException("Font null: " + fontFile);
            } catch (Exception e) {
                e.printStackTrace();
                throw new IllegalArgumentException("Font unusable");
            }
        } else
            DocletUtility.error("Font file not found: " + fontFile);
    } else {
        // Use predefined font
        String face = "";

        if (faceType == TEXT_FONT) {
            face = FontFactory.HELVETICA;

            if ((style & AbstractConfiguration.ITALIC) > 0) {
                if ((style & AbstractConfiguration.BOLD) > 0)
                    face = FontFactory.HELVETICA_BOLDOBLIQUE;
                else
                    face = FontFactory.HELVETICA_OBLIQUE;
            } else if ((style & AbstractConfiguration.BOLD) > 0)
                face = FontFactory.HELVETICA_BOLD;
        } else {
            face = FontFactory.COURIER;
            if ((style & ITALIC) > 0) {
                if ((style & BOLD) > 0)
                    face = FontFactory.COURIER_BOLDOBLIQUE;
                else
                    face = FontFactory.COURIER_OBLIQUE;
            } else if ((style & BOLD) > 0)
                face = FontFactory.COURIER_BOLD;
        }

        if (fontStyle != Font.NORMAL)
            font = FontFactory.getFont(face, size, fontStyle, color);
        else
            font = FontFactory.getFont(face, size);
    }

    return font;
}

From source file:org.cyberoam.iview.charts.Chart.java

License:Open Source License

/**
 * Function to write a given ChartID to pdf file
 * @param pdfFileName specifies the pdf where chart is written.Please specify full path with the filename.
 * @param reportGroup id specifies the chart to be generated
 * @param startdate specifies start date 
 * @param enddate specifies end date/*w  ww.j a v a2  s  .co  m*/
 * @param limit specifies number of records per record to be written in report
 */
public static void generatePDFReportGroup(OutputStream out, int reportGroupID, String applianceID,
        String startDate, String endDate, String limit, int[] deviceIDs, HttpServletRequest request,
        LinkedHashMap paramMap) throws Exception {
    float width = 768;
    float height = 1024;
    float rec_hieght = 470;
    Rectangle pagesize = new Rectangle(768, 1024);
    Document document = new Document(pagesize, 30, 30, 30, 30);

    JFreeChart chart = null;
    SqlReader sqlReader = new SqlReader(false);
    //CyberoamLogger.sysLog.debug("pdf:"+pdfFileName);
    CyberoamLogger.sysLog.debug("reportGroupID:" + reportGroupID);
    CyberoamLogger.sysLog.debug("applianceID:" + applianceID);
    CyberoamLogger.sysLog.debug("startDate:" + startDate);
    CyberoamLogger.sysLog.debug("endDate:" + endDate);
    CyberoamLogger.sysLog.debug("limit:" + limit);
    try {
        //PdfWriter writer = PdfWriter.getInstance(document, response!=null ? response.getOutputStream():new FileOutputStream(pdfFileName));
        PdfWriter writer = PdfWriter.getInstance(document, out);
        writer.setPageEvent(new Chart());
        document.addAuthor("iView");
        document.addSubject("iView Report");
        document.open();
        PdfContentByte contentByte = writer.getDirectContent();
        ReportGroupBean reportGroupBean = ReportGroupBean.getRecordbyPrimarykey(reportGroupID);
        ArrayList reportList = reportGroupBean.getReportIdByReportGroupId(reportGroupID);
        ReportBean reportBean;
        ResultSetWrapper rsw = null;

        String seperator = System.getProperty("file.separator");

        //String path=System.getProperty("catalina.home") +seperator+"webapps" +seperator+"ROOT" + seperator + "images" + seperator + "iViewPDF.jpg";
        String path = InitServlet.contextPath + seperator + "images" + seperator + "iViewPDF.jpg";

        Image iViewImage = Image.getInstance(path);
        iViewImage.scaleAbsolute(750, 900);
        //iViewImage.scaleAbsolute(600,820);
        iViewImage.setAbsolutePosition(10, 10);
        document.add(iViewImage);

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

        /*
         *   Generating Table on the First Page of Report providing summary of Content 
         */
        PdfPTable frontPageTable = new PdfPTable(2);
        PdfPCell dataCell;
        ReportGroupRelationBean reportGroupRelationBean;
        String reportName = "";

        Color tableHeadBackColor = new Color(150, 174, 190);
        Color tableContentBackColor = new Color(229, 232, 237);
        Color tableBorderColor = new Color(229, 232, 237);

        dataCell = new PdfPCell(new Phrase(new Chunk("Report Profile",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
        dataCell.setBackgroundColor(tableHeadBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        /**
         * Getting dynamic title.
         */
        String title = "";
        if (paramMap != null) {
            title = paramMap.get("title").toString();

            paramMap.remove("title");
        }
        if (request != null)
            title = getFormattedTitle(request, reportGroupBean, true);

        dataCell = new PdfPCell(new Phrase(new Chunk(title,
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.PLAIN, new Color(255, 255, 255)))));
        dataCell.setBackgroundColor(tableHeadBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Start Date",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(startDate));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("End Date",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(endDate));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("iView Server Time",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        java.util.Date currentDate = new java.util.Date();
        dataCell = new PdfPCell(new Phrase(currentDate.toString()));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Reports",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        int len = reportList.size();
        for (int k = 0; k < len; k++) {
            reportGroupRelationBean = (ReportGroupRelationBean) reportList.get(k);
            reportName += " " + (k + 1) + ". "
                    + ReportBean.getRecordbyPrimarykey(reportGroupRelationBean.getReportId()).getTitle() + "\n";
        }
        dataCell = new PdfPCell(new Phrase("\n" + reportName + "\n"));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);

        frontPageTable.addCell(dataCell);

        dataCell = new PdfPCell(new Phrase(new Chunk("Device Names (IP Address)",
                FontFactory.getFont(FontFactory.HELVETICA_BOLD, 12, Font.PLAIN, new Color(0, 0, 0)))));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        DeviceBean deviceBean = null;
        String deviceNameWithIP = "";
        if (deviceIDs != null) {
            for (int i = 0; i < deviceIDs.length; i++) {
                deviceBean = DeviceBean.getRecordbyPrimarykey(deviceIDs[i]);
                if (deviceBean != null) {
                    deviceNameWithIP += " " + (i + 1) + ". " + deviceBean.getName() + " (" + deviceBean.getIp()
                            + ")\n";
                }
            }
        }
        dataCell = new PdfPCell(new Phrase("\n" + deviceNameWithIP + "\n"));
        dataCell.setBackgroundColor(tableContentBackColor);
        dataCell.setBorderColor(tableBorderColor);
        frontPageTable.addCell(dataCell);

        /*
         * Adding Table to PDF      
         */
        document.add(frontPageTable);

        /*
         * Adding Charts and Table to PDF 
         */
        for (int i = 0; i < reportList.size(); i++) {
            document.newPage();
            reportBean = ReportBean
                    .getRecordbyPrimarykey(((ReportGroupRelationBean) reportList.get(i)).getReportId());
            String query = null;
            if (request == null) {
                query = PrepareQuery.getQuery(reportBean, startDate, endDate, applianceID, null, null, "0",
                        limit, paramMap);
            } else {
                PrepareQuery prepareQuery = new PrepareQuery();
                query = prepareQuery.getQuery(reportBean, request);
            }
            CyberoamLogger.sysLog.debug("PDF:ReportID:" + reportBean.getReportId() + "Query->" + query);

            try {
                rsw = sqlReader.getInstanceResultSetWrapper(query);
            } catch (org.postgresql.util.PSQLException e) {
                if (query.indexOf("5min_ts_20") > -1) {
                    query = query.substring(0, query.indexOf("5min_ts_20")) + "4hr"
                            + query.substring(query.indexOf("5min_ts_20") + 16, query.length());
                    CyberoamLogger.appLog.debug("New query : " + query);
                    rsw = sqlReader.getInstanceResultSetWrapper(query);

                } else {
                    CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                }
            } catch (Exception e) {
                CyberoamLogger.appLog.error("Exeption in AjaxController.java " + e, e);
                rsw.close();
            }

            /*
             * PDF Rendering work starts here
             */

            for (int j = 0; j < (int) (rec_hieght / 16) + 1; j++) {
                document.add(new Paragraph("\n"));
            }
            // This fix is to resolve the problems associated with reports which don't have graphs.
            // If there is no graph associated with the report than no need to generate 
            //a chart for it.
            GraphBean graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getReportId());
            //if(graphBean!=null)
            if (reportBean.getReportFormatId() != 2) {
                chart = Chart.getChart(reportBean.getReportId(), rsw, null);
                PdfTemplate pdfTemplate = contentByte.createTemplate(width, height);
                Graphics2D graphics2D = pdfTemplate.createGraphics(width, height);
                Rectangle2D rectangle = new Rectangle2D.Double(100, 85, 540, rec_hieght);
                chart.draw(graphics2D, rectangle);
                graphics2D.dispose();
                contentByte.addTemplate(pdfTemplate, 0, 0);
            } else {
                Paragraph p = new Paragraph(reportBean.getTitle() + "\n\n",
                        FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLD));
                p.setAlignment("center");
                document.add(p);
            }

            // Retrieving PdfPTable
            PdfPTable pdfTable = getPdfPTable(reportBean, rsw);
            rsw.close();

            /*
             * Adding Table to PDF
             */

            document.add(pdfTable);
        }
        CyberoamLogger.appLog.info("*************Finishing Chart****************");
    } catch (Exception e) {
        CyberoamLogger.sysLog.debug("Chart.writeChartToPDF.e" + e.getMessage(), e);
    } finally {
        sqlReader.close();
    }

    document.close();
}

From source file:org.cyberoam.iview.charts.Chart.java

License:Open Source License

/**
 * Function for getting report PdfPtable instance for given report and record set
 * @param report bean specifies the report for which table is generated 
 * @param rsw specifies Result set collection
 * @return instance of PdfPtable//www  . ja va2 s .  co  m
 */
public static PdfPTable getPdfPTable(ReportBean reportBean, ResultSetWrapper rsw) {
    PdfPTable pdfTable = null;
    try {
        rsw.last();
        //int rowCount=rsw.getRow();
        ReportColumnBean[] reportColumns = (ReportColumnBean[]) ReportColumnBean
                .getReportColumnsByReportID(reportBean.getReportId()).toArray(new ReportColumnBean[0]);
        pdfTable = new PdfPTable(reportColumns.length);
        // Adding Column Name to PDF Table
        PdfPCell headCell;
        for (int count = 0; count < reportColumns.length; count++) {
            headCell = new PdfPCell(new Phrase(18, new Chunk(reportColumns[count].getColumnName(),
                    FontFactory.getFont(FontFactory.HELVETICA_BOLD, 16, Font.BOLD, Color.blue))));
            headCell.setBackgroundColor(new Color(238, 238, 238));
            pdfTable.addCell(headCell);
        }
        String data;
        int i = 0;
        rsw.beforeFirst();
        while (rsw.next()) {
            for (int j = 0; j < reportColumns.length; j++) {
                if (reportColumns[j].getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) {
                    data = ByteInUnit.getBytesInUnit(rsw.getLong(reportColumns[j].getDbColumnName()));
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.PERCENTAGE_FORMATTING) {
                    data = rsw.getString(reportColumns[j].getDbColumnName()) + " %";
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.DECODE_FORMATTING) {
                    data = URLDecoder.decode(rsw.getString(reportColumns[j].getDbColumnName()));
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.PROTOCOL_FORMATTING) {
                    int index = rsw.getString(reportColumns[j].getDbColumnName()).indexOf(':');
                    if (index != -1) {
                        data = ProtocolBean.getProtocolNameById(Integer.parseInt(
                                rsw.getString(reportColumns[j].getDbColumnName()).substring(0, index)));
                        data = data + rsw.getString(reportColumns[j].getDbColumnName()).substring(index,
                                rsw.getString(reportColumns[j].getDbColumnName()).length());
                    } else {
                        data = rsw.getString(reportColumns[j].getDbColumnName());
                    }
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.SEVERITY_FORMATTING) {
                    data = TabularReportConstants
                            .getSeverity(rsw.getString(reportColumns[j].getDbColumnName()));
                } else if (reportColumns[j].getColumnFormat() == TabularReportConstants.ACTION_FORMATTING) {
                    data = TabularReportConstants.getAction(rsw.getString(reportColumns[j].getDbColumnName()));
                } else {
                    data = rsw.getString(reportColumns[j].getDbColumnName());
                }
                if (data == null || "".equalsIgnoreCase(data))
                    data = "N/A";
                pdfTable.addCell(data);
            }
            i++;
        }
    } catch (SQLException e) {
        CyberoamLogger.sysLog.debug("Chart.getPDFPTable.e" + e, e);
    }

    return pdfTable;
}