Thanks for reply. i tried to override those method and modified the way you suggested.
below is code for print() fuction
but result is pretty distorted, it does create light background, but other colors are not working properly.
can you tell me what is wrong ??
Code: Select all
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException {
if (pageIndex != 0) {
return NO_SUCH_PAGE;
}
Graphics2D g2 = (Graphics2D) g;
double x = pf.getImageableX();
double y = pf.getImageableY();
double w = pf.getImageableWidth();
double h = pf.getImageableHeight();
try{
JFreeChart cloneChart = (JFreeChart)chart.clone();
ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme());
ChartUtilities.applyCurrentTheme(cloneChart);
cloneChart.draw(g2, new Rectangle2D.Double(x, y, w, h), chartPanel.getAnchor(),
null);
}catch(Exception e){
e.printStackTrace();
}
return PAGE_EXISTS;
}