Jump to content
We've recently updated our Privacy Statement, available here ×

kennethmch

Members
  • Posts

    2
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Posts posted by kennethmch

  1. Assuming you already have the jasperprint object

     

     

     

    Code:
    			        	response.setContentType("image/jpeg");			        				        	BufferedImage pageImage = new BufferedImage(jasperPrint.getPageWidth() + 1, jasperPrint.getPageHeight() + 1, BufferedImage.TYPE_INT_RGB);			        				        	exporter = new JRGraphics2DExporter();			        	exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);			        			                Map imagesMap = new HashMap();		        				                request.getSession().setAttribute("IMAGES_MAP", imagesMap);			        			                exporter.setParameter(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.FALSE);		                exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);		                exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, context+"/images?image=");			        				        	exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());			        	exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(0));			        				            exporter.exportReport();			            output = bufferedImageToByteArray(pageImage);	      public static byte[] bufferedImageToByteArray(BufferedImage img) throws IOException{	   	      ByteArrayOutputStream os = new ByteArrayOutputStream();	   	      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(os);	   	      encoder.encode(img);	   	      return os.toByteArray();	   	      }	 
×
×
  • Create New...