Hello,
I want to print my report to pdf and it did already work though I got an 
OutOfMemoryException.
Then I found some posts where the JRVirtualizer was mentioned and played a 
bit with it. But it did not really work and I erased it from my code.
Now I can't get the report to work properly anymore. I can only get it to 
work with one item but if I want to add more rows I get the OutOfMemory 
Exception again.
It doesn't make much sense to me and I can't really get my hand on what is 
really wrong.
Hope someone can point me in the right way!
Thanks a lot!
Karola

Here's a bit of code:

The method printing the report to pdf:

public void generatePDF(JobChart jobChart) throws IOException, JRException 
{
        Object[] objects = new Object[]{jobChart};
 
        Map parameters = new HashMap();
 
        ...
        response.setContentType("application/pdf");
 
        JasperRunManager.runReportToPdfStream(
 getClass().getClassLoader().getResourceAsStream("MasterJobChart.jasper"),
                response.getOutputStream(),
                parameters,
                new JRBeanArrayDataSource(objects)
        );
}

The MasterReport with the problematic subreport in the detail band:

<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "
http://jasperreports.sourceforge.net/dtds/jasperreport.dtd";>
<jasperReport
                 name="MasterJobChart"
                 columnCount="1"
                 printOrder="Vertical"
                 orientation="Landscape"
                 pageWidth="2168"
                 pageHeight="1100"
                 columnWidth="2090"
                 columnSpacing="0"
                 leftMargin="40"
                 rightMargin="38"
                 topMargin="20"
                 bottomMargin="20"
                 whenNoDataType="NoPages"
                 isTitleNewPage="false"
                 isSummaryNewPage="false">
        <property name="ireport.scriptlethandling" value="0" />
        <property name="ireport.encoding" value="UTF-8" />
        <import value="java.util.*" />
        <import value="net.sf.jasperreports.engine.*" />
        <import value="net.sf.jasperreports.engine.data.*" />

        <field name="jobs" class="java.util.Collection"/>
        <field name="calendar" class="java.util.Collection"/>

                <columnHeader>
                        <band height="40"  isSplitAllowed="true" >
                                ...
                                <subreport  isUsingCache="true">
                                        <reportElement
                                                x="240"
                                                y="26"
                                                width="1849"
                                                height="14"
                                                key="subreport-1"
 isRemoveLineWhenBlank="true"/>
                                        <dataSourceExpression><![CDATA[new 
net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((Collection) 
$F{calendar})]]></dataSourceExpression>
                                        <subreportExpression 
class="java.lang.String"><![CDATA["Calendar.jasper"]]></subreportExpression>
                                </subreport>
                                ...
                        </band>
                </columnHeader>
                <detail>
                        <band height="1020"  isSplitAllowed="true" >
                                <subreport  isUsingCache="true">
                                        <reportElement
                                                x="0"
                                                y="0"
                                                width="2090"
                                                height="7"
                                                key="subreport-2"
 isPrintWhenDetailOverflows="true"/>
                                        <dataSourceExpression><![CDATA[new 
net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((Collection) 
$F{jobs})]]></dataSourceExpression>
                                        <subreportExpression 
class="java.lang.String"><![CDATA["JobChart.jasper"]]></subreportExpression>
                                </subreport>
                        </band>
                </detail>
 
</jasperReport>

And the corresponding subreport:
<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "
http://jasperreports.sourceforge.net/dtds/jasperreport.dtd";>
<jasperReport
                 name="JobChart"
                 columnCount="1"
                 printOrder="Vertical"
                 orientation="Landscape"
                 pageWidth="2090"
                 pageHeight="7"
                 columnWidth="2090"
                 columnSpacing="0"
                 leftMargin="0"
                 rightMargin="0"
                 topMargin="0"
                 bottomMargin="0"
                 whenNoDataType="NoPages"
                 isTitleNewPage="false"
                 isSummaryNewPage="false">
        <property name="ireport.scriptlethandling" value="0" />
        <property name="ireport.encoding" value="UTF-8" />
        <import value="java.util.*" />
        <import value="net.sf.jasperreports.engine.*" />
        <import value="net.sf.jasperreports.engine.data.*" />


        <field name="jobname" class="java.lang.String"/>
        <field name="jobID" class="java.lang.String"/>
        <field name="days" class="java.util.Collection"/>

                <detail>
                        <band height="7"  isSplitAllowed="true" >
                                <textField isStretchWithOverflow="false" 
isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" 
hyperlinkTarget="Self" >
                                        <reportElement
                                                x="0"
                                                y="0"
                                                width="200"
                                                height="7"
                                                key="textField-1"/>
                                        <box topBorder="None" 
topBorderColor="#000000" leftBorder="Thin" leftBorderColor="#000000" 
rightBorder="Thin" rightBorderColor="#000000" bottomBorder="Thin" 
bottomBorderColor="#000000"/>
                                        <textElement textAlignment="Left" 
verticalAlignment="Middle" rotation="None" lineSpacing="Single">
                                                <font fontName="SansSerif" 
size="5" isBold="false" isItalic="false" isUnderline="false" 
isStrikeThrough="false" />
                                        </textElement>
                                <textFieldExpression 
class="java.lang.String"><![CDATA[$F{jobname}]]></textFieldExpression>
                                </textField>
                                <textField isStretchWithOverflow="false" 
isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" 
hyperlinkTarget="Self" >
                                        <reportElement
                                                x="200"
                                                y="0"
                                                width="40"
                                                height="7"
                                                key="textField-2"/>
                                        <box topBorder="None" 
topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" 
rightBorder="Thin" rightBorderColor="#000000" rightPadding="5" 
bottomBorder="Thin" bottomBorderColor="#000000"/>
                                        <textElement 
textAlignment="Right">
                                                <font size="5"/>
                                        </textElement>
                                <textFieldExpression 
class="java.lang.String"><![CDATA[$F{jobID}]]></textFieldExpression>
                                </textField>
                                <subreport  isUsingCache="true">
                                        <reportElement
                                                x="240"
                                                y="0"
                                                width="1849"
                                                height="7"
                                                key="subreport-1"/>
                                        <dataSourceExpression><![CDATA[new 
net.sf.jasperreports.engine.data.JRBeanCollectionDataSource((Collection) 
$F{days})]]></dataSourceExpression>
                                        <subreportExpression 
class="java.lang.String"><![CDATA["Days.jasper"]]></subreportExpression>
                                </subreport>
                        </band>
                </detail> 
</jasperReport>

------------------------------------------------------------------
Netzgiganten GmbH
Gerokstr. 6
70188 Stuttgart
http://www.netzgiganten.de

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jasperreports-questions mailing list
jasperreports-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jasperreports-questions

Reply via email to