Search code examples
jasper-reports

jasper subreport blank new page


I made a jasper file and it shows a new page, there will be a blank page, please tell me how to fix it.

I use iReport-5.6.0 to modify it.

enter image description here

Main (part of the sub report)

<band height="109" splitType="Immediate">
            
            <subreport>
                <reportElement style="style_detail" positionType="Float" x="0" y="31" width="445" height="23" uuid="8d1ddd6f-a366-4634-bc00-eea444fa9920"/>
                <subreportParameter name="ENDTEXT1">
                    <subreportParameterExpression><![CDATA[$P{ENDTEXT1}]]></subreportParameterExpression>
                </subreportParameter>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{letterTransList4})]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "subreport1.jasper"]]></subreportExpression>
            </subreport>
    
        </band>

Sub Report

<?xml version="1.0" encoding="UTF-8"?>
<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="correspondenceReportPOABG_subreport1" pageWidth="444" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="444" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="7e2bd990-3814-4075-a5f2-e4d4a29b5bad">
    <property name="ireport.zoom" value="1.5"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="0"/>
    <property name="net.sf.jasperreports.export.docx.flexible.row.height" value="true"/>
    <style name="style_header" hAlign="Left" vAlign="Top" fontName="" fontSize="15"/>
    <style name="style_detail" hAlign="Left" vAlign="Top" fontName="" fontSize="14" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false">
        <paragraph lineSpacing="Single"/>
    </style>
    <parameter name="ENDTEXT1" class="java.lang.String"/>
    <field name="detail" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="1" splitType="Stretch"/>
    </title>
    <pageHeader>
        <band splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="21" splitType="Immediate">
            <textField isStretchWithOverflow="true">
                <reportElement style="style_detail" positionType="Float" x="0" y="0" width="444" height="21" uuid="186ec40e-42e2-488a-a21c-a5bba58c0e90"/>
                <textElement markup="none">
                    <paragraph lineSpacing="Single"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{detail}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <columnFooter>
        <band splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band splitType="Immediate"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

I made a jasper file and it shows a new page, there will be a blank page, please tell me how to fix it.

I want no blank pages. How should I set it up?

I use iReport-5.6.0 to modify it.


Solution

  • The page format on your subreport is currently set to pageHeight="802" which equals one full A4 page and that's why it's using a full page in your main report.

    I'd recommend adjusting the page format of the subreport to match the allocated space in the main report.