Jump to content
We've recently updated our Privacy Statement, available here ×

Sub-Report Font alignment in JasperStudio 6.2.2


Ivan.Hibbert

Recommended Posts

Left aligned text in compiled sub-report using JasperStudio 6.2.2 - June, 2016

 

 

I have been searching the forums for months to try to find an answer to my Font Alignment issue.  After twice THINKING I had solved it, I was mistaken yet again when I re-compiled my WORKING sub-reports with the newer version of JasperStudio.  Most of the forums date this issue back many years... so if there is a fix out there, I'm somehow missing it.

 

When I compile a sub-report with JasperStudio 6.0.3, and embed the .jasper into a report, my grails application renders it correctly in both HTML and exporting to PDF.  However, when I re-compile the same sub-report with the later JasperStudio 6.2.2, all report elements' texts are LEFT ALIGNED.  Everytihng I've read thus far, suggests that you can't use older versions of the jasperreports-x.x.x.jar than that used to compile the sub-report.  We are using JasperStudio 6.2.2 and have imported all of the jasperreports-6.2.2.jar and associated jar files from the 6.2.2 project.  I am baffled by this behaviour as there is nothing mismatched.

 

If I re-compile any sub-report with the earlier version of JasperStudio 6.0.3, the reports render as desired (centred text etc...).

The forums suggest that there was a change to the way JasperStudio handled alignment of text as of around JasperStudio 6.0.x - so the question now remains:

HOW do you use the later JasperStudio and its associated jars to render a compiled subreport with correct font alignment?

We have a grails application and are using the following libraries:

jasperreports-6.2.2.jar
jasperreports-fonts-6.2.2.jar
jasperreports-javaflow-6.2.2.jar

Any pointers, suggestions or helps would be greatly appreciated!

 

Files and Technical:

A new subreport was created fresh from JasperStudio 6.2.2

Designer view of Sub report using JasperStudio 6.2.2

SubReport_Studio_6_2_2.png.fa09260ef416168382167723ea5b08ff.png

 

Subreport .jrxml file as shown in JasperStudio 6.2.2:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.2.2.final using JasperReports Library version 6.2.2  --><!-- 2016-06-17T09:22:10 --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1f0618b7-fa1a-4078-9afd-01e7d0f28e6c">    <style name="Heading 1" forecolor="#3B6E8F" fontName="Arial" fontSize="18" isBold="true"/>    <queryString>        <![CDATA[]]>    </queryString>    <title>        <band height="40" splitType="Stretch">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField>                <reportElement style="Heading 1" x="0" y="0" width="550" height="30" uuid="bb52ca96-cc87-4788-aa1d-bab658ef3868"/>                <box>                    <topPen lineWidth="1.0"/>                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                    <rightPen lineWidth="1.0"/>                </box>                <textElement textAlignment="Center" verticalAlignment="Middle">                    <font fontName="Times New Roman" size="20" isBold="true" isItalic="true"/>                </textElement>                <textFieldExpression><![CDATA["JasperStudio 6.2.2 Test"]]></textFieldExpression>            </textField>        </band>    </title>    <detail>        <band height="40" splitType="Stretch">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField>                <reportElement x="0" y="10" width="550" height="30" uuid="1317fb6d-e4cd-44d4-8333-4bdf6ec27a25"/>                <box>                    <topPen lineWidth="1.0" lineColor="#999999"/>                    <leftPen lineWidth="1.0" lineColor="#999999"/>                    <bottomPen lineWidth="1.0" lineColor="#999999"/>                    <rightPen lineWidth="1.0" lineColor="#999999"/>                </box>                <textElement textAlignment="Center" verticalAlignment="Middle">                    <font fontName="Arial" size="14" isItalic="true"/>                </textElement>                <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]

 

Report Output when compiled with JasperStudio 6.2.2:

SubReport_output_Studio_6_2_2.png.f56c9d190085c1b4889392eb294b3c4d.png

 

Same subreport .jrxml file as shown in JasperStudio 6.0.3:

<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version last--><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="1f0618b7-fa1a-4078-9afd-01e7d0f28e6c">    <style name="Heading 1" forecolor="#3B6E8F" fontName="Arial" fontSize="18" isBold="true"/>    <queryString>        <![CDATA[]]>    </queryString>    <title>        <band height="40" splitType="Stretch">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField>                <reportElement style="Heading 1" x="0" y="0" width="550" height="30" uuid="bb52ca96-cc87-4788-aa1d-bab658ef3868"/>                <box>                    <topPen lineWidth="1.0"/>                    <leftPen lineWidth="1.0"/>                    <bottomPen lineWidth="1.0"/>                    <rightPen lineWidth="1.0"/>                </box>                <textElement textAlignment="Center" verticalAlignment="Middle">                    <font fontName="Times New Roman" size="20" isBold="true" isItalic="true"/>                </textElement>                <textFieldExpression><![CDATA["JasperStudio 6.2.2 Test"]]></textFieldExpression>            </textField>        </band>    </title>    <detail>        <band height="40" splitType="Stretch">            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>            <textField>                <reportElement x="0" y="10" width="550" height="30" uuid="1317fb6d-e4cd-44d4-8333-4bdf6ec27a25"/>                <box>                    <topPen lineWidth="1.0" lineColor="#999999"/>                    <leftPen lineWidth="1.0" lineColor="#999999"/>                    <bottomPen lineWidth="1.0" lineColor="#999999"/>                    <rightPen lineWidth="1.0" lineColor="#999999"/>                </box>                <textElement textAlignment="Center" verticalAlignment="Middle">                    <font fontName="Arial" size="14" isItalic="true"/>                </textElement>                <textFieldExpression><![CDATA["Text Field"]]></textFieldExpression>            </textField>        </band>    </detail></jasperReport>[/code]

 

Report Output when compiled with JasperStudio 6.0.3:

SubReport_output_Studio_6_0_3.png.b3630546c9d1682732fc6a87d4c5d044.png

 

As you can see, the text aligns as per the Design only when compiled with the EARLIER JasperStudio version 6.0.3.

 

So, what have I missed?  What do I need to use the Latest versions and keep the sub-report text alignment as per the design?

 

Thank you for your help -- ANYONE????

 

Icy

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Does the report preview show the text properly aligned in JSS 6.2.2?  Is the problem only happening when running the report in your application (outside JSS)?

If so, try putting the following expression in a text element and running the report in your application:

getClass().getResource("net/sf/jasperreports/engine/JasperReport.class")[/code]

What is the resource URL that you get?

Btw, note that you don't need both jasperreports-6.2.2.jar and jasperreports-javaflow-6.2.2.jar, the latter is a variant of the default jar that is meant to be used with the Javaflow subreport executer.

Regards,

Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...