diegoqueres81 Posted May 7, 2019 Share Posted May 7, 2019 I'm developing prototypes of memory games on Jasper Studio.I would like to generate a report with the following structure:Page 1: Images and labels of the cards;Page 2: Background side of the cards on page 1;Page 3: Images and labels of the cards;Page 4: Background side of the cards on page 3;........................................................................................... A random example: Printing the report, each page must have printed in both sides.Front side of page: cards with images and texts Back side of page: background of the memory cards I want generate pdf reports that users will print first page, turn the paper in printer, and then they will print the back of the sheet with the background of the cards.I was able to generate the cards already. But generating the background of the cards on the next sheet, I'm having troubles yet. Anyone can help? Link to comment Share on other sites More sharing options...
hozawa Posted May 8, 2019 Share Posted May 8, 2019 Have you tried putting each page as a subreport and putting a page break in between? Link to comment Share on other sites More sharing options...
diegoqueres81 Posted May 9, 2019 Author Share Posted May 9, 2019 I tried it now. The first page appears normal, the cover of the cards. but on the following pages, both subreports content overflow each other...What i do to avoid this?subreport 1 (cover)breaksubreport 2 (back)break Link to comment Share on other sites More sharing options...
C-Box Posted May 9, 2019 Share Posted May 9, 2019 have you set the POSITIONTYPE of the second subreport element and also the break-elements to FLOAT? Or is it still "FixRelativeToTop"? If so, just change it to "FLOAT".If you put the second break behind the second subreport element, you always will get an empty page at the end, as the report won't know that the records are consumed/finished... so I guess, this isn't wanted. actually I think, you wouldn't need a break element at all, as you also could use "RunToBottom" flag on both subReports - of course depending on your structure... so the first one will render your first cards and consume all the page height. now the second one will render your background elements, also consuming all the available page height, and so on... just give it a try.Unfortunately I can't look at my "alternate duplex background sample", as this was done for a customer at my old company that was printing his general terms always on background of odd pages :-(hth + regards from Dresden/GermanyC-Box Link to comment Share on other sites More sharing options...
diegoqueres81 Posted May 9, 2019 Author Share Posted May 9, 2019 I tried your suggestions, C-Box.Now it's showing all pages of the first subreport. and after that, displays all the pages of the second subreport.It's close of what I want, but what I want is similar about you described: a page with the front of the cards, the next page with the background of the cards, and so on. I tried of this way now:subreport 1 (cover)breaksubreport 2 (back) Detail band code: <detail> <band height="4" splitType="Stretch"> <subreport isUsingCache="true" runToBottom="true"> <reportElement x="0" y="0" width="830" height="1" isRemoveLineWhenBlank="true" uuid="b0b2b69f-f856-434e-889a-97c30a0cb469"/> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["Memory Game/MemoryGame_Cover.jasper"]]></subreportExpression> </subreport> <break> <reportElement x="0" y="2" width="99" height="1" uuid="4d467dc2-c55d-417a-8e4e-3c555b472d8f"/> </break> <subreport isUsingCache="true" runToBottom="true"> <reportElement positionType="Float" x="0" y="3" width="830" height="1" isRemoveLineWhenBlank="true" uuid="988c7e01-ad93-4e20-a466-db3b094d239b"/> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["Memory Game/MemoryGame_Back.jasper"]]></subreportExpression> </subreport> </band> </detail> I have tried without break element, and i get the same result. Link to comment Share on other sites More sharing options...
C-Box Posted May 9, 2019 Share Posted May 9, 2019 Well I tried to remind what I've done some years ago for customer... as I said, I can't access the orginal jrxml as I changed the company.So take a look at the sample attached. Run the Main Report with e.g. 27 empty records (so I used just an empty datasource for testing). The BackSide SubReport is also hardcoded with 9 emtpy records.. but I think you will manage to adapt it to your report/data ;-)hth + regards from Dresden/GermanyC-Box Main 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="Mainreport" language="groovy" columnCount="3" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="185" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0" uuid="1a26a677-f7eb-4378-8aae-5c6e04188dfc"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA[""]]></defaultValueExpression> </parameter> <group name="DummyDuplex" isStartNewColumn="true"/> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="10"> <printWhenExpression><![CDATA[$V{PAGE_NUMBER} %2 == 0]]></printWhenExpression> <subreport isUsingCache="false" runToBottom="false"> <reportElement x="-20" y="0" width="595" height="5" uuid="76e6c0d9-47c9-4143-a7ba-2d6511e5c907"/> <dataSourceExpression><![CDATA[new JREmptyDataSource(9)]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SR_BackSide.jasper"]]></subreportExpression> </subreport> </band> </pageHeader> <detail> <band height="260" splitType="Stretch"> <rectangle radius="5"> <reportElement mode="Opaque" x="0" y="0" width="185" height="260" backcolor="#CCCCFF" uuid="66930a98-e323-4fd3-ae34-442e605217fd"/> </rectangle> <textField> <reportElement x="0" y="90" width="170" height="80" uuid="0d823d88-f4ee-4bd7-b4cf-b4312d659b1b"/> <textElement textAlignment="Center"> <font size="18" isBold="true"/> </textElement> <textFieldExpression><![CDATA["Card: #"+$V{REPORT_COUNT}]]></textFieldExpression> </textField> <textField> <reportElement x="38" y="189" width="100" height="20" uuid="77012025-136d-4fec-8360-947bf0170161"/> <textFieldExpression><![CDATA["ColumnNumber:"+$V{COLUMN_NUMBER}]]></textFieldExpression> </textField> <textField> <reportElement x="38" y="209" width="100" height="20" uuid="f2ddaf54-12d2-4a88-a2c8-bdd49ac2b3aa"/> <textFieldExpression><![CDATA["ColumnCount: "+$V{COLUMN_COUNT}]]></textFieldExpression> </textField> <textField> <reportElement x="38" y="229" width="100" height="20" uuid="f52bd9a2-7934-4df1-b3ad-6ba8f7916254"/> <textFieldExpression><![CDATA["ReportCount: "+$V{REPORT_COUNT}]]></textFieldExpression> </textField> <textField> <reportElement x="38" y="170" width="100" height="20" uuid="2e478e5d-f0b2-4424-8150-8c24dd3579aa"/> <textFieldExpression><![CDATA["ModDiv: "+ $V{REPORT_COUNT} % 9 ]]></textFieldExpression> </textField> </band> </detail> <summary> <band height="5"> <subreport isUsingCache="false" runToBottom="false"> <reportElement x="-20" y="0" width="595" height="5" uuid="012baf97-aa0f-4a4e-be92-5090d2576fd0"/> <dataSourceExpression><![CDATA[new JREmptyDataSource(9)]]></dataSourceExpression> <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SR_BackSide.jasper"]]></subreportExpression> </subreport> </band> </summary></jasperReport> 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="SR_BackSide" language="groovy" columnCount="3" printOrder="Horizontal" pageWidth="595" pageHeight="842" columnWidth="185" leftMargin="20" rightMargin="20" topMargin="0" bottomMargin="0" uuid="954c6aa1-8b06-4e1e-90be-5cc90a03b216"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <background> <band splitType="Stretch"/> </background> <detail> <band height="260" splitType="Stretch"> <rectangle radius="5"> <reportElement x="0" y="0" width="185" height="260" backcolor="#CCCCCC" uuid="5ad90a00-37cc-4a26-9514-6c297ad8fd2f"/> </rectangle> <textField> <reportElement x="29" y="64" width="128" height="133" uuid="63578029-2122-4f5b-9be0-caeb0bdafdd5"/> <textElement textAlignment="Center"> <font size="18" isItalic="true"/> </textElement> <textFieldExpression><![CDATA["BackSide: #"+$V{REPORT_COUNT}]]></textFieldExpression> </textField> </band> </detail></jasperReport> Link to comment Share on other sites More sharing options...
diegoqueres81 Posted May 10, 2019 Author Share Posted May 10, 2019 I followed your model. And it helped me a lot, thank you!I made some improvements and adjusted to my cards. Two parameters to improve controlI create two parameters to have some control over subreports: <parameter name="CARDS_BY_PAGE" class="java.lang.Integer" isForPrompting="false"> <defaultValueExpression><![CDATA[12]]></defaultValueExpression> </parameter> <parameter name="CARDS_BY_COLUMN" class="java.lang.Integer" isForPrompting="false"> <defaultValueExpression><![CDATA[1]]></defaultValueExpression> </parameter>CARDS_BY_COLUMN because, in some cases, i will want print 1 or 2 cards by column (i will do more than one game). Page Header <pageHeader> <band height="1"> <printWhenExpression><![CDATA[$V{PAGE_NUMBER} %2 == 0]]></printWhenExpression> <subreport> <reportElement x="0" y="0" width="200" height="1" uuid="676dfca8-d693-4789-b92e-5707343a1b62"/> <subreportParameter name="PATH"> <subreportParameterExpression><![CDATA[$P{PATH}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="LANG1"> <subreportParameterExpression><![CDATA[$P{LANG1}]]></subreportParameterExpression> </subreportParameter> <subreportParameter name="LIMIT"> <subreportParameterExpression><![CDATA[$P{CARDS_BY_PAGE}]]></subreportParameterExpression> </subreportParameter> <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> <subreportExpression><![CDATA["Memory Game/MemoryGame_Back.jasper"]]></subreportExpression> </subreport> </band> </pageHeader> Config summary to reportI have configured two properties on Jasper Report tagisSummaryNewPage="true"isSummaryWithPageHeaderAndFooter="true" On subreport, i limit the records who will be showed (avoid overflow more than one page - on page header)<filterExpression><![CDATA[$V{REPORT_COUNT} <= $P{LIMIT}]]></filterExpression> So.. I have to improve more, after tests: how it is showing with one page of cards, with cards filling more or less lines, ...But in some tests it's already working as I expected. Thank you very much! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now