Example usage for com.lowagie.text.pdf PdfTemplate setGrayFill

List of usage examples for com.lowagie.text.pdf PdfTemplate setGrayFill

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfTemplate setGrayFill.

Prototype


public void setGrayFill(float gray) 

Source Link

Document

Changes the currentgray tint for filling paths (device dependent colors!).

Usage

From source file:questions.images.CustomizedTitleBar.java

public static Image getTitleBar(PdfWriter writer, Image background, String title)
        throws DocumentException, IOException {
    float width = background.getWidth();
    float height = background.getHeight();
    PdfTemplate tmp = writer.getDirectContent().createTemplate(width, height);
    tmp.addImage(background, width, 0, 0, height, 0, 0);
    BaseFont font = BaseFont.createFont();
    tmp.beginText();/*from w  w  w .j av  a2  s  .c  om*/
    tmp.setGrayFill(1);
    tmp.setFontAndSize(font, 18);
    tmp.showTextAligned(Element.ALIGN_CENTER, title, width / 2, 4, 0);
    tmp.endText();
    return Image.getInstance(tmp);
}