Jump to content

UTF-8 encoding in PDF


Recommended Posts

Hello All,

I'm a newbie here. My requirement is that I need to print a dynamic report containing UTF-8 characters to PDF. This has to be done without using JRXML file. I'm able to view UTF-8 characters in Jasper ReportViewer. But when I print to PDF file, the UTF-8 characters are not correctly printed. Only some characters gets printed. This problem exists only for printing to PDF file. I can successfuly print to XML, XLS, HTML, etc.

The sample code is listed below.            

Also, please help on how to auto-adjust column size when printing to different formats.

Thanks in advance,


               JRDesignStyle unicodeChars = new JRDesignStyle();               unicodeChars.setName("Unicode_Chars");               unicodeChars.setFontName("Arial");               unicodeChars.setFontSize(12);               unicodeChars.setItalic(true);               unicodeChars.setPdfFontName("Arial");               unicodeChars.setPdfEncoding("UTF-8");               italicStyle.setPdfEmbedded(false);               jasperDesign.addStyle(unicodeChars);
Link to comment
Share on other sites

  • 1 month later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic



This is more of a font related problem.

Please check the supplied /demo/samples/fonts and /demo/samples/unicode samples provided with the JR project.

Note that they are making use of a font extension present in the /demo/fonts folder. That font extenions mapps two open source TTF font families called DejaVu Sans and DejaVu Serif.

Make sure that you control the fonts when you export to PDF and that those fonts are indeed available at PDF export time.

Go with a font extension for that, as the Arial font will not be availble on the machine, unless you ship it with your application.


I hope this helps.



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