Jump to content

Problem with truncated texts in unix environment


foo1301

Recommended Posts

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

 

Link to comment
Share on other sites

  • 5 weeks later...
  • Replies 14
  • Created
  • Last Reply

Top Posters In This Topic

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 1 year later...

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...

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.

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 5 months later...

Code:
Jasperreports_extensions.propertiesnet.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.extensions.SpringExtensionsRegistryFactorynet.sf.jasperreports.extension.fonts.spring.beans.resource=fonts/fonts.xmlfonts.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           http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">   <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>

 

Post Edited by rajusaranga at 09/30/2011 17:10

Link to comment
Share on other sites

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
 

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...