Jump to content
We've recently updated our Privacy Statement, available here ×

Doesn't show special characters using jasper APIS in Java program


xcollons

Recommended Posts

Hello,

I'm trying to do a report and then launch it from a java application. The report, amongst other things, have a person's name, as since it's in spanish, it can include special characters such as 'Ñ'.

If we take a look at the xml header, it says that it's encoded in UTF-8: "<?xml version="1.0" encoding="UTF-8"?>", and what I'm trying to show is a variable called "persfullname" from an Informix database. For that, I'm using a textfield like this: 

<textField>
<reportElement x="160" y="0" width="351" height="15" uuid="fc2d6e4a-77a1-5ceb-9bad-1b997f4432e6"/>
<textElement markup="styled"/>
<textFieldExpression><![CDATA[$F{persfullname}]]></textFieldExpression>
</textField>
 
If I launch the preview from the designer, the ´Ñ´is showed correctly. The problem is when I try to launch the report from Java, using the Jasper Viewer. The ´Ñ´is marked as a '?'.
The jasper libraries used are
-jasperreports-6.2.2.jar
-jasperreports-fonts-6.2.2.jar
-jasperreports-functions-6.2.2.jar
-jasperreports-javaflow-6.2.2.jar
 
And "common" libraries, itext, etc...
 
The relevant bit of code to launch the report is here:
String jasperReport = JasperCompileManager.compileReportToFile
                    (reportPath);
 
            jasperPrint = JasperFillManager.fillReport(jasperReport,
                parameters, conn);
 
JasperViewer jasperViewer = new JasperViewer(jasperPrint, false);
JasperViewer.setVisible(true);

 

Being parameters a HashMap and conn, a connection to the database.

Am I missing anything? Thanks.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Yes. You didn't mention with which encoding you're getting the data from Informix. You need to get the data in UTF-8 encoding from Informix.

You also didn't specify which font you are using. If you are using special characters, font that support those characters must be made into a font extension jar file and put in the classpath.

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