Jump to content
We've recently updated our Privacy Statement, available here ×

subreport overflows the page width when used in main report


lorenzo.brito

Recommended Posts

If I preview the subreport individualy, it respects the width  page size, but when it is embbeded in a main report, it overflows the page , as you can see 

difference.png.0046f4f3427230832d3bf5f8e1cbc236.png

--------------------- main report -----------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.19.0.final using JasperReports Library version 6.19.0-646c68931cebf1a58bc65c4359d1f0ca223c5e94  -->
<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="mainreport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="15617b9c-2c80-4382-8940-3ef863d8dc21">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="sampledata"/>
    <queryString language="JSON">
        <![CDATA[sampledata]]>
    </queryString>
    <field name="text1" class="java.lang.String">
        <property name="net.sf.jasperreports.json.field.expression" value="text1"/>
        <fieldDescription><![CDATA[text1]]></fieldDescription>
    </field>
    <field name="subreport" class="java.lang.String">
        <property name="net.sf.jasperreports.json.field.expression" value="subreport"/>
        <fieldDescription><![CDATA[subreport]]></fieldDescription>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="210" y="20" width="100" height="30" uuid="c0776897-ce67-4b63-8614-7ef5a5195920"/>
                <text><![CDATA[Main report]]></text>
            </staticText>
        </band>
    </title>
    <detail>
        <band height="275" splitType="Stretch">
            <subreport>
                <reportElement x="0" y="10" width="460" height="200" uuid="66d1d2f2-43e7-483b-bfde-496605594a12"/>
                <subreportParameter name="REPORT_DATA_SOURCE">
                    <subreportParameterExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("subreport")]]></subreportParameterExpression>
                </subreportParameter>
                <subreportExpression><![CDATA["subreport.jasper"]]></subreportExpression>
            </subreport>
        </band>
    </detail>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
 

-----

--------- sub report   -------------

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.19.0.final using JasperReports Library version 6.19.0-646c68931cebf1a58bc65c4359d1f0ca223c5e94  -->
<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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1d8a8cbf-ade7-44a8-8225-bdfd49f5f2f2">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="sampledata"/>
    <queryString language="JSON">
        <![CDATA[sampledata.subreport]]>
    </queryString>
    <field name="textsupreport" class="java.lang.String">
        <property name="net.sf.jasperreports.json.field.expression" value="textsupreport"/>
        <fieldDescription><![CDATA[textsupreport]]></fieldDescription>
    </field>
    <detail>
        <band height="125" splitType="Stretch">
            <staticText>
                <reportElement mode="Opaque" x="0" y="2" width="555" height="18" forecolor="#FFFFFF" backcolor="#787777" uuid="7e5e2de5-05c9-4c38-8c32-9fc8a8d3be85"/>
                <text><![CDATA[subreport]]></text>
            </staticText>
            <textField>
                <reportElement x="121" y="63" width="100" height="30" uuid="93605355-8fa4-477f-b41f-96dfc836ae4d"/>
                <textFieldExpression><![CDATA[$F{textsupreport}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="21" y="63" width="100" height="30" uuid="e7cb2bc1-a62c-4947-983b-ee022132042b"/>
                <text><![CDATA[text1]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>

 

 

---------------------

 

 

 

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

As C-Box says, we dont have to use margins in the subreport. 

 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.19.0.final using JasperReports Library version 6.19.0-646c68931cebf1a58bc65c4359d1f0ca223c5e94  -->
<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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="595" leftMargin="0" rightMargin="0" topMargin="20" bottomMargin="20" uuid="1d8a8cbf-ade7-44a8-8225-bdfd49f5f2f2">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="sampledata"/>
    <queryString language="JSON">
        <![CDATA[sampledata.subreport]]>
    </queryString>
    <field name="textsupreport" class="java.lang.String">
        <property name="net.sf.jasperreports.json.field.expression" value="textsupreport"/>
        <fieldDescription><![CDATA[textsupreport]]></fieldDescription>
    </field>
    <detail>
        <band height="125" splitType="Stretch">
            <staticText>
                <reportElement mode="Opaque" x="0" y="2" width="595" height="18" forecolor="#FFFFFF" backcolor="#787777" uuid="7e5e2de5-05c9-4c38-8c32-9fc8a8d3be85"/>
                <text><![CDATA[subreport 2.0]]></text>
            </staticText>
            <textField>
                <reportElement x="121" y="63" width="100" height="30" uuid="93605355-8fa4-477f-b41f-96dfc836ae4d"/>
                <textFieldExpression><![CDATA[$F{textsupreport}]]></textFieldExpression>
            </textField>
            <staticText>
                <reportElement x="21" y="63" width="100" height="30" uuid="e7cb2bc1-a62c-4947-983b-ee022132042b"/>
                <text><![CDATA[text1]]></text>
            </staticText>
        </band>
    </detail>
</jasperReport>
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...