long start = System.currentTimeMillis();
JasperPrint jasperPrint = JasperFillManager.fillReport("H:\\hyxprintworkspace\\taobao\\sfDemo\\src\\com\\sf\\openapi\\waybill\\print\\util\\poster_100mm150mm.jasper", null, new JREmptyDataSource());
JRGraphics2DExporter exporter = new JRGraphics2DExporter();//创建graphics输出器
//创建一个影像对象
BufferedImage bufferedImage = new BufferedImage(jasperPrint.getPageWidth() * 4, jasperPrint.getPageHeight() * 4, BufferedImage.TYPE_INT_RGB);
//取graphics
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();//释放资源信息
//这里的buf
JasperReports打印图片
最新推荐文章于 2023-08-28 17:14:01 发布
![](https://img-home.csdnimg.cn/images/20240709112858.png)