Package net.sf.jasperreports.engine

Examples of net.sf.jasperreports.engine.JRExporter


    ByteArrayOutputStream output = new ByteArrayOutputStream();

    try {

      JRExporter exporter = setup();
      exporter.setParameters(parameters);
      exporter.setParameter(JRExporterParameter.JASPER_PRINT, print.get(0));

      BufferedImage image = getPageImage(print.get(0));
      exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, image.getGraphics());
      exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, zoom);
      exporter.setParameter(JRExporterParameter.PAGE_INDEX, page);
      exporter.exportReport();

      ImageIO.write(image, format, output);
      return output.toByteArray();

    } catch (JRException e) {
View Full Code Here


   
    ByteArrayOutputStream output = new ByteArrayOutputStream();
 
    try {
     
      JRExporter exporter = setup();
      exporter.setParameters(getParameters());
     
      if (print.size() > 1)
        exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, print);
      else
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, print.get(0));
     
      exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, output);
      exporter.exportReport();
      Flushables.flushQuietly(output);
      return output.toByteArray()
     
    } catch (JRException e) {
      throw new RuntimeException(e);
View Full Code Here

                }

                response.setHeader("Content-disposition", tmp.toString());
            }

            JRExporter exporter;

            if (format.equals(FORMAT_PDF)) {
                response.setContentType("application/pdf");
                exporter = new JRPdfExporter();
            } else if (format.equals(FORMAT_CSV)) {
                response.setContentType("text/plain");
                exporter = new JRCsvExporter();
            } else if (format.equals(FORMAT_HTML)) {
                response.setContentType("text/html");

                // IMAGES_MAPS seems to be only supported as "backward compatible" from JasperReports 1.1.0

                Map imagesMap = new HashMap();
                request.getSession(true).setAttribute("IMAGES_MAP", imagesMap);

                exporter = new JRHtmlExporter();
                exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
                exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

                // Needed to support chart images:
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
                request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", jasperPrint);
            } else if (format.equals(FORMAT_XLS)) {
                response.setContentType("application/vnd.ms-excel");
                exporter = new JRXlsExporter();
            } else if (format.equals(FORMAT_XML)) {
                response.setContentType("text/xml");
                exporter = new JRXmlExporter();
            } else if (format.equals(FORMAT_RTF)) {
                response.setContentType("application/rtf");
                exporter = new JRRtfExporter();
            } else {
                throw new ServletException("Unknown report format: " + format);
            }

            Map exportParams = (Map) stack.findValue(exportParameters);
            if (exportParams != null) {
                LOG.debug("Found export parameters; adding to exporter parameters...");
                exporter.getParameters().putAll(exportParams);
            }

            output = exportReportToBytes(jasperPrint, exporter);
        } catch (JRException e) {
            String message = "Error producing " + format + " report for uri " + systemId;
View Full Code Here

    private static final int PAGES_THRESHHOLD = 2;

    private static final ReportWriterFactory INSTANCE = new ReportWriterFactory();

    public ReportWriter getReportWriter(final JasperPrint _jasperPrint, final String _format, final Map _parameters) {
        final JRExporter exporter = FormatInfoRegistry.getInstance().getExporter(_format);
        exporter.setParameters(_parameters);
        if (_jasperPrint.getPages().size() > PAGES_THRESHHOLD) {
            return new FileReportWriter(_jasperPrint, exporter);
        } else {
            return new MemoryReportWriter(_jasperPrint, exporter);
        }
View Full Code Here

        return ((FormatInfo)FORMAT_INFO.get(_format)).getContentType();
    }

    public JRExporter getExporter(final String _format) {
        checkFormat(_format);
        final JRExporter exporter = ((FormatInfo)FORMAT_INFO.get(_format)).getExporterInstance();
        exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        return exporter;
    }
View Full Code Here

        final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, documentFormat, parameters);

        if (FORMAT_HTML.equals(documentFormat)) {
          Map imagesMap = new HashMap();
          JRExporter exporter = reportWriter.getExporter();
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, _request.getContextPath() + imageServletUrl);
          // Needed to support chart images:
          exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
          _request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);
        }

        reportWriter.writeTo(_response);
    }
View Full Code Here

        final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, documentFormat, parameters);

        if (FORMAT_HTML.equals(documentFormat)) {
          Map imagesMap = new HashMap();
          JRExporter exporter = reportWriter.getExporter();
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
          exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, _request.getContextPath() + imageServletUrl);
          // Needed to support chart images:
          exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
          _request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);
        }

        reportWriter.writeTo(_response);
    }
View Full Code Here

    private static final int PAGES_THRESHHOLD = 2;

    private static final ReportWriterFactory INSTANCE = new ReportWriterFactory();

    public ReportWriter getReportWriter(final JasperPrint _jasperPrint, final String _format, final Map _parameters) {
        final JRExporter exporter = FormatInfoRegistry.getInstance().getExporter(_format);
        exporter.setParameters(_parameters);

        if (_jasperPrint.getPages().size() > PAGES_THRESHHOLD) {
            return new FileReportWriter(_jasperPrint, exporter);
        } else {
            return new MemoryReportWriter(_jasperPrint, exporter);
View Full Code Here

        return ((FormatInfo)FORMAT_INFO.get(_format)).getContentType();
    }

    public JRExporter getExporter(final String _format) {
        checkFormat(_format);
        final JRExporter exporter = ((FormatInfo)FORMAT_INFO.get(_format)).getExporterInstance();
        exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        return exporter;
    }
View Full Code Here

    JasperPrint _jasperPrint = generateJasperPrint(dynamicReport, layoutManager, ds,parameters);
    final ReportWriter reportWriter = ReportWriterFactory.getInstance().getReportWriter(_jasperPrint, JasperReportConstants.FORMAT_HTML, parameters);
    parameters.put(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);

    Map imagesMap = new HashMap();
        JRExporter exporter = reportWriter.getExporter();
        exporter.setParameters(exporterParams);

        exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);
        exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, request.getContextPath() + imageServletUrl);
        // Needed to support chart images:
        exporter.setParameter(JRExporterParameter.JASPER_PRINT, _jasperPrint);
        request.getSession().setAttribute("net.sf.jasperreports.j2ee.jasper_print", _jasperPrint);

    //write generated HTML to the http-response (the one you got from the helper)
        reportWriter.writeTo(response);
  }
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.engine.JRExporter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.