Class JasperRunManager


  • public final class JasperRunManager
    extends java.lang.Object
    Facade class for the JasperReports engine.

    Sometimes it is useful to produce documents only in a popular format such as PDF or HTML, without having to store on disk the serialized, intermediate JasperPrint object produced by the report-filling process.

    This can be achieved using this manager class, which immediately exports the document produced by the report-filling process into the desired output format.

    Author:
    Teodor Danciu (teodord@users.sourceforge.net)
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static JasperRunManager getInstance​(JasperReportsContext jasperReportsContext)  
      static void runReportToHtmlFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters)  
      static void runReportToHtmlFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)  
      static void runReportToHtmlFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)  
      static java.lang.String runReportToHtmlFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params)  
      static java.lang.String runReportToHtmlFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, java.sql.Connection conn)  
      static java.lang.String runReportToHtmlFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, JRDataSource jrDataSource)  
      static byte[] runReportToPdf​(java.io.InputStream inputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters)  
      static byte[] runReportToPdf​(java.io.InputStream inputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)  
      static byte[] runReportToPdf​(java.io.InputStream inputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)  
      static byte[] runReportToPdf​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters)  
      static byte[] runReportToPdf​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)  
      static byte[] runReportToPdf​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)  
      static byte[] runReportToPdf​(JasperReport jasperReport, java.util.Map<java.lang.String,​java.lang.Object> parameters)  
      static byte[] runReportToPdf​(JasperReport jasperReport, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)  
      static byte[] runReportToPdf​(JasperReport jasperReport, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)  
      static void runReportToPdfFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters)  
      static void runReportToPdfFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)  
      static void runReportToPdfFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)  
      static java.lang.String runReportToPdfFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params)  
      static java.lang.String runReportToPdfFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, java.sql.Connection conn)  
      static java.lang.String runReportToPdfFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, JRDataSource jrDataSource)  
      static void runReportToPdfStream​(java.io.InputStream inputStream, java.io.OutputStream outputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters)  
      static void runReportToPdfStream​(java.io.InputStream inputStream, java.io.OutputStream outputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)  
      static void runReportToPdfStream​(java.io.InputStream inputStream, java.io.OutputStream outputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)  
      void runToHtmlFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Fills a report and saves it directly into a HTML file.
      void runToHtmlFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)
      Fills a report and saves it directly into a HTML file.
      void runToHtmlFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)
      Fills a report and saves it directly into a HTML file.
      java.lang.String runToHtmlFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params)
      Fills a report and saves it directly into a HTML file.
      java.lang.String runToHtmlFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, java.sql.Connection conn)
      Fills a report and saves it directly into a HTML file.
      java.lang.String runToHtmlFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, JRDataSource jrDataSource)
      Fills a report and saves it directly into a HTML file.
      byte[] runToPdf​(java.io.InputStream inputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(java.io.InputStream inputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(java.io.InputStream inputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)
      Fills a report and sends it to an output stream in PDF format.
      byte[] runToPdf​(JasperReport jasperReport, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(JasperReport jasperReport, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)
      Fills a report and returns byte array object containing the report in PDF format.
      byte[] runToPdf​(JasperReport jasperReport, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)
      Fills a report and returns byte array object containing the report in PDF format.
      void runToPdfFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Fills a report and saves it directly into a PDF file.
      void runToPdfFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)
      Fills a report and saves it directly into a PDF file.
      void runToPdfFile​(java.lang.String sourceFileName, java.lang.String destFileName, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)
      Fills a report and saves it directly into a PDF file.
      java.lang.String runToPdfFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params)
      Fills a report and saves it directly into a PDF file.
      java.lang.String runToPdfFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, java.sql.Connection conn)
      Fills a report and saves it directly into a PDF file.
      java.lang.String runToPdfFile​(java.lang.String sourceFileName, java.util.Map<java.lang.String,​java.lang.Object> params, JRDataSource jrDataSource)
      Fills a report and saves it directly into a PDF file.
      void runToPdfStream​(java.io.InputStream inputStream, java.io.OutputStream outputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Fills a report and sends it directly to an OutputStream in PDF format.
      void runToPdfStream​(java.io.InputStream inputStream, java.io.OutputStream outputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, java.sql.Connection conn)
      Fills a report and sends it directly to an OutputStream in PDF format.
      void runToPdfStream​(java.io.InputStream inputStream, java.io.OutputStream outputStream, java.util.Map<java.lang.String,​java.lang.Object> parameters, JRDataSource jrDataSource)
      Fills a report and sends it directly to an OutputStream in PDF format.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • runToPdfFile

        public java.lang.String runToPdfFile​(java.lang.String sourceFileName,
                                             java.util.Map<java.lang.String,​java.lang.Object> params,
                                             java.sql.Connection conn)
                                      throws JRException
        Fills a report and saves it directly into a PDF file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdfFile

        public java.lang.String runToPdfFile​(java.lang.String sourceFileName,
                                             java.util.Map<java.lang.String,​java.lang.Object> params)
                                      throws JRException
        Fills a report and saves it directly into a PDF file. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        sourceFileName - the name of the compiled report file
        params - the parameters map
        Returns:
        the name of the generated PDF file
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToPdfFile

        public void runToPdfFile​(java.lang.String sourceFileName,
                                 java.lang.String destFileName,
                                 java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                 java.sql.Connection conn)
                          throws JRException
        Fills a report and saves it directly into a PDF file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdfFile

        public void runToPdfFile​(java.lang.String sourceFileName,
                                 java.lang.String destFileName,
                                 java.util.Map<java.lang.String,​java.lang.Object> parameters)
                          throws JRException
        Fills a report and saves it directly into a PDF file. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        sourceFileName - source file containing the compiled report design
        destFileName - PDF destination file name
        parameters - report parameters map
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToPdfStream

        public void runToPdfStream​(java.io.InputStream inputStream,
                                   java.io.OutputStream outputStream,
                                   java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                   java.sql.Connection conn)
                            throws JRException
        Fills a report and sends it directly to an OutputStream in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdfStream

        public void runToPdfStream​(java.io.InputStream inputStream,
                                   java.io.OutputStream outputStream,
                                   java.util.Map<java.lang.String,​java.lang.Object> parameters)
                            throws JRException
        Fills a report and sends it directly to an OutputStream in PDF format. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        inputStream - compiled report input stream
        outputStream - PDF output stream
        parameters - parameters map
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToPdf

        public byte[] runToPdf​(java.lang.String sourceFileName,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters,
                               java.sql.Connection conn)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdf

        public byte[] runToPdf​(java.lang.String sourceFileName,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        sourceFileName - source file containing the compiled report design
        parameters - report parameters map
        Returns:
        binary PDF output
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToPdf

        public byte[] runToPdf​(java.io.InputStream inputStream,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters,
                               java.sql.Connection conn)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdf

        public byte[] runToPdf​(java.io.InputStream inputStream,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        inputStream - input stream to read the compiled report design object from
        parameters - report parameters map
        Returns:
        binary PDF output
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToPdf

        public byte[] runToPdf​(JasperReport jasperReport,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters,
                               java.sql.Connection conn)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdf

        public byte[] runToPdf​(JasperReport jasperReport,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        jasperReport - the compiled report
        parameters - the parameters map
        Returns:
        binary PDF output
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToPdfFile

        public java.lang.String runToPdfFile​(java.lang.String sourceFileName,
                                             java.util.Map<java.lang.String,​java.lang.Object> params,
                                             JRDataSource jrDataSource)
                                      throws JRException
        Fills a report and saves it directly into a PDF file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdfFile

        public void runToPdfFile​(java.lang.String sourceFileName,
                                 java.lang.String destFileName,
                                 java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                 JRDataSource jrDataSource)
                          throws JRException
        Fills a report and saves it directly into a PDF file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdfStream

        public void runToPdfStream​(java.io.InputStream inputStream,
                                   java.io.OutputStream outputStream,
                                   java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                   JRDataSource jrDataSource)
                            throws JRException
        Fills a report and sends it directly to an OutputStream in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdf

        public byte[] runToPdf​(java.lang.String sourceFileName,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters,
                               JRDataSource jrDataSource)
                        throws JRException
        Fills a report and sends it to an output stream in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdf

        public byte[] runToPdf​(java.io.InputStream inputStream,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters,
                               JRDataSource jrDataSource)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToPdf

        public byte[] runToPdf​(JasperReport jasperReport,
                               java.util.Map<java.lang.String,​java.lang.Object> parameters,
                               JRDataSource jrDataSource)
                        throws JRException
        Fills a report and returns byte array object containing the report in PDF format. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToHtmlFile

        public java.lang.String runToHtmlFile​(java.lang.String sourceFileName,
                                              java.util.Map<java.lang.String,​java.lang.Object> params,
                                              java.sql.Connection conn)
                                       throws JRException
        Fills a report and saves it directly into a HTML file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToHtmlFile

        public java.lang.String runToHtmlFile​(java.lang.String sourceFileName,
                                              java.util.Map<java.lang.String,​java.lang.Object> params)
                                       throws JRException
        Fills a report and saves it directly into a HTML file. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        sourceFileName - the name of the compiled report file
        params - the parameters map
        Returns:
        the name of the generated HTML file
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToHtmlFile

        public void runToHtmlFile​(java.lang.String sourceFileName,
                                  java.lang.String destFileName,
                                  java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                  java.sql.Connection conn)
                           throws JRException
        Fills a report and saves it directly into a HTML file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToHtmlFile

        public void runToHtmlFile​(java.lang.String sourceFileName,
                                  java.lang.String destFileName,
                                  java.util.Map<java.lang.String,​java.lang.Object> parameters)
                           throws JRException
        Fills a report and saves it directly into a HTML file. The intermediate JasperPrint object is not saved on disk.
        Parameters:
        sourceFileName - source file containing the compiled report design
        destFileName - name of the destination HTML file
        parameters - report parameters map
        Throws:
        JRException
        See Also:
        JRFiller.fill(JasperReportsContext, JasperReport, Map)
      • runToHtmlFile

        public java.lang.String runToHtmlFile​(java.lang.String sourceFileName,
                                              java.util.Map<java.lang.String,​java.lang.Object> params,
                                              JRDataSource jrDataSource)
                                       throws JRException
        Fills a report and saves it directly into a HTML file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runToHtmlFile

        public void runToHtmlFile​(java.lang.String sourceFileName,
                                  java.lang.String destFileName,
                                  java.util.Map<java.lang.String,​java.lang.Object> parameters,
                                  JRDataSource jrDataSource)
                           throws JRException
        Fills a report and saves it directly into a HTML file. The intermediate JasperPrint object is not saved on disk.
        Throws:
        JRException
      • runReportToPdfFile

        public static java.lang.String runReportToPdfFile​(java.lang.String sourceFileName,
                                                          java.util.Map<java.lang.String,​java.lang.Object> params)
                                                   throws JRException
        Throws:
        JRException
        See Also:
        runToPdfFile(String, Map)
      • runReportToPdfFile

        public static void runReportToPdfFile​(java.lang.String sourceFileName,
                                              java.lang.String destFileName,
                                              java.util.Map<java.lang.String,​java.lang.Object> parameters)
                                       throws JRException
        Throws:
        JRException
        See Also:
        runToPdfFile(String, String, Map)
      • runReportToPdf

        public static byte[] runReportToPdf​(java.lang.String sourceFileName,
                                            java.util.Map<java.lang.String,​java.lang.Object> parameters)
                                     throws JRException
        Throws:
        JRException
        See Also:
        runToPdf(String, Map)
      • runReportToHtmlFile

        public static java.lang.String runReportToHtmlFile​(java.lang.String sourceFileName,
                                                           java.util.Map<java.lang.String,​java.lang.Object> params)
                                                    throws JRException
        Throws:
        JRException
        See Also:
        runToHtmlFile(String, Map)
      • runReportToHtmlFile

        public static void runReportToHtmlFile​(java.lang.String sourceFileName,
                                               java.lang.String destFileName,
                                               java.util.Map<java.lang.String,​java.lang.Object> parameters)
                                        throws JRException
        Throws:
        JRException
        See Also:
        runToHtmlFile(String, String, Map)