Insert a Chart in a PdfPTable cell

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

Insert a Chart in a PdfPTable cell

Postby validName » Mon Nov 06, 2017 7:10 am

Hello all,

I am a beginner working for the first time with JFreeChart, I have to modify an application using a PDF export by adding Charts and tables....and charts into tables.

I have tried to find answer but solutions seem to be quite ancient and nothing worked. Can anyone help please ?

this is the code of the cell:
Code: Select all
                                     
PdfPCell cell = new PdfPCell(new Phrase());
p = new Paragraph();
p.add(new Chunk("I'd like to put my chart here", myFont));
p.setAlignment(Element.ALIGN_CENTER);
cell = new PdfPCell();
cell.addElement(p);
cell.setUseAscender(true);
cell.setUseDescender(true);
table.addCell(cell);


and here the code to display the Chart I have to insert in the cell :
Code: Select all
document.newPage();
JFreeChart Chart = myChart(0, 10, 20 , 30);
BufferedImage ChartBufferedImage = myChart.createBufferedImage(200, 200);
Image ChartImage = Image.getInstance(writer,ChartBufferedImage, 1.0f);
mainTable.addCell(ChartImage);
document.add(mainTable);


It seems easy because the chart is already in a table but I can't find how to manage to copy it in another cell of another table. Should I use another PDF writer and/or ByteArrayOutputStream ?
I have tried to be as specific as i could.
thanks,
validName
 
Posts: 1
Joined: Mon Nov 06, 2017 6:56 am

Return to JFreeChart

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests