How to show Page Header above Title

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

 

 

 

padmav's picture
136
Joined: May 8 2009 - 12:34pm
Last seen: 14 years 4 months ago

4 Answers:

Make the image part of your title section. Then use an expression in the header band to suppress the header on the first page.

svenn's picture
15052
Joined: Mar 19 2007 - 5:57am
Last seen: 16 years 6 months ago

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

padmav's picture
136
Joined: May 8 2009 - 12:34pm
Last seen: 14 years 4 months ago

Using the printWhenEXpression based on the PAGE_NUMBER built-in variable.

 

 <pageHeader>
  <band height="60">

<printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue() > 1 ? Boolean.TRUE: Boolean.FALSE]]></printWhenExpression>
     <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>


I hope this helps.

Teodor

 

teodord's picture
53184
Joined: Jun 30 2006 - 9:00am
Last seen: 3 hours 31 min ago

Teodor,

Thank you very much.  That works well.

Padma

padmav's picture
136
Joined: May 8 2009 - 12:34pm
Last seen: 14 years 4 months ago
Feedback
randomness