Solved

French text display problem in JASPER report docs

Posted on 2007-11-14
10
2,480 Views
Last Modified: 2012-06-27
Please help me regarding this problem

I use jasper report for report in my web project (Tomcat). I am saving the report in .rtf file and from java. Also, I read the text from iReport (jasper tool) and write it in the .doc/.rtf documents.

When the tomcat is in windows OS, the french texts in the .rtf report is displayed as well.

But If the tomcat is in Linux OS, the same french text is displayed with some changes

The Code for saving the report as .rtf
=======================================

JasperPrint jasperPrint = JasperManager.fillReport(jasperReport,parameters,c onn);
JRRtfExporter rtfExporter = new JRRtfExporter(); rtfExporter.setParameter(JRExporterParameter.JASPE R_PRINT, jasperPrint); rtfExporter.setParameter(JRExporterParameter.OUTPU T_FILE_NAME,
request.getRealPath("includes")+"/report.rtf");
rtfExporter.exportReport();



So now the report is saved as report.doc

And I read the document and display it. For that code is
================================================== ======

response.setHeader ("Content-Disposition", "attachment;filename="Report.rtf"");
File f = new File("report.doc");
InputStream in = new FileInputStream(f);
ServletOutputStream outs = response.getOutputStream();
int bit = 256;
int i = 0;
try {
while ((bit) >= 0) {
bit = in.read();
outs.write(bit);
}
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
}
outs.flush();
outs.close();
in.close();

*****************************************


1) Do I need to map any font while i create doc/rtf reports? because in windows it is not a problem...

2) Accent problem is the main one in this .rtf/doc...how to overcome this when we create report?


0
Comment
Question by:Loganathan Natarajan
  • 5
  • 4
10 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 20278560
If you open the PDF directly, rather than through the servlet, does it look ok then?

ie:  Is it a generation problem, or a transmission problem?
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 20278584
i think it is transmission problem... because in normal word document also when i write french text.. it is not displaying correctly..  

do we need to apply french fonts to display the french text in word doc???

but it works well in pdf docs..
0
 
LVL 35

Expert Comment

by:TimYates
ID: 20278622
Are you viewing the file on the two different OSes as well?

I'm confused now...

So this works:

    GENERATE(windows) -> SERVLET(windows) -> VIEW(windows)

Does this?

    GENERATE(windows) -> SERVLET(windows) -> VIEW(linux)

Or are you saying that this doesn't work:

    GENERATE(linux) -> SERVLET(linux) -> VIEW(windows)

?
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 20278632
my development OS is in windows... the deployment (upload) OS is in linux.. so.. as for windows everything works fine...


So this works:

 GENERATE(windows) -> SERVLET(windows) -> VIEW(windows)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 20278665
And this:

GENERATE(linux) -> SERVLET(linux) -> VIEW(windows)

fails?
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:deeppra
ID: 20278733
try to save the file in unicode encoding format
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 20278915
i tried using unicode encoding as well as the below way also,
rtfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());

it doesn't works....


do i need apply any french font while i create the doc/rtf ?

0
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 20278958
RTFs don't have embedded fonts as far as I know

It is more than likely an encoding issue somewhere in your pipeline...  Either the generation of the RTF or the sending it to the user phase

That's why I asked if you can copy the RTF off of the Linux box onto your Windows box using normal tools, and open it that way...  Is it the actual RTF file which is corrupted?  

I guess that the RTF is fine when generated on the Linux box, but it is the servlet that is mis-handling it
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 20278974
ok...RTF formats works well..but designs are not applied properly... only TEXT's could be displayed...

so i have to go for .doc formate... how do i solve it in .doc format?
0
 
LVL 36

Author Comment

by:Loganathan Natarajan
ID: 20286313
anymore comments?
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Do you ever need to create a 20 page Word document for some testing purpose? Are you tired of copying & pasting old boring "lorem ipsum" text over and over again, increasing font size and line space in order to make the document 20+ pages long? Look…
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now