title: sub report starting in new page and adding extra page at end in PDF using jasper reports
body: <p>I am having a main report with three report groups. each report group header is having a sub report. when i generate the PDF file using the jasper report</p>
  
  <ol>
  <li>Its adding some blank space between the sub reports i.e., if the first sub report occupies more than 60% of the first page automatically the second sub report is starting in the new page.<br>
  I cant use ispageignoration because we will generate the pdf for
  multiple records where each record should start in new page.</li>
  <li>Its generating a blank page at the end just with the page header</li>
  </ol>
  
  <p>the text fields(value1, value2... value6) in second report may have max of 2000characters..</p>
  
  <p>can any one please help me.. </p>
  
  <p>Main Report report1.jrxml file
    <pre><Code></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="20" bottomMargin="20"&gt;
          &lt;parameter name="logoStream" class="java.awt.Image" isForPrompting="false"/&gt;
          &lt;parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"&gt;
              &lt;defaultValueExpression&gt;&lt;![CDATA["D:\\Other  Drive\\eHRM\\17365\\"]]&gt;&lt;/defaultValueExpression&gt;
          &lt;/parameter&gt;
          &lt;field name="id" class="java.lang.String"/&gt;
          &lt;field name="dataSource1" class="net.sf.jasperreports.engine.JRDataSource"/&gt;
          &lt;field name="dataSource2" class="net.sf.jasperreports.engine.JRDataSource"/&gt;
          &lt;field name="dataSource3" class="net.sf.jasperreports.engine.JRDataSource"/&gt;
          &lt;group name="Group1" isStartNewPage="true"&gt;
              &lt;groupExpression&gt;&lt;![CDATA[$F{id}]]&gt;&lt;/groupExpression&gt;
              &lt;groupHeader&gt;
                  &lt;band height="20"&gt;
                      &lt;subreport&gt;
                          &lt;reportElement x="-30" y="0" width="535" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;dataSourceExpression&gt;&lt;![CDATA[$F{dataSource1}]]&gt;&lt;/dataSourceExpression&gt;
                          &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + "/report1_subreport1.jasper"]]&gt;&lt;/subreportExpression&gt;
                      &lt;/subreport&gt;
                  &lt;/band&gt;
              &lt;/groupHeader&gt;
          &lt;/group&gt;
          &lt;group name="Group2"&gt;
              &lt;groupExpression&gt;&lt;![CDATA[$F{id}]]&gt;&lt;/groupExpression&gt;
              &lt;groupHeader&gt;
                  &lt;band height="20"&gt;
                      &lt;subreport&gt;
                          &lt;reportElement x="-30" y="0" width="535" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;dataSourceExpression&gt;&lt;![CDATA[$F{dataSource2}]]&gt;&lt;/dataSourceExpression&gt;
                          &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + "/report1_subreport2.jasper"]]&gt;&lt;/subreportExpression&gt;
                      &lt;/subreport&gt;
                  &lt;/band&gt;
              &lt;/groupHeader&gt;
          &lt;/group&gt;
          &lt;group name="group3"&gt;
              &lt;groupExpression&gt;&lt;![CDATA[$F{id}]]&gt;&lt;/groupExpression&gt;
              &lt;groupHeader&gt;
                  &lt;band height="20"&gt;
                      &lt;subreport&gt;
                          &lt;reportElement x="-30" y="0" width="535" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;dataSourceExpression&gt;&lt;![CDATA[$F{dataSource3}]]&gt;&lt;/dataSourceExpression&gt;
                          &lt;subreportExpression&gt;&lt;![CDATA[$P{SUBREPORT_DIR} + "/report1_subreport3.jasper"]]&gt;&lt;/subreportExpression&gt;
                      &lt;/subreport&gt;
                  &lt;/band&gt;
              &lt;/groupHeader&gt;
          &lt;/group&gt;
          &lt;background&gt;
              &lt;band splitType="Stretch"/&gt;
          &lt;/background&gt;
          &lt;pageHeader&gt;
              &lt;band height="50"&gt;
                  &lt;image&gt;
                      &lt;reportElement x="0" y="0" width="100" height="50"/&gt;
                      &lt;imageExpression&gt;&lt;![CDATA[(java.awt.Image)$P{logoStream}]]&gt;&lt;/imageExpression&gt;
                  &lt;/image&gt;
                  &lt;textField&gt;
                      &lt;reportElement x="510" y="0" width="20" height="20"/&gt;
                      &lt;textElement/&gt;
                      &lt;textFieldExpression&gt;&lt;![CDATA[$V{PAGE_NUMBER}.toString()]]&gt;&lt;/textFieldExpression&gt;
                  &lt;/textField&gt;
              &lt;/band&gt;
          &lt;/pageHeader&gt;
      &lt;/jasperReport&gt;
  </code></pre>
  
  <p></code></pre></p>
  
  <p>The Three subreports will be in same format as the below jrxml file</p>
  
  <p><pre><code></p>
  
  <pre><code>        &lt;?xml version="1.0" encoding="UTF-8"?&gt;
      &lt;jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1_subreport1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="30" rightMargin="30" topMargin="0" bottomMargin="0"&gt;
          &lt;field name="title1" class="java.lang.String"/&gt;
          &lt;field name="value1" class="java.lang.String"/&gt;
          &lt;field name="title2" class="java.lang.String"/&gt;
          &lt;field name="value2" class="java.lang.String"/&gt;
          &lt;field name="title3" class="java.lang.String"/&gt;
          &lt;field name="value3" class="java.lang.String"/&gt;
          &lt;field name="title4" class="java.lang.String"/&gt;
          &lt;field name="value4" class="java.lang.String"/&gt;
          &lt;field name="title5" class="java.lang.String"/&gt;
          &lt;field name="value5" class="java.lang.String"/&gt;
          &lt;field name="title6" class="java.lang.String"/&gt;
          &lt;field name="value6" class="java.lang.String"/&gt;
          &lt;background&gt;
              &lt;band splitType="Stretch"/&gt;
          &lt;/background&gt;
          &lt;detail&gt;
              &lt;band height="161" splitType="Stretch"&gt;
                  &lt;elementGroup&gt;
                      &lt;line&gt;
                          &lt;reportElement x="0" y="27" width="535" height="5" forecolor="#FFFFFF"&gt;
                              &lt;printWhenExpression&gt;&lt;![CDATA[($F{value2} == null || $F{value2}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]&gt;&lt;/printWhenExpression&gt;
                          &lt;/reportElement&gt;
                      &lt;/line&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="0" y="33" width="120" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{title2}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="120" y="33" width="415" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{value2}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                  &lt;/elementGroup&gt;
                  &lt;elementGroup&gt;
                      &lt;line&gt;
                          &lt;reportElement x="0" y="54" width="535" height="5" forecolor="#FFFFFF"&gt;
                              &lt;printWhenExpression&gt;&lt;![CDATA[($F{value3} == null || $F{value3}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]&gt;&lt;/printWhenExpression&gt;
                          &lt;/reportElement&gt;
                      &lt;/line&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="0" y="60" width="120" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{title3}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="120" y="60" width="415" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{value3}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                  &lt;/elementGroup&gt;
                  &lt;elementGroup&gt;
                      &lt;line&gt;
                          &lt;reportElement x="0" y="81" width="535" height="5" forecolor="#FFFFFF"&gt;
                              &lt;printWhenExpression&gt;&lt;![CDATA[($F{value4} == null || $F{value4}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]&gt;&lt;/printWhenExpression&gt;
                          &lt;/reportElement&gt;
                      &lt;/line&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="0" y="87" width="120" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{title4}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="120" y="87" width="415" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{value4}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                  &lt;/elementGroup&gt;
                  &lt;elementGroup&gt;
                      &lt;line&gt;
                          &lt;reportElement x="0" y="108" width="535" height="5" forecolor="#FFFFFF"&gt;
                              &lt;printWhenExpression&gt;&lt;![CDATA[($F{value5} == null || $F{value5}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]&gt;&lt;/printWhenExpression&gt;
                          &lt;/reportElement&gt;
                      &lt;/line&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="0" y="114" width="120" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{title5}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="120" y="114" width="415" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{value5}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                  &lt;/elementGroup&gt;
                  &lt;elementGroup&gt;
                      &lt;line&gt;
                          &lt;reportElement x="0" y="135" width="535" height="5" forecolor="#FFFFFF"&gt;
                              &lt;printWhenExpression&gt;&lt;![CDATA[($F{value6} == null || $F{value6}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]&gt;&lt;/printWhenExpression&gt;
                          &lt;/reportElement&gt;
                      &lt;/line&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="0" y="141" width="120" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{title6}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="120" y="141" width="415" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{value6}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                  &lt;/elementGroup&gt;
                  &lt;elementGroup&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="0" y="6" width="120" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{title1}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;textField isStretchWithOverflow="true" isBlankWhenNull="true"&gt;
                          &lt;reportElement x="120" y="6" width="415" height="20" isRemoveLineWhenBlank="true"/&gt;
                          &lt;textElement/&gt;
                          &lt;textFieldExpression&gt;&lt;![CDATA[$F{value1}]]&gt;&lt;/textFieldExpression&gt;
                      &lt;/textField&gt;
                      &lt;line&gt;
                          &lt;reportElement x="0" y="0" width="535" height="5" forecolor="#FFFFFF"&gt;
                              &lt;printWhenExpression&gt;&lt;![CDATA[($F{value1} == null || $F{value1}.equals( "" )) ? Boolean.FALSE : Boolean.TRUE]]&gt;&lt;/printWhenExpression&gt;
                          &lt;/reportElement&gt;
                      &lt;/line&gt;
                  &lt;/elementGroup&gt;
              &lt;/band&gt;
          &lt;/detail&gt;
      &lt;/jasperReport&gt;
  </code></pre>
  
  <p></code></pre></p>
  
  <p>A person may have n number of companies so i spited the company name, job profile, project description in to sub report.</p>
  
  <pre><code>---------------------------------------------------------------
  Name: XXX
  DOB: XX-XX-XXXX
  Personal Profile: (** this field may have 2000 characters****)
  Skill Sets : (** this also will have 2000 characters**)
  
  Professional Experience:
  
  Company name: XXXX
  Job Profile: (** this also will have 2000 characters**)
  Project Description :(** this also will have 2000 characters**)
  
  Company name: YYYYY
  Job Profile: (** this also will have 2000 characters**)
  Project Description :(** this also will have 2000 characters**)
  -----------------------------------------------------------------
  </code></pre>
  
  <p>my  requirement is to generate the PDf similar to it.</p>