Hi,
I need to show a page header on all of the pages on the report containing product logo. So, on the first page page header should show above the title. Can you please let me know hwo do I achive this. But, when I am creating a template, if I put the page header above the title, the report template does not compile.
In the following code, if I put the page header below the title, in the first page also, it appears below the title. But I want the page header to be above the title in the first page.
-----------------------------------
<title>
<band height="180">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement positionType="Float" stretchType="RelativeToTallestObject" x="0" y="20" width="515" height="40" isRemoveLineWhenBlank="true"/>
<box>
<topPen lineWidth="1.0"/>
</box>
<textElement textAlignment="Center">
<font size="16" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{reportTitle}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement style="Sans_Bold" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="60" width="515" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font size="10" isBold="true" pdfFontName="Helvetica-Bold"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Filters Applied:"]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="dataSource" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="80" width="515" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{dataSource}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="timeFrame" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="100" width="515" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$P{timeFrame}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="searchFilter" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="120" width="515" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Source: " + $P{source}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="searchFilter" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="140" width="515" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Application: " + $P{application}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement key="searchFilter" positionType="Float" stretchType="RelativeToTallestObject" x="0" y="160" width="515" height="20" isRemoveLineWhenBlank="true"/>
<textElement textAlignment="Left">
<font size="10"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA["Destination:" + $P{destination}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="60">
<image scaleImage="Clip">
<reportElement x="0" y="0" width="247" height="60" isRemoveLineWhenBlank="true"/>
<imageExpression class="java.lang.String"><![CDATA["../images/logo_mcafee_profiler.png"]]></imageExpression>
</image>
</band>
</pageHeader>
---------
Thanks,
Padma
4 Answers:
Hi svenn,
Thnak you for your reply. I am new to Jasper Reports. Can you please let me know how do I write expression to remove the page header for the first page.
Following is the page header that I will be using.
-------------------------------
<pageHeader>
<band height="60">
<image scaleImage="Clip">
<reportElement x="0" y="0" width="247" height="60" isRemoveLineWhenBlank="true"/>
<imageExpression class="java.lang.String"><![CDATA["../images/logo.png"]]></imageExpression>
</image>
</band>
</pageHeader>
----------------
Thanks,
Padma
Using the printWhenEXpression based on the PAGE_NUMBER built-in variable.
<pageHeader> <printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue() > 1 ? Boolean.TRUE: Boolean.FALSE]]></printWhenExpression> |
I hope this helps.
Teodor