List of usage examples for com.itextpdf.text.pdf PdfContentByte createAppearance
public PdfAppearance createAppearance(final float width, final float height)
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; }