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

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

Introduction

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

Prototype

public void setBoundingBox(Rectangle bBox) 

Source Link

Usage

From source file:questions.ocg.StatusBars1.java

public Image getImage(PdfContentByte cb, int i) throws BadElementException {
    PdfTemplate tmp = cb.createTemplate(100, 10);
    tmp.setBoundingBox(new Rectangle(-5, -2, 105, 12));
    Rectangle r = new Rectangle(0, 0, 100, 10);
    tmp.rectangle(r);// w w  w .j ava 2  s  .  c  o m
    r = new Rectangle(0, 0, i, 10);
    tmp.beginLayer(colorLayerColored);
    if (i % 2 == 0)
        r.setBackgroundColor(Color.RED);
    else
        r.setBackgroundColor(Color.GREEN);
    tmp.rectangle(r);
    tmp.endLayer();
    tmp.beginLayer(colorLayerGreyed);
    r = new Rectangle(0, 0, i, 10);
    if (i % 2 == 0)
        r.setBackgroundColor(new GrayColor(10));
    else
        r.setBackgroundColor(new GrayColor(97));
    tmp.rectangle(r);
    tmp.endLayer();
    return Image.getInstance(tmp);
}