Problem with truncated texts in unix environment

Hello jasperfolks,

we are using jasperreports 1.3.4 (with itext 1.2.1) in production for several years now for generating pdf sheets. Developing takes place in a windows, production in a unix environment using Websphere. In the beginning we had severe problems with texts in textfields becoming truncated in unix, whereas they have been displayed correctly in windows during development. It turned out that we had to put a distinct font into a jar file and adding this one to the classpath.

Recently we upgraded our production environment from Websphere 5 to Websphere 7 and suddenly the mentioned problem arose again. As an example, a date "04.05.2009" is truncated to "04.05.200"; as far as i have seen at most one character is truncated.

The software that uses jasperreports is designed in a way that it cannot even start if the font.jar cannot be found, so this shouldn't be the cause. We have tried to

  • upgrade versions (jasperreports to 2.0.5 and itext to 2.0.8; higher versions led to compatibility issues)
  • setting the net.sf.jasperreports.export.pdf.force.linebreak.policy to true
  • checking the fonts in the resulting pdf; seemed ok

It is remarkable that the upgrade of Websphere (and that upgraded the jdk version from 1.4 to 5.0 (possibly 6 - don't know for sure)) with no other software change caused the problem. Possibly it is some kind of different rounding behaviour of the result of a small jdk method that changed with the jdk version?

 

Any idea ?

Thank you in advance

 

foo1301's picture
55
Joined: Jul 22 2009 - 1:26am
Last seen: 14 years 2 months ago

14 Answers:

Hi,

 

What is this font.jar file you talk about and what does it have to do with JasperReports?

Adding fonts to the classpath does not mean they are installed in the system or available to the JVM.

At least not in those old versions of JR where font extension support was not yet available.

 

Thank you,

Teodor

 

teodord's picture
53198
Joined: Jun 30 2006 - 9:00am
Last seen: 1 day 1 hour ago

Hello teodor,

this font.jar contains tthe two TT-fonts (vcarial.ttf and vcarialbd.ttf)  we are using with JR:

     <reportFont name            ="HeaderFont"
                isDefault        ="false"
                fontName         ="VCArial"
                size             ="8"
                isBold           ="true"
                isItalic         ="false"
                isUnderline      ="false"
                isStrikeThrough  ="false"
                pdfFontName      ="vcarialbd.ttf"
                pdfEncoding      ="Cp1252"
                isPdfEmbedded    ="true"/>

 

The fonts are initialized by:

final InputStream isArial = getClass().getResourceAsStream("/vcarial.ttf");
final InputStream isArialBold = getClass().getResourceAsStream(
"/vcarialbd.ttf");
Font.createFont(Font.TRUETYPE_FONT, isArial);
Font.createFont(Font.TRUETYPE_FONT, isArialBold);
isArial.close();
isArialBold.close();

 

This solution indeed solved the font problems we had that time, so i'm quite sure it always worked as intended. It just happened with the Websphere upgrade that a similar (above mentioned) font problem occured, and i have no further idea to solve it.

foo1301's picture
55
Joined: Jul 22 2009 - 1:26am
Last seen: 14 years 2 months ago

Hi,

 

The problem you experience comes from the fact that the newer Websphere comes with newer JDK.

Websphere 5 probably came with 1.4, while Websphere 7 probably comes with 1.6.

 

The Font.createFont method no longer works the same in those different versions of the JDK. In 1.4, calling this method had the side effect of registering the font with the JVM. This is no longer the case, and while the change was logged as a bug at Sun, they rejected it saying they never intended it to work that way. This is why in 1.6, registering fonts has a completely new API.

This is actually the main reason why in JasperReports we decided to implement support for what we no call "font extensions". We wanted to make the use of fonts with the reports as transparent as possible.

I suggest you either upgrade to newer JR and make use of its font extension support, or, you read about how to register fonts in the newer versions of JDK.

 

I hope this helps.
Teodor

 

teodord's picture
53198
Joined: Jun 30 2006 - 9:00am
Last seen: 1 day 1 hour ago

That's interesting and opens up a new possibility (and yes, you're right about the JDK versions).

I'll have a look at that - thank you very much, teodor.



Post Edited by foo1301 at 08/24/2009 13:20
foo1301's picture
55
Joined: Jul 22 2009 - 1:26am
Last seen: 14 years 2 months ago

Hi,

We are facing the same issue.We are using jasper reports 1.3.3(with itext  1.4.5) . Development is in windows environment and production is in mainframes z/OS. This issue is may not be related to websphere server and it is related to unix environment only. I could see the same font in websphere 7 as in the websphere 6.

Any help is highly appreciated

hema

 

hema_jasper's picture
Joined: Mar 6 2011 - 8:09pm
Last seen: 9 years 3 months ago

Hema,

Even I had faced similar issues some time back and could could not find anything wrong on the environment. The issue was fixed by increasing the width of the field where the content was truncated in Unix. In rare cases this issue happened that Unix was not able to display the content with the given size of the field where in Windows was successfully displaying it.

Thanks,

R Srinivas

srinivas1278's picture
Joined: Nov 5 2009 - 9:12pm
Last seen: 2 years 8 months ago

Srinivas,

Thanks for the update. I could fix the issue by increasing the height  and width of the field. But I have space concern that i need to generate a PDF letter using only title part of the jasper report.

Is there any alternative in UNIX to display the content with the given size of field like in windows?

Thanks,

Hema.

 

 

 

hema_jasper's picture
Joined: Mar 6 2011 - 8:09pm
Last seen: 9 years 3 months ago

You have different fonts in the development environment vs the deployment environment. Use font extensions. Life will be good.

Regards,
Matt

mdahlman's picture
37340
Joined: Mar 13 2007 - 2:43am
Last seen: 8 years 10 months ago

Hema,

Though I have not tried it myself, You can also try setting 'Pdf embeded' attribute to true for the field. FYI. This might increase the report output file size.

Thanks,

R Srinivas

srinivas1278's picture
Joined: Nov 5 2009 - 9:12pm
Last seen: 2 years 8 months ago

please give me working solution as i dont have development environment with mainframes and need to request to test it in production environment.

I think we need  to set the "PDF embedded"  attribute to true after we have set the path to the file containing fonts.

Can you specify the solution in detail.

Regards,

Hema.

 

hema_jasper's picture
Joined: Mar 6 2011 - 8:09pm
Last seen: 9 years 3 months ago

Hi,

I could resolve the issue using font extensions. Thank you for the help.

First i could reproduce the issue by deleting fonts from the C:\\WINDOWS\\Fonts. Then i have used font extenstions and tested the application. Now it is working fine.

Regards,

Hema.

 

 

hema_jasper's picture
Joined: Mar 6 2011 - 8:09pm
Last seen: 9 years 3 months ago

That's not working either......................please Help!!!!!!

pratikpai's picture
Joined: Apr 14 2011 - 1:40am
Last seen: 12 years 5 months ago
Code:
Jasperreports_extensions.properties
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.extensions.SpringExtensionsRegistryFactory
net.sf.jasperreports.extension.fonts.spring.beans.resource=fonts/fonts.xml
 
fonts.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           <a href="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">" target="_blank"><a href="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">" target="_blank">http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"></a></a>
 
   <bean id="fontBean946935387245" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
       <property name="name" value="Arial"/>
       <property name="normal" value="fonts/arial.ttf"/>
       <property name="bold" value="fonts/arialbd.ttf"/>
       <property name="italic" value="fonts/ariali.ttf"/>
       <property name="boldItalic" value="fonts/arialbi.ttf"/>
       <property name="pdfEmbedded" value="true"/>
   </bean>
 
 
   <bean id="fontBean94693538846" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
       <property name="name" value="Arial Narrow"/>
       <property name="normal" value="fonts/ARIALN.TTF"/>
       <property name="bold" value="fonts/ARIALNB.TTF"/>
       <property name="italic" value="fonts/ARIALNI.TTF"/>
       <property name="boldItalic" value="fonts/ARIALNBI.TTF"/>
       <property name="pdfEmbedded" value="true"/>
   </bean>
 
 
   <bean id="fontBean946935351822" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
       <property name="name" value="Courier New"/>
       <property name="normal" value="fonts/cour.ttf"/>
       <property name="bold" value="fonts/courbd.ttf"/>
       <property name="italic" value="fonts/couri.ttf"/>
       <property name="boldItalic" value="fonts/courbi.ttf"/>
       <property name="pdfEmbedded" value="true"/>
   </bean>
 
 
   <bean id="fontBean946935377219" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
       <property name="name" value="Times New Roman"/>
       <property name="normal" value="fonts/times.ttf"/>
       <property name="bold" value="fonts/timesbd.ttf"/>
       <property name="italic" value="fonts/timesi.ttf"/>
       <property name="boldItalic" value="fonts/timesbi.ttf"/>
       <property name="pdfEmbedded" value="true"/>
   </bean>
 
 
   <bean id="fontBean946935393722" class="net.sf.jasperreports.engine.fonts.SimpleFontFamily">
       <property name="name" value="ocra10"/>
       <property name="normal" value="fonts/ocra10.ttf"/>
       <property name="pdfEmbedded" value="true"/>
   </bean>
 
 
</beans>
</td></tr></tbody></table><br><br>Post Edited by rajusaranga at 09/30/2011 17:10
rajusaranga's picture
Joined: Sep 29 2011 - 10:25am
Last seen: 11 years 12 months ago

Hello,

We are using Jasperreports 3.6.2 with iText-2.1.0 to generate PDF reports. Development takes place in Windows,  production in AIX environment using Websphere.  We are using Font Extensions feature and bundling our fonts with Web application.
The PDF reports are working fine in Websphere 6.0.2.31, but when we upgraded our Websphere environment from 6.0.2.31 to 6.0.2.43(J2RE 1.4.2 from SR11 to SR13), we had a 1 character truncation problem in few text fields of PDF reports.

Please advise.

I am having some problems in posting to this forum.Please see above reply for my properties file and fonts.xml

Thank you in advance.
Raju

Our Environment:
Websphere 6.0.2.43, J2RE 1.4.2(SR13)
Struts 1.3.10
Spring 2.5.6
Jasper Report 3.6.2
iText 2.1.0
jasperreports-extensions-3.5.3.jar
iReport 3.6.2
 

rajusaranga's picture
Joined: Sep 29 2011 - 10:25am
Last seen: 11 years 12 months ago
Feedback
randomness