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

kennethmch

Members
  • Posts

    2
  • Joined

  • Last visited

kennethmch's Achievements

Newbie

Newbie (1/14)

  • Week One Done
  • One Month Later
  • One Year In
  • First Post Rare

Recent Badges

0

Reputation

  1. Hi, sorry for posting another question here. I do not know the solution for your question, and im just wonder how did you embed the jfreechart into jasperreport? Can you please post some of your scriptlet, jrxml and your related java code? many thanks
  2. 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...