0
votes

Just like the title said, I have a problem with the visualization of reports with JasperReports. Firstly, I am using Eclipse Indigo with the plugin Jaspersoft Studio to create the reports and JDK 1.6 U24.

The following code will help me explain my problem

<textField pattern="dd/MM/yyyy" isBlankWhenNull="true">
    <reportElement positionType="Float" mode="Transparent" x="131" y="79" width="423" height="12" isRemoveLineWhenBlank="true" backcolor="#E1E9F0" uuid="9075f7aa-bd0f-4e78-8eca-102cc38f6f37"/>
    <textElement verticalAlignment="Middle">
        <font fontName="Serif" size="9" isBold="true"/>
    </textElement>
    <textFieldExpression><![CDATA[$F{inscriptionDate}]]></textFieldExpression>
</textField>

The problem is that the properties of the tags texField and textElement are ignored when the report is displayed, that is, the property "pattern" of the textField tag will be ignored when the variable "inscriptionDate" (Which is of Date type) is displayed in the report. Another example, the "size" and "fontName" properties of the font child tag of the textElement tag, like with textField, this properties are ignored and the text will be show with the default properties.

In the specific case of the "size" property I tried to change the value but I always get the same result. Something funny is that the property "isBold" or "isItalic" aren't ignored.

The same issue happen with the staticText tag:

<staticText>
     <reportElement style="titulo2" positionType="Float" mode="Transparent" x="1" y="95" width="553" height="12" backcolor="#E1E9F0" uuid="09fb4cfe-831d-42f3-a32c-66ce4a2bc0f0">
         <printWhenExpression><![CDATA[true]]></printWhenExpression>
    </reportElement>
    <textElement verticalAlignment="Middle" markup="styled">
        <font fontName="Serif" size="9" isBold="true" isItalic="true"/>
    </textElement>
    <text><![CDATA[<style size="9">Some text</style>]]></text>
</staticText>

The difference between the first code and the second is in the use of the tag <style> (second last line), in fact, I am using this "solution" to try to solve my problem but I know that this is not a proper solution.

I really appreciate the help...

1

1 Answers

0
votes

Ok, there's things to be considered.

  • fontName: When are giving a particular font to a text, that font has to be availabe with JVM in order to be applied to the report, If JVM doesn't have that font it woud replace it with something which it has (Arial in most cases). You would need to create a Font Extension for the fonts you require.
  • Formatting date: The problem here could be report requires $F{inscriptionDate} to be in string to format it. However you can alternatively format the date as new SimpleDateFormat("dd/MM/yyyy").format($F{inscriptionDate}).
  • font size: font size given to text field must work. There is no scope for a issue here. Try increasing the size considerably to see if it works.