Insert a blank page between two OLE documents in Jasper report

0

Hello,

We have several OLE documents that are stocked in a database.

After declaring our datasource and <querystring> in our report, we use <subreport> with <subreportParameter name="oleObjectId"> in the <detail> section in order to print each document one after the other

Due to double sided printing, we need to add an empty blank page between each OLE documents, to be sure that all OLE documents will be printed in a separate sheet. For the now, two documents that are one page length are printed out on the same sheet whereas recipients are different physical persons.

How can we tell Jasper to add a blank page (two consecutive page breaks) between two OLE documents?

If anyone has an idea?

 

Matthias.delamare's picture
Joined: Jun 28 2019 - 3:46am
Last seen: 2 hours 14 min ago

FYI, I use Jasper Report v6.8.0

Matthias.delamare - 6 days 23 hours ago

7 Answers:

0

The detail section can contain multiple bands, so you could insert a second detail band that contains 2 Break elements with an empty Static Text element between them. See the attachment.

Attachments: 
AttachmentSize
Binary Data blank_a4_1.jrxml2 KB
shertage's picture
1932
Joined: Sep 26 2006 - 8:06pm
Last seen: 4 days 21 hours ago
0

Hello,

Thank you for your response. I tested your solution, but it does not provide the expected result. I put the custom message "Page let empty intentionally" in the text field, and the result is the following :

PAGE BREAK
Page let empty intentionally
PAGE BREAK
PAGE BREAK
Page let empty intentionally
PAGE BREAK
PAGE BREAK
Page let empty intentionally
PAGE BREAK

OLE DOCUMENT #1
PAGE BREAK
OLE DOCUMENT #2
PAGE BREAK
OLE DOCUMENT #3
PAGE BREAK
OLE DOCUMENT #4

How can I tell Jasper to execute elements in the expected order (DOC #1 then "Page let empty intentionally" then DOC #2 then "Page let empty intentionally", ...) ?

Matthias.delamare's picture
Joined: Jun 28 2019 - 3:46am
Last seen: 2 hours 14 min ago
0

Well, in this case it would be very useful if you could post your JRXML file here, in order to illustrate the report layout in your case.

Thank you,

Sanda

shertage's picture
1932
Joined: Sep 26 2006 - 8:06pm
Last seen: 4 days 21 hours ago
0

Ok. Here it is. I hid sensitive values with XXXXX and YYYYY

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="GET_ALL_LINKED_DOCUMENTS" pageWidth="612" pageHeight="842" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Empty" uuid="de603a7d-4403-4173-a4b9-61aecb96f406">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="XXXXX.xml"/>
    <parameter name="XXXXX_PARAM1" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
    </parameter>
    <parameter name="XXXXX_PARAM2" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
    </parameter>
    <parameter name="STYLE_TEMPLATE" class="java.net.URL" isForPrompting="false"/>
    <parameter name="RESOURCE_PATH" class="java.lang.String" isForPrompting="false"/>
    <queryString>
        <![CDATA[select OLE_OBJECT_ID from XXX where XXX=XXXXX_PARAM1 and YYY=XXXXX_PARAM2]]>
    </queryString>
    <field name="OLE_OBJECT_ID" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value="OLE_OBJECT_ID"/>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="50">
            <break>
                <reportElement x="0" y="0" width="99" height="1" uuid="3021991e-c925-4824-bded-d63f881cb0cc">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                </reportElement>
            </break>
            <staticText>
                <reportElement x="10" y="10" width="590" height="30" uuid="e46db91c-5d68-4247-a3fa-9b28b57b8fb0">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                </reportElement>
                <textElement textAlignment="Center">
                    <font size="14" isBold="false"/>
                </textElement>
                <text><![CDATA[Page let empty intentionally]]></text>
            </staticText>
            <break>
                <reportElement x="0" y="45" width="100" height="1" uuid="ea27cdf9-58ca-491e-be0c-7872b3cfdbbd">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                </reportElement>
            </break>
        </band>
        <band height="20" splitType="Stretch">
            <subreport isUsingCache="true" runToBottom="true">
                <reportElement positionType="Float" mode="Transparent" x="0" y="0" width="612" height="20" isRemoveLineWhenBlank="true" uuid="b41ae55d-d96a-4a8e-8854-afa8f8db4904">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <subreportParameter name="oleObjectId">
                    <subreportParameterExpression><![CDATA[$F{OLE_OBJECT_ID}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="STYLE_TEMPLATE">
                    <subreportParameterExpression><![CDATA[$P{STYLE_TEMPLATE}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="RESOURCE_PATH">
                    <subreportParameterExpression><![CDATA[$P{RESOURCE_PATH}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA[LOADSUB("GenericSubreportOleAttachment.jasper")]]></subreportExpression>
            </subreport>
        </band>
    </detail>
</jasperReport>

And the GenericSubreportOleAttachment.jasper file :

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="GenericSubreportOleAttachment" pageWidth="612" pageHeight="792" columnWidth="572" leftMargin="0" rightMargin="40" topMargin="0" bottomMargin="0" whenResourceMissingType="Key" uuid="d05f9809-412a-46c1-8be6-02664ba8332b">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="XXXXX.xml"/>
    <parameter name="oleObjectId" class="java.lang.String">
        <parameterDescription><![CDATA[OLE Object ID]]></parameterDescription>
    </parameter>
    <parameter name="STYLE_TEMPLATE" class="java.net.URL" isForPrompting="false"/>
    <parameter name="RESOURCE_PATH" class="java.lang.String" isForPrompting="false"/>
    <parameter name="documentLoaded" class="java.lang.Boolean" isForPrompting="false">
        <parameterDescription><![CDATA[Loaded Flag]]></parameterDescription>
        <defaultValueExpression><![CDATA[LOADDOCUMENT($P{oleObjectId})]]></defaultValueExpression>
    </parameter>
    <queryString language="SQL">
        <![CDATA[select $P{oleObjectId}
from dual]]>
    </queryString>
    <field name=":1" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value=":1"/>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
</jasperReport>

Matthias.delamare's picture
Joined: Jun 28 2019 - 3:46am
Last seen: 2 hours 14 min ago
0

Thank you. The detail band with the Break elements needs to be placed after the band containing the subreport in the JRXML. Something like:

    <detail>
        <band height="20" splitType="Stretch">
            <subreport isUsingCache="true" runToBottom="true">
                ...
            </subreport>
        </band>
        <band height="50"> 
           <break> 
                ... 
           </break> 
           <staticText> 
                ... 
           </staticText> 
           <break> 
                ... 
           </break> 
      </band> 
   </detail>

shertage's picture
1932
Joined: Sep 26 2006 - 8:06pm
Last seen: 4 days 21 hours ago
0

Ok, I inverted the two <band> elements, but it does not changes anything, I always have all the blank pages ("Page let empty intentionally") then all OLE documents after.

Here is my code now : 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="GET_ALL_LINKED_DOCUMENTS" pageWidth="612" pageHeight="842" columnWidth="612" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" whenResourceMissingType="Empty" uuid="de603a7d-4403-4173-a4b9-61aecb96f406">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="net.sf.jasperreports.print.create.bookmarks" value="false"/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="XXXXX.xml"/>
    <parameter name="XXXXX_PARAM1" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
    </parameter>
    <parameter name="XXXXX_PARAM2" class="java.lang.String" isForPrompting="false">
        <parameterDescription><![CDATA[]]></parameterDescription>
    </parameter>
    <parameter name="STYLE_TEMPLATE" class="java.net.URL" isForPrompting="false"/>
    <parameter name="RESOURCE_PATH" class="java.lang.String" isForPrompting="false"/>
    <queryString>
        <![CDATA[select OLE_OBJECT_ID from XXX where XXX=XXXXX_PARAM1 and YYY=XXXXX_PARAM2]]>
    </queryString>
    <field name="OLE_OBJECT_ID" class="java.lang.String">
        <property name="com.jaspersoft.studio.field.label" value="OLE_OBJECT_ID"/>
    </field>
    <background>
        <band splitType="Stretch"/>
    </background>
    <detail>
        <band height="20" splitType="Stretch">
            <subreport isUsingCache="true" runToBottom="true">
                <reportElement positionType="Float" mode="Transparent" x="0" y="0" width="612" height="20" isRemoveLineWhenBlank="true" uuid="b41ae55d-d96a-4a8e-8854-afa8f8db4904">
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <subreportParameter name="oleObjectId">
                    <subreportParameterExpression><![CDATA[$F{OLE_OBJECT_ID}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="STYLE_TEMPLATE">
                    <subreportParameterExpression><![CDATA[$P{STYLE_TEMPLATE}]]></subreportParameterExpression>
                </subreportParameter>
                <subreportParameter name="RESOURCE_PATH">
                    <subreportParameterExpression><![CDATA[$P{RESOURCE_PATH}]]></subreportParameterExpression>
                </subreportParameter>
                <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                <subreportExpression><![CDATA[LOADSUB("GenericSubreportOleAttachment.jasper")]]></subreportExpression>
            </subreport>
        </band>
        <band height="50">
            <break>
                <reportElement x="0" y="0" width="99" height="1" uuid="3021991e-c925-4824-bded-d63f881cb0cc">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                </reportElement>
            </break>
            <staticText>
                <reportElement x="10" y="10" width="590" height="30" uuid="e46db91c-5d68-4247-a3fa-9b28b57b8fb0">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                </reportElement>
                <textElement textAlignment="Center">
                    <font size="14" isBold="false"/>
                </textElement>
                <text><![CDATA[Page let empty intentionally]]></text>
            </staticText>
            <break>
                <reportElement x="0" y="45" width="100" height="1" uuid="ea27cdf9-58ca-491e-be0c-7872b3cfdbbd">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                </reportElement>
            </break>
        </band>
    </detail>
</jasperReport>

Any idea?

Matthias.delamare's picture
Joined: Jun 28 2019 - 3:46am
Last seen: 2 hours 14 min ago
0

Hello, do you have an idea to fix the issue? I just want to add two page breaks between two OLE documents. See the code above.

Matthias.delamare's picture
Joined: Jun 28 2019 - 3:46am
Last seen: 2 hours 14 min ago
Feedback
randomness