I am developing a Java App. I created a pie chart using jFreeChart and added it to a PDF file created with the iText library, but I cannot find a way to align and center the graphic inside the PDF. This is the code I'm using to add the chart:
PdfContentByte contentByte = writer.getDirectContent();
PdfTemplate template = contentByte.createTemplate(600, 600);
Graphics2D graphics2d = template.createGraphics(600, 600, new DefaultFontMapper());
Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 300, 300);
resultsPieChart.draw(graphics2d, rectangle2d);
graphics2d.dispose();
contentByte.addTemplate(template, 0, 0);