Example usage for com.itextpdf.text.pdf PdfContentByte createAppearance

List of usage examples for com.itextpdf.text.pdf PdfContentByte createAppearance

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfContentByte createAppearance.

Prototype

public PdfAppearance createAppearance(final float width, final float height) 

Source Link

Document

Creates a new appearance to be used with form fields.

Usage

From source file:WeeklyReport.Sections.Declines.java

public Image declinesByCommodityImage(PdfWriter writer) throws BadElementException {
    JFreeChart chart = new Declines().declinesByCommodityClassChart();
    PdfContentByte contentByte = writer.getDirectContent();
    PdfTemplate template = contentByte.createAppearance(600f, 400f);
    Graphics2D graphics2d = template.createGraphics(600f, 400f, new DefaultFontMapper());
    Rectangle2D rectangle2d = new Rectangle2D.Float(10f, 0, 500f, 400f);
    chart.draw(graphics2d, rectangle2d);
    graphics2d.dispose();/* w  w  w  . j  ava2 s .  com*/

    Image chartImage = Image.getInstance(template);
    return chartImage;
}