Export a report as an image
Map parameters = new HashMap();
JasperPrint jasperPrint =
JasperFillManager.fillReport(
(JasperReport) JRLoader.loadObject(new File("d:/injuryPresume.jasper")), parameters, new JREmptyDataSource());
JRGraphics2DExporter exporter = new JRGraphics2DExporter();
BufferedImage bufferedImage = new BufferedImage(jasperPrint.getPageWidth() * 4, jasperPrint.getPageHeight() * 4, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, g);
exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, Float.valueOf(4));
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.exportReport();
g.dispose();
ImageIO.write(bufferedImage, "JPEG", new File("d:/aa.jpg"));
JasperPrint jasperPrint =
JasperFillManager.fillReport(
(JasperReport) JRLoader.loadObject(new File("d:/injuryPresume.jasper")), parameters, new JREmptyDataSource());
JRGraphics2DExporter exporter = new JRGraphics2DExporter();
BufferedImage bufferedImage = new BufferedImage(jasperPrint.getPageWidth() * 4, jasperPrint.getPageHeight() * 4, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, g);
exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, Float.valueOf(4));
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.exportReport();
g.dispose();
ImageIO.write(bufferedImage, "JPEG", new File("d:/aa.jpg"));
留言
張貼留言