I'm trying to insert chart generated using jfreechart (it should be svg ) in
table, here is the code:
PdfPTable chartTable = new PdfPTable(1);
float width = 200;
float height = 300;
// Batik: Get a DOMImplementation
DOMImplementation domImpl =
GenericDOMImplementation.getDOMImplementation();
// Batik: Create an instance of
org.w3c.dom.Document
Document document = domImpl.createDocument(null,
"svg", null);
// Batik: Create an instance of the SVG
Generator
SVGGraphics2D svgGenerator = new
SVGGraphics2D(document);
chart.draw(svgGenerator, new
Rectangle2D.Double(0, 0, width, height));
PdfContentByte cb =
pdfWriter.getDirectContent();
PdfTemplate template = cb.createTemplate(width,
height);
Graphics2D g2 = template.createGraphics(width,
height);
PrintTranscoder printTranscoder = new
PrintTranscoder();
TranscoderInput transcoderInput = new
TranscoderInput(svgGenerator.getDOMFactory());
printTranscoder.transcode(transcoderInput,
null);
PageFormat pageFormat = new PageFormat();
Paper paper = new Paper();
paper.setSize(width, height);
paper.setImageableArea(0, 0, width, height);
pageFormat.setPaper(paper);
printTranscoder.print(g2, pageFormat, 0);
g2.dispose();
Image img=Image.getInstance(template);
chartTable.addCell(img);
doc.add(chartTable);
The result is always empty table... can anybody help me?
--
View this message in context:
http://old.nabble.com/jfreechart%2C-itext%2C-batik-tp29213979p29213979.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]