Example usage for com.lowagie.text Font BOLD

List of usage examples for com.lowagie.text Font BOLD

Introduction

In this page you can find the example usage for com.lowagie.text Font BOLD.

Prototype

int BOLD

To view the source code for com.lowagie.text Font BOLD.

Click Source Link

Document

this is a possible style.

Usage

From source file:de.unigoettingen.sub.commons.contentlib.pdflib.PDFTitlePage.java

License:Apache License

/************************************************************************************
 * render paragraph into title page// ww  w  .j a v  a2  s  .  c  o m
 * 
 * @param pdftpp given {@link PDFTitlePageParagraph} to render
 * @param pdfdoc given {@link com.lowagie.text.Document} where to render
 * @throws DocumentException
 ************************************************************************************/
private void renderParagraph(PDFTitlePageParagraph pdftpp, com.lowagie.text.Document pdfdoc)
        throws DocumentException {
    String text = pdftpp.getContent();
    if (text == null) {
        text = "";
    }
    int fontstyle = Font.NORMAL;
    if (pdftpp.getFonttype().equals("bold")) {
        fontstyle = Font.BOLD;
    }
    if (pdftpp.getFonttype().equals("italic")) {
        fontstyle = Font.ITALIC;
    }
    if (pdftpp.getFonttype().equals("bolditalic")) {
        fontstyle = Font.BOLDITALIC;
    }
    if (pdftpp.getFonttype().equals("underline")) {
        fontstyle = Font.UNDERLINE;
    }
    if (pdftpp.getFonttype().equals("strikethru")) {
        fontstyle = Font.STRIKETHRU;
    }
    // create BaseFont for embedding
    try {
        Font font = FontFactory.getFont("Arial", BaseFont.CP1252, BaseFont.EMBEDDED, pdftpp.getFontsize(),
                fontstyle);
        Paragraph p2 = new Paragraph(new Chunk(text, font));
        // Paragraph p2=new Paragraph(text,
        // FontFactory.getFont(FontFactory.TIMES_ROMAN, 12));
        pdfdoc.add(p2);
    } catch (Exception e) {
        LOGGER.error("error occured while generating paragraph for titlepage", e);
    }
}

From source file:de.xirp.report.ReportGenerator.java

License:Open Source License

/**
 * Returns a default formatted list for the given list type.
 * /*from w ww .j av  a2  s .co  m*/
 * @param type
 *            The list type.
 * @return A default formatted list.
 */
private static List getList(ListType type) {
    switch (type) {
    case BULLET:
        List list = new List(false, 20);
        list.setListSymbol(new Chunk("\u2022", FontFactory.getFont( //$NON-NLS-1$
                FontFactory.HELVETICA, 12, Font.BOLD)));
        return list;
    case DASH:
        return new List(false, 20);
    case NUMBER:
        return new List(true, 20);
    }
    return null;
}

From source file:demo.dwr.simple.UploadDownload.java

License:Apache License

/**
 * And scrawl the text on the image in 10 rows of 21 chars
 * @param uploadImage The image to work on
 * @param uploadFile The text to write on the image
 * @param color The selected color/*  w w w  .  j  a v  a2 s.c  om*/
 * @return The altered image
 */
private BufferedImage grafitiTextOnImage(BufferedImage uploadImage, String uploadFile, String color) {
    StringBuilder buffer = new StringBuilder();
    while (buffer.length() < 200) {
        buffer.append(" ");
        buffer.append(uploadFile);
    }

    Graphics2D g2d = uploadImage.createGraphics();
    for (int row = 0; row < 10; row++) {
        String output = null;
        if (buffer.length() > (row + 1) * CHARS_PER_LINE) {
            output = buffer.substring(row * CHARS_PER_LINE, (row + 1) * CHARS_PER_LINE);
        } else {
            output = buffer.substring(row * CHARS_PER_LINE);
        }

        g2d.setFont(new java.awt.Font("SansSerif", java.awt.Font.BOLD, 16));
        g2d.setColor(UploadDownload.decodeHtmlColorString(color));
        g2d.drawString(output, 5, (row + 1) * CHARS_PER_LINE);
    }

    return uploadImage;
}

From source file:desktopbugtracker.export.PdfFont.java

License:Open Source License

public static Font bold() {
    return new Font(Font.HELVETICA, Font.DEFAULTSIZE, Font.BOLD);
}

From source file:domain.reports.menu.PDFReportMenu.java

License:LGPL

@Override
protected void createPDF(GenericTransaction data, ByteArrayOutputStream buf) throws Throwable {

    //inicializar documento: tamano de pagina, orientacion, margenes
    Document doc = new Document();
    PdfWriter docWriter = PdfWriter.getInstance(doc, buf);
    doc.setPageSize(PageSize.LETTER.rotate());
    doc.setMargins(30, 30, 30, 40);/* w w  w.j a  v a  2 s  . com*/

    doc.open();

    //crear fonts por defecto
    tblHeaderFont = new Font(Font.HELVETICA, 10f, Font.BOLD);
    tblBodyFont = new Font(Font.HELVETICA, 10f, Font.NORMAL);

    //definir pie de pagina del lado izquierdo
    String footerText = this.getFooter(); //read it from config.xml or web.xml
    String reportDate = StringUtil.formatDate(new java.util.Date(), "dd-MM-yyyy HH:mm");

    //crear template (objeto interno de IText) y manejador de evento 
    //para imprimir el pie de pagina
    bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    cb = docWriter.getDirectContent();
    tpl = cb.createTemplate(20, 14);
    docWriter.setPageEvent(new PDFPageEvents(footerText, pageXofY, tpl, bf, cb, reportDate));

    //titulo - lo lee de config.xml por defecto
    reportTitle = getReportTitle();
    Paragraph t = new Paragraph(reportTitle, new Font(Font.HELVETICA, 14f, Font.BOLD));
    t.setAlignment(Rectangle.ALIGN_RIGHT);
    doc.add(t);

    //logo
    img = Image.getInstance(getImage(this.getServerBaseURL() + logoPath, false));
    img.scalePercent(100);
    float imgY = doc.top() - img.getHeight();
    float imgX = doc.left();
    img.setAbsolutePosition(imgX, imgY);
    doc.add(img);

    //blank line
    doc.add(new Paragraph(" "));
    //blank line
    doc.add(new Paragraph(" "));
    //blank line
    doc.add(new Paragraph(" "));

    //for each master record print a master/detail section
    MasterDetailReader dataobj = (MasterDetailReader) data;
    Recordset master = dataobj.getRecordset("master");
    master.top();
    while (master.next()) {
        //blank line
        doc.add(new Paragraph(" "));

        //print master section
        doc.add(getGroupMaster(master));

        //print detail section
        doc.add(getGroupDetail(master, dataobj.getDetail(master)));

    }

    //print grand total
    doc.add(new Paragraph(" "));

    doc.close();
    docWriter.close();

}

From source file:domain.reports.menu.PDFReportMenu.java

License:LGPL

/**
* Return group header (master)//from   w w  w .ja  v a 2  s . co m
* @param master Recordset containing master records
* @return
* @throws Throwable
*/
Paragraph getGroupMaster(Recordset master) throws Throwable {

    String text = "Aplicacin: " + master.getString("aplication") + "\n";
    text = text + "Men: " + master.getString("title");

    Paragraph t = new Paragraph(text, new Font(Font.HELVETICA, 12f, Font.BOLD));
    t.setAlignment(Rectangle.ALIGN_LEFT);
    return t;

}

From source file:domain.reports.role.PDFReportRole.java

License:LGPL

/**
* Return group header (master)//from www  . j  av  a  2s .c  o  m
* @param master Recordset containing master records
* @return
* @throws Throwable
*/
Paragraph getGroupMaster(Recordset master) throws Throwable {

    String text = "Aplicacin: " + master.getString("aplication") + "\n";
    text = text + "Rol: " + master.getString("rolename") + "\n" + "Descripcin: "
            + master.getString("description");

    Paragraph t = new Paragraph(text, new Font(Font.HELVETICA, 12f, Font.BOLD));
    t.setAlignment(Rectangle.ALIGN_LEFT);
    return t;

}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

@Override
public void export(ActionEvent event, String tableId, FacesContext context, String filename, String tableTitle,
        boolean pageOnly, boolean selectionOnly, String encodingType, MethodExpression preProcessor,
        MethodExpression postProcessor, boolean subTable) throws IOException {
    try {//from   ww w .j a va 2 s  . c  o  m
        Document document = new Document();
        if (orientation.equalsIgnoreCase("Landscape")) {
            document.setPageSize(PageSize.A4.rotate());
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);
        StringTokenizer st = new StringTokenizer(tableId, ",");
        while (st.hasMoreElements()) {
            String tableName = (String) st.nextElement();
            UIComponent component = SearchExpressionFacade.resolveComponent(context, event.getComponent(),
                    tableName);
            if (component == null) {
                throw new FacesException("Cannot find component \"" + tableName + "\" in view.");
            }
            if (!(component instanceof DataTable || component instanceof DataList)) {
                throw new FacesException("Unsupported datasource target:\"" + component.getClass().getName()
                        + "\", exporter must target a PrimeFaces DataTable/DataList.");
            }

            if (preProcessor != null) {
                preProcessor.invoke(context.getELContext(), new Object[] { document });
            }

            if (!document.isOpen()) {
                document.open();
            }
            if (tableTitle != null && !tableTitle.isEmpty() && !tableId.contains("" + ",")) {

                Font tableTitleFont = FontFactory.getFont(FontFactory.TIMES, encodingType, Font.DEFAULTSIZE,
                        Font.BOLD);
                Paragraph title = new Paragraph(tableTitle, tableTitleFont);
                document.add(title);

                Paragraph preface = new Paragraph();
                addEmptyLine(preface, 3);
                document.add(preface);
            }
            PdfPTable pdf;
            DataList list = null;
            DataTable table = null;
            if (component instanceof DataList) {
                list = (DataList) component;
                pdf = exportPDFTable(context, list, pageOnly, encodingType);
            } else {
                table = (DataTable) component;
                pdf = exportPDFTable(context, table, pageOnly, selectionOnly, encodingType, subTable);
            }

            if (pdf != null) {
                document.add(pdf);
            }
            // add a couple of blank lines
            Paragraph preface = new Paragraph();
            addEmptyLine(preface, datasetPadding);
            document.add(preface);

            if (postProcessor != null) {
                postProcessor.invoke(context.getELContext(), new Object[] { document });
            }
        }
        document.close();

        writePDFToResponse(context.getExternalContext(), baos, filename);

    } catch (DocumentException e) {
        throw new IOException(e.getMessage());
    }
}

From source file:ec.edu.chyc.manejopersonal.managebean.PDFCustomExporter.java

License:Apache License

protected void createCustomFonts(String encoding) {

    if (fontName != null && FontFactory.getFont(fontName).getBaseFont() != null) {
        this.cellFont = FontFactory.getFont(fontName, encoding);
        this.facetFont = FontFactory.getFont(fontName, encoding, Font.DEFAULTSIZE, Font.BOLD);
    } else {// w  w  w  .j  a  v a2  s  . c  o  m
        this.cellFont = FontFactory.getFont(FontFactory.HELVETICA, encoding);
        this.facetFont = FontFactory.getFont(FontFactory.HELVETICA, encoding, Font.DEFAULTSIZE, Font.BOLD);
    }
    if (facetFontColor != null) {
        this.facetFont.setColor(facetFontColor);
    }
    if (facetFontSize != null) {
        this.facetFont.setSize(facetFontSize);
    }
    if (facetFontStyle != null) {
        this.facetFont.setStyle(facetFontStyle);
    }
    if (cellFontColor != null) {
        this.cellFont.setColor(cellFontColor);
    }
    if (cellFontSize != null) {
        this.cellFont.setSize(cellFontSize);
    }
    if (cellFontStyle != null) {
        this.cellFont.setStyle(cellFontStyle);
    }
}

From source file:ec.edu.uce.erp.web.common.util.CustomPDFExporter.java

@Override
protected void addColumnFacets(DataTable table, PdfPTable pdfTable, ColumnType columnType) {

    for (UIColumn col : table.getColumns()) {
        if (!col.isRendered()) {
            continue;
        }/*from w  w w. j  a  v a2 s .c o m*/
        if (col instanceof DynamicColumn) {
            ((DynamicColumn) col).applyModel();
        }
        if (col.isExportable()) {
            addHeaderValue(pdfTable, col.getFacet(columnType.facet()),
                    FontFactory.getFont(FontFactory.TIMES, "iso-8859-1", Font.DEFAULTSIZE, Font.BOLD));
        }
    }
}