Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate text fields by 90 degrees in jasper reports?

I am creating some reports using iReport designer. While generating reports I came across a requirement where I have to display static text fields/labels in 90 degree rotation as shown in the below image:

90 degree rotated text field

I was searching on internet to get solution for this and I came to know that jaspersoft doesn't support text field rotation. I read this in the solution for this question. Is this feature available in any new version of jaspersoft? Or is there any way to achieve this functionality using external java programs?

like image 524
Madhusudan Avatar asked Mar 15 '23 13:03

Madhusudan


1 Answers

Jasper report does not support the rotation at a certain degree, but your example is rotation="Left", so to rotate the text you should use the rotation property on the textElement example

<staticText>
    <reportElement x="100" y="2" width="100" height="75" uuid="ac56467b-05e7-4749-ab0a-cf15b3c2047d"/>
    <textElement rotation="Left">
        <paragraph lineSpacing="Single"/>
    </textElement>
    <text><![CDATA[YOUR TEXT]]></text>
</staticText>

Where the key code is <textElement rotation="Left">

The rotation can have these propreties.

Left = As in you example text goes from down to up

Right = Text goes from up to down

UpsideDown = Text is upside down

If you are using iReport check out the properties tab > Text properties > Rotation

like image 103
Petter Friberg Avatar answered Apr 25 '23 13:04

Petter Friberg