2011-05-27 130 views
1

当我添加1个图表文件是没有问题的问题添加图表(JFreeChart的PDF)和(iText的)

当我添加第二张图我得到这个错误...螺纹

异常“main”com.itextpdf.text.exceptions.IllegalPdfSyntaxException:不平衡的保存/恢复状态操作符。

chart1 = SpecialJFreeChartBuilder.createChart1(
       "Site and Number of Requests ", results); 

     document.newPage(); 

     PdfContentByte Add_Chart_Content = writer.getDirectContent(); 
     PdfTemplate template_Chart_Holder = Add_Chart_Content 
       .createTemplate(width, height); 
     Graphics2D Graphics_Chart = template_Chart_Holder.createGraphics(
       width, height, new DefaultFontMapper()); 
     Rectangle2D Chart_Region = new Rectangle2D.Double(0, 0, 540, 380); 
     chart1.draw(Graphics_Chart, Chart_Region); 
     Graphics_Chart.dispose(); 
     Add_Chart_Content.addTemplate(template_Chart_Holder, 0, 0); 

     chart2 = SpecialJFreeChartBuilder.createChart2(
       "Site and totalAmount ", results); 

     document.newPage(); 

     PdfContentByte Add_Chart_Content1 = writer.getDirectContent(); 
     PdfTemplate template_Chart_Holder1 = Add_Chart_Content1 
       .createTemplate(width, height); 
     Graphics2D Graphics_Chart1 = template_Chart_Holder1.createGraphics(
       width, height, new DefaultFontMapper()); 
     Rectangle2D Chart_Region1 = new Rectangle2D.Double(0, 0, 540, 380); 
     chart2.draw(Graphics_Chart1, Chart_Region1); 
     Graphics_Chart.dispose(); 
     Add_Chart_Content.addTemplate(template_Chart_Holder1, 0, 0); 

.... document.close();

谁能帮我....

+0

解决了问题... Graphics_Chart.dispose(); 必须是: Graphics_Chart1.dispose(); Graphics_Chart2.dispose(); – 2011-05-27 22:04:52

回答

0

解决问题... Graphics_Chart.dispose();必须是:Graphics_Chart1.dispose(); Graphics_Chart2.dispose();

相关问题