Hi,
I'm passing a simple implementation of JRAbstractSvgRenderer (taken from the ireports pdf manual) as one of the parameters using JasperFillManager.fillReport.
public class CustomImageRenderer extends JRAbstractSvgRenderer {
@Override
public void render(Graphics2D g2d, Rectangle2D rect) throws JRException {
System.out.println("CustomImageRenderer.render");
// Save the Graphics2D affine transform
AffineTransform savedTrans = g2d.getTransform();
Font savedFont = g2d.getFont();
// Paint a nice background...
g2d.setPaint(new GradientPaint(0, 0, Color.ORANGE,
0, (int) rect.getHeight(), Color.PINK));
g2d.fillRect(0, 0, (int) rect.getWidth(), (int) rect.getHeight());
Font myfont = new Font("Arial Black", Font.PLAIN, 50);
g2d.setFont(myfont);
FontRenderContext frc = g2d.getFontRenderContext();
String text = new String("JasperReports!!!");
TextLayout textLayout = new TextLayout(text, myfont, frc);
Shape outline = textLayout.getOutline(null);
Rectangle r = outline.getBounds();
// Translate the graphic to center the text
g2d.translate(
(rect.getWidth() / 2) - (r.width / 2),
rect.getHeight() / 2 + (r.height / 2));
g2d.setColor(Color.BLACK);
g2d.draw(outline);
// Restore the Graphics2D affine transform
g2d.setFont(savedFont);
g2d.setTransform(savedTrans);
}
}
...
Map parameters = new HashMap();
parameters.put("IMAGEPARAM", new CustomImageRenderer());
...
JasperPrint jasperPrint = JasperFillManager.fillReport(path, parameters, conn);
I have linked an Image component in my report to this parameter but the image does not display. What am I missing here?
What I'd like to accomplish is to eventually pass an already created Java2D image to my report but I don't want pass it as a raster image.
Thanx in advance