title: How to collate multiple jrxml jasper reports into a one single pdf output file
body: <p>I have to prepare reports using five different sql queries. Each query will give out one report table.</p>
  
  <p>So I wrote 5 jrxml files each corresponding to one of the above query with their own headings, title settings, footers, pagenumbers, etc.</p>
  
  <p>Now, I am able to compile, print and export each of the above jrxmls into 5 different pdfs. </p>
  
  <p>However, client wants all the reports collated into one single pdf. That is in the final pdf, first four pages will be say report one, next five pages report two, then report three and so on and so forth. </p>
  
  <p>1) How to achieve this ?</p>
  
  <p>2) Each report has page number as 1/4, 2/4, 3/4 etc. Where the second part i.e. the complete page number is evaluated with evaluation time as report. So when I will collate all reports in single pdf (if possible), will it also be possible to re-number the pages in justification to final pdf ?</p>
  
  <p>Based on the answer below, I did the following in my java class and it works:</p>
  
  <pre><code> try
              {
              JasperReport jreport1 = JasperCompileManager.compileReport(input1);
              JasperPrint jprint1 = JasperFillManager.fillReport(jreport1, new HashMap(), new JREmptyDataSource());
              //JasperExportManager.exportReportToPdfFile(jprint, "/home/ashutosh/Desktop/desktop/nikunj/JasperTestApp/output/mytest.pdf");
  
              JasperReport jreport2 = JasperCompileManager.compileReport(input2);
              JasperPrint jprint2 = JasperFillManager.fillReport(jreport2, new HashMap(), new JREmptyDataSource());
  
              JasperReport jreport3 = JasperCompileManager.compileReport(input3);
              JasperPrint jprint3 = JasperFillManager.fillReport(jreport3, new HashMap(), new JREmptyDataSource());
  
              List&lt;JasperPrint&gt; jprintlist = new ArrayList&lt;JasperPrint&gt;();
  
              jprintlist.add(jprint1);
              jprintlist.add(jprint2);
              jprintlist.add(jprint3);
  
              JRExporter exporter = new JRPdfExporter();
              exporter.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, jprintlist);
  
              OutputStream output = new FileOutputStream(new File("/home/ashutosh/Desktop/desktop/nikunj/JasperTestApp/output/mytestbatch.pdf"));
  
              exporter.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, output);
              exporter.exportReport();
  
              }catch(Exception e)
              {
                  e.printStackTrace();
              }
  </code></pre>
  
  <p>Above: input1, input2, input3 are string paths to input jrxmls</p>
  
  <p>Where my JRXML files just print three messages: Hello World 1, Hello World 2, Hello World 3. </p>
  
  <pre><code> &lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE jasperReport
    PUBLIC "-//JasperReports//DTD Report Design//EN"
    "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"&gt;
  
  &lt;jasperReport name="Simple_Report"&gt;
   &lt;detail&gt;
      &lt;band height="20"&gt;
        &lt;staticText&gt;
          &lt;reportElement x="180" y="0" width="200" height="20"/&gt;
          &lt;text&gt;&lt;![CDATA[Hello World One!]]&gt;&lt;/text&gt;
        &lt;/staticText&gt;
      &lt;/band&gt;
    &lt;/detail&gt;
  &lt;/jasperReport&gt;
  </code></pre>
  
  <p>Thanks for reading!  </p>