Example usage for com.itextpdf.text.pdf BaseField setFont

List of usage examples for com.itextpdf.text.pdf BaseField setFont

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf BaseField setFont.

Prototype

public void setFont(BaseFont font) 

Source Link

Document

Sets the text font.

Usage

From source file:com.vectorprint.report.itext.style.stylers.FieldFont.java

License:Open Source License

@Override
public <E> E style(E element, Object data) throws VectorPrintException {
    element = super.style(element, data);
    BaseField bf = getFromCell(element);
    if (bf != null) {

        com.itextpdf.text.Font f = FontFactory.getFont(getValue(FAMILY_PARAM, String.class),
                getValue(SIZE_PARAM, Float.class), getValue(STYLE_PARAM, Font.STYLE.class).getStyle());
        if (f.getBaseFont() == null) {
            throw new VectorPrintRuntimeException(
                    "font " + f.getFamilyname() + " does not have a basefont, check your fontloading");
        }/*from  w  w  w.  jav  a2 s .  c o  m*/
        bf.setFont(f.getBaseFont());
        bf.setFontSize(getValue(SIZE_PARAM, Float.class));
        bf.setTextColor(itextHelper.fromColor(getValue(COLOR_PARAM, Color.class)));
    }
    return element;
}