Jump to content
Changes to the Jaspersoft community edition download ×

Fetching Greek Characters from DB And Display


2005 IR Help

Recommended Posts

By: Ramesh - ramesh_t

Fetching Greek Characters from DB And Display

2004-07-29 05:44

Hi,

I am Using ireport for designing report templet . There are some db fields which will contain greek character. I have to display those text in output screen. Now I am saving the report as a HTML file.

 

But when we are opening the HTML file it is isplaying junk.

 

Please give me some idea how can I implement this.

Thanks in advance for yours help.

 

Here is code used for testing:-

JasperDesign jasperDesign = JasperManager.loadXmlDesign("CitiReceipt2.xml");

JasperReport jasperReport = JasperManager.compileReport(jasperDesign);

 

 

// Second, create a map of parameters to pass to the report.

Map parameters = new HashMap();

parameters.put("SYSTEM_DATE", "Naiaoc");

 

// Third, get a database connection

Connection conn = Test.getConnection();

 

// Fourth, create JasperPrint using fillReport() method

JasperPrint jasperPrint = JasperManager.fillReport(jasperReport,

parameters, conn);

 

JRHtmlExporter exporter = new JRHtmlExporter ();

StringBuffer Buffer = new StringBuffer();

exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER,Buffer);

exporter.exportReport();

System.out.println("Before Hello World!");

System.out.println(Buffer.toString());

JasperExportManager.exportReportToHtmlFile(jasperPrint,"CitiReceipt.html") ;

 

 

Thanks

Ramesh

 

 

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Fetching Greek Characters from DB And Display

2004-07-29 07:22

For my idle curiosity, what does

 

"parameters.put("SYSTEM_DATE", "Naiaoc");"

 

do?

 

Can you post a segment of the generated HTML? Just a few lines containing the result.

 

 

Are you sure the database is storing the data correctly (like difference between a VARCHAR and an NVARCHAR in SQL Server)?

 

Are you sure your browser has the appropriate language capability?

 

Have you tried viewing the report exported to a PDF or in the applet viewer?

 

 

 

 

 

By: Ramesh - ramesh_t

RE: Fetching Greek Characters from DB And Display

2004-07-29 19:25

SYSTEM_DATE is java.lang.String type.

"parameters.put("SYSTEM_DATE", "Naiaoc");"

 

This statement we did for testing only.

Curently we are displaying same greek data from webpages. But when we are displaying from report

it is showing junk.

 

The sample Html File:-

<html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<head>

<style type="text/css">

a {text-decoration: none}

</style>

</head>

<body text="#000000" link="#000000" alink="#000000" vlink="#000000">

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr><td width="50%"> </td><td align="center">

 

<a name="JR_PAGE_ANCHOR_1">

<table width=595 cellpadding=0 cellspacing=0 border=0

bgcolor=white>

<tr>

<td><img src="CitiReceipt.html_files/px" width=67 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=144 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=3 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=5 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=80 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=3 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=20 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=3 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=5 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=24 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=2 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=145 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=2 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=2 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=1 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=4 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=5 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=5 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=9 height=1></td>

<td><img src="CitiReceipt.html_files/px" width=59 height=1></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=29></td>

</tr>

<tr valign=top>

<td><img src="CitiReceipt.html_files/px" width=67 height=38></td>

<td colspan=25 valign="middle" style="background-color: #CC00CC; text-align: center;"><span style="font-family: Arial; color: #0000FF; background-color: #CC00CC; font-size: 24.0px; font-weight: bold;">Citi Receipt</span></td>

<td><img src="CitiReceipt.html_files/px" width=59 height=38></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=88></td>

</tr>

<tr valign=top>

<td colspan=4><img src="CitiReceipt.html_files/px" width=215 height=2></td>

<td colspan=4 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">Κατάστημα</span></td>

<td colspan=19><img src="CitiReceipt.html_files/px" width=291 height=2></td>

</tr>

<tr valign=top>

<td colspan=4><img src="CitiReceipt.html_files/px" width=215 height=14></td>

<td colspan=5><img src="CitiReceipt.html_files/px" width=53 height=14></td>

<td colspan=9><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">«»??? </span></td>

<td colspan=5><img src="CitiReceipt.html_files/px" width=82 height=14></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=11></td>

</tr>

<tr valign=top>

<td colspan=15><img src="CitiReceipt.html_files/px" width=359 height=3></td>

<td colspan=6 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">null</span></td>

<td colspan=6><img src="CitiReceipt.html_files/px" width=83 height=3></td>

</tr>

<tr valign=top>

<td colspan=5><img src="CitiReceipt.html_files/px" width=216 height=10></td>

<td colspan=2 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">ΗμεÏομηνία</span></td>

<td colspan=8><img src="CitiReceipt.html_files/px" width=58 height=10></td>

<td colspan=6><img src="CitiReceipt.html_files/px" width=83 height=10></td>

</tr>

<tr valign=top>

<td colspan=5><img src="CitiReceipt.html_files/px" width=216 height=5></td>

<td colspan=20><img src="CitiReceipt.html_files/px" width=294 height=5></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=5></td>

</tr>

<tr valign=top>

<td colspan=16><img src="CitiReceipt.html_files/px" width=360 height=2></td>

<td colspan=8 rowspan=3><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">null</span></td>

<td colspan=3><img src="CitiReceipt.html_files/px" width=73 height=2></td>

</tr>

<tr valign=top>

<td colspan=2><img src="CitiReceipt.html_files/px" width=211 height=13></td>

<td colspan=7><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">Κατάστημα Îελάτη</span></td>

<td colspan=7><img src="CitiReceipt.html_files/px" width=36 height=13></td>

<td colspan=3><img src="CitiReceipt.html_files/px" width=73 height=13></td>

</tr>

<tr valign=top>

<td colspan=16><img src="CitiReceipt.html_files/px" width=360 height=1></td>

<td colspan=3><img src="CitiReceipt.html_files/px" width=73 height=1></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=9></td>

</tr>

<tr valign=top>

<td colspan=18><img src="CitiReceipt.html_files/px" width=363 height=1></td>

<td rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">null</span></td>

<td colspan=8><img src="CitiReceipt.html_files/px" width=87 height=1></td>

</tr>

<tr valign=top>

<td colspan=4><img src="CitiReceipt.html_files/px" width=215 height=14></td>

<td colspan=7><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">΄Ονομα Îελάτη</span></td>

<td colspan=7><img src="CitiReceipt.html_files/px" width=35 height=14></td>

<td colspan=8><img src="CitiReceipt.html_files/px" width=87 height=14></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=13></td>

</tr>

<tr valign=top>

<td colspan=3><img src="CitiReceipt.html_files/px" width=212 height=14></td>

<td colspan=7 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">Δελτίο αστυνομικής</span></td>

<td colspan=6><img src="CitiReceipt.html_files/px" width=33 height=14></td>

<td colspan=4><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">null</span></td>

<td colspan=7><img src="CitiReceipt.html_files/px" width=85 height=14></td>

</tr>

<tr valign=top>

<td colspan=3><img src="CitiReceipt.html_files/px" width=212 height=1></td>

<td colspan=17><img src="CitiReceipt.html_files/px" width=268 height=1></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=8></td>

</tr>

<tr valign=top>

<td colspan=5><img src="CitiReceipt.html_files/px" width=216 height=14></td>

<td colspan=6><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">Ταυτότητας</span></td>

<td colspan=6><img src="CitiReceipt.html_files/px" width=34 height=14></td>

<td colspan=6 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">null</span></td>

<td colspan=4><img src="CitiReceipt.html_files/px" width=78 height=14></td>

</tr>

<tr valign=top>

<td colspan=17><img src="CitiReceipt.html_files/px" width=362 height=3></td>

<td colspan=4><img src="CitiReceipt.html_files/px" width=78 height=3></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=8></td>

</tr>

<tr valign=top>

<td colspan=6><img src="CitiReceipt.html_files/px" width=221 height=4></td>

<td colspan=6 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 12.0px; font-weight: bold;">Δ/νση κατοικίας</span></td>

<td colspan=15><img src="CitiReceipt.html_files/px" width=262 height=4></td>

</tr>

<tr valign=top>

<td colspan=6><img src="CitiReceipt.html_files/px" width=221 height=13></td>

<td colspan=2><img src="CitiReceipt.html_files/px" width=25 height=13></td>

<td colspan=11 rowspan=2><span style="font-family: Arial; background-color: #FFFFFF; font-size: 10.0px;">null</span></td>

<td colspan=2><img src="CitiReceipt.html_files/px" width=68 height=13></td>

</tr>

<tr valign=top>

<td colspan=14><img src="CitiReceipt.html_files/px" width=358 height=3></td>

<td colspan=2><img src="CitiReceipt.html_files/px" width=68 height=3></td>

</tr>

<tr valign=top>

<td colspan=27><img src="CitiReceipt.html_files/px" width=595 height=516></td>

</tr>

</table>

<br>

<br>

 

</td><td width="50%"> </td></tr>

</table>

</body>

</html>

 

 

 

 

 

 

 

By: Mykel Alvis - evilarchitect

RE: Fetching Greek Characters from DB And Dis

2004-07-29 20:22

OK. You've definitely got some issues.

 

Problem number one: You've got a lot of lines on the page. This isn't serious, but I was never able to get this to look good.

 

Problem number two: This is the killer.

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Your character encoding is UTF-8. That's ascii. That's a big no-no for doing foreign other languages.

 

You need to figure out how to set the html character encoding to something that supports your character set so that the headers get generated correctly. I don't know what that is, since I don't really do anything with i18n directly.

 

Good luck. Post your solution.

 

 

 

 

By: Paulo Soares - psoares33

RE: Fetching Greek Characters from DB And Dis

2004-07-30 03:25

UTF-8 supports all the Unicode characters. That's not the problem. Some generic considerations:

 

- the data stored in the DB may be stored as bytes that have to be converted to a String using some encoding

 

- the DB driver gives you a String but there's a mismatch between the DB encoding and what's actually stored

 

- you must have an html encoding compatible with what you put there. This may or may not be a JR problem

 

 

 

 

By: Ramesh - ramesh_t

RE: Fetching Greek Characters from DB And Display

2004-07-29 23:24

I have tried with carset="iso-8859-7" but still it is same.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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