Jump to content
Changes to the Jaspersoft community edition download ×

JasperReports 2.0.3: (xls) long text is truncated


Berrada

Recommended Posts

Hallo,

 

the feature of preserving the entire text even when it doesn't fit the element area is finally released.

 

JasperReports 2.0.3 release notes

support for keeping the entire original text for text elements that do not stretch; the full text is used in data-oriented exporters such as XLS and CSV;

 

I've changed the jar file into jasperreports-2.0.3.jar and started the export, the text is even truncated.

 

which property do I have to set if I want to preserve the entire text?

 

Thanks in advance

Link to comment
Share on other sites

  • Replies 16
  • Created
  • Last Reply

Top Posters In This Topic

You need to set net.sf.jasperreports.print.keep.full.text to true in one of the following places:

Globally in jasperreports.properties

At report level:

Code:

<jasperReport ...>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
...

At text element level:

Code:
[code]
<textField>
<reportElement ..>
<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>
...

[/ul]

 

Also see [url=http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/JRTextElement.html#PROPERTY_PRINT_KEEP_FULL_TEXT]this Javadoc description.

 

Regards,

Lucian

Post edited by: lucianc, at: 2008/01/10 15:39

Link to comment
Share on other sites

  • 1 month later...

Hello Lucian,

 

I am using 2.0.3 and I still see the data getting

truncated inspite of adding

 

<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>

 

 

at jasperreport level. Please, find the jrxml.

 

Here, the commentDisplay field is truncated. Just to

let you know the isStretchWithOverflow is set to

"false". If I set this to true I do see the data

not truncated.

 

But, I want to data to be not truncated with

isStretchWithOverFlow set to true.

 

Please, advice if I am missing anything.

 

 

 

 

[file name=celltruncate.txt size=7158]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/celltruncate.txt[/file]

Link to comment
Share on other sites

Lucian,

 

 

I am guessing what could the problem might have

been. An older 2.0.2 version was lurking in a different

war on the jboss application server I was deploying...

which is strange. I replaced the jasper jar in this

war with newer version and I am able to see it work.

I might be dumb.. :) as I am procrastinating to confirm

this hypothesis of mine. Any ways here is the xls.

 

I appreciate your help

 

Best Regards,

Venkat

Link to comment
Share on other sites

harivenkat wrote:

I am guessing what could the problem might have
been. An older 2.0.2 version was lurking in a different
war on the jboss application server I was deploying...
which is strange. I replaced the jasper jar in this
war with newer version and I am able to see it work.
I might be dumb.. :) as I am procrastinating to confirm
this hypothesis of mine. Any ways here is the xls.

 

I'm confused. Do you still have a problem?

 

Regards,

Lucian

Link to comment
Share on other sites

Va salut,

 

As vrea sa intreb, ce pot sa fac ca sa vad textul intreg (in textbox, in pdf) extras din database ? In sensul ca uneori se vede tot, alteori nu (lipsesc cateva cuvinte sau chiar o linie intreaga). Am incercat cu "property name="net.sf.jasperreports.print.keep.full.text" value="true", m-am uitat si in "Samples" si am citit si FAQ-urile.

Trimit si fisierul jrxml.

 

Multumesc,

Mackensen

 

 

Hello,

 

I would like to ask, what can I do in order to see the whole text (in the textbox, pdf) from the database ? I mean, sometimes it's displayed ok but sometimes not (a few words missing or even 1 line). I tried with "property name="net.sf.jasperreports.print.keep.full.text" value="true", I also looked in "Samples" and I read the FAQ.

Here is the jrxml.

 

Thanx, Mackensen [file name=req_off-94669bb7e3b91b00ae72cbf6616f3442.jrxml size=21040]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/req_off-94669bb7e3b91b00ae72cbf6616f3442.jrxml[/file]

Link to comment
Share on other sites

mackensen wrote:

I would like to ask, what can I do in order to see the whole text (in the textbox, pdf) from the database ? I mean, sometimes it's displayed ok but sometimes not (a few words missing or even 1 line). I tried with "property name="net.sf.jasperreports.print.keep.full.text" value="true", I also looked in "Samples" and I read the FAQ.

 

net.sf.jasperreports.print.keep.full.text only applies to data-oriented exporters such as XLS or CSV. The layout-oriented exporters (such as PDF) will only show the part of the text that's been determined to fit the text element area at fill time.

 

If you don't see the entire text for a text field when exporting to PDF, make sure that

The text field element has isStretchWithOverflow="true" if the text could exceed the amount of text that would fit in the element areas.

The AWT and PDF fonts match. See this FAQ for more details.

 

This might be the culprit in your case, since I see the following thing in your JRXML:

Code:
<font fontName="Times New Roman" pdfFontName="Helvetica-Bold" ...[/ol]

 

Regards,

Lucian

Link to comment
Share on other sites

thanx,

 

The jrxml I sent you it was just a test...I tried with many fonts...So, the problem is that the fonts don't match. How can I see what fonts has the JVM ? Or, better, is there a way to set the font dynamically on every JVM the program runs ?

 

Thanx again,

Mackensen

Post edited by: mackensen, at: 2008/02/26 12:26

Link to comment
Share on other sites

mackensen wrote:

How can I see what fonts has the JVM ?

 

You can write a Java application that does java.awt.GraphicsEnvironment.getAllFonts() or getAvailableFontFamilyNames(), or use a 3rd party Java font browser tool.

 

Or, better, is there a way to set the font dynamically on every JVM the program runs ?

 

Not exactly sure what you mean by setting the font dynamically, but that's probably not supported. Style information in report templates is not exactly dynamic.

 

Regards,

Lucian

Link to comment
Share on other sites

Sorry, I didn't study very much.

 

I already found something to see the JVM fonts. But I still don't understand.

 

I'm in a web application and I use just jsp, beans and servlet.

 

So, I created the jrxml file and set the fonts with iReport and then the pdf is created with Jasperreport from a servlet.

 

You say the problem is there when I set the fonts in iReport ? (in the Properties window, where there are 2 dropdown menus: "Font name" and "Pdf font name") ?

These fonts should match ? If yes, how can I set the fonts dynamically, I mean if the application runs on another jvm ?

 

Thanx again,

Mackensen

Post edited by: mackensen, at: 2008/02/28 11:05

Link to comment
Share on other sites

mackensen wrote:

You say the problem is there when I set the fonts in iReport ? (in the Properties window, where there are 2 dropdown menus: "Font name" and "Pdf font name") ?
These fonts should match ?

 

Yes.

 

If yes, how can I set the fonts dynamically, I mean if the application runs on another jvm ?

 

Report styles are static, so you only have limited options here:

  • Dynamic AWT fonts (i.e. "Font name") can only be achieved by using Java logical fonts (such as Serif, SansSerif, etc) that could map to different physical fonts on different JVMs.

Dynamic PDF fonts can be achieved by using the JRExporterParameter.FONT_MAP export parameter when exporting to PDF.[/ul]

 

Regards,

Lucian

Link to comment
Share on other sites

It still didn't work. I have a small servlet with this code:

 

int i=0;

Font[] fontlist=java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();

Font unfont=null;

for (i=0;i<fontlist.length;i++)

{

unfont=fontlist;

out.println("Name:"+unfont.getName()+"---Family: "+unfont.getFamily()+"---FontName:"+unfont.getFontName()+"<br>");

}

 

 

It displays a list of fonts like this:

 

 

Name:39251---Family: 39251---FontName:39251

Name:Agency FB---Family: Agency FB---FontName:Agency FB

Name:Agency FB Bold---Family: Agency FB---FontName:Agency FB Grassetto

Name:Allegro BT---Family: Allegro BT---FontName:Allegro BT

Name:Andale Mono---Family: Andale Mono---FontName:Andale Mono

Name:Arial---Family: Arial---FontName:Arial

Name:Arial Black---Family: Arial Black---FontName:Arial Black

Name:Arial Black Italic---Family: Arial Black---FontName:Arial Black Corsivo

Name:Arial Bold---Family: Arial---FontName:Arial Grassetto

 

I simply took some fonts from here (the "Family" item) and put in the jrxml so the "Font name" and "pdfFontName" have the same name. It's right ?

 

Thanx,

Mackensen

Link to comment
Share on other sites

  • 10 months later...

Dear lucianc,

I am facing a similar problem with jasper reports. When I print a report in PDF, MS-WORD or Rich Text format and if the text in a particular field is large then the text get truncated at the end of the line. Please see attached file testdoc.doc. Same problem happens in all the format types (pdf, richtext format). I am attaching teh jrml as well and we are using jasper report version 2.0.4.

From the above discussion, I guess this problem is coming because of fonts. I would highly appriciate if you could please help me resolving this problem.

I have gone through this whole thread and tried the other options for setting

<property name="net.sf.jasperreports.print.keep.full.text" value="true"/>

 <property name="net.sf.jasperreports.export.pdf.force.linebreak.policy" value="true"/>

but none of them work.

Please help

Thanks and Regards,

Deepak

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