Java 将图表(JFreeChart)添加到Pdf(iText)时出现问题
当我向文档中添加1个图表时,没有问题 当我添加第二个图表时,我得到了这个错误 线程“main”com.itextpdf.text.exceptions.IllegalPdfSyntaxException中的异常:不平衡的保存/还原状态运算符Java 将图表(JFreeChart)添加到Pdf(iText)时出现问题,java,Java,当我向文档中添加1个图表时,没有问题 当我添加第二个图表时,我得到了这个错误 线程“main”com.itextpdf.text.exceptions.IllegalPdfSyntaxException中的异常:不平衡的保存/还原状态运算符 chart1 = SpecialJFreeChartBuilder.createChart1( "Site and Number of Requests ", results); document.newPa
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()
有人能帮我解决这个问题吗。。。Graphics_Chart.dispose();必须是:Graphics_Chart1.dispose();图形图表2.dispose() 解决了这个问题。。。Graphics_Chart.dispose();必须是:Graphics_Chart1.dispose();图形图表2.dispose();