if (!fileName.endsWith(".pdf")) {
fileName = fileName + ".pdf";
}
File f = new File(fileDialog.getDirectory(),
fileName);
PDFDocument document = new PDFDocument();
document.setAuthor("ECJ Console");
Page page = document.createPage(new Rectangle(
width, height));
Graphics2D g2 = page.getGraphics2D();
Rectangle2D rectangle2D = new Rectangle2D.Double(0,
0, width, height);
chart.draw(g2, rectangle2D);
g2.dispose();
document.writeToFile(f);
}
} catch (Exception ex)
{
ex.printStackTrace();