my dog learned polymorphism
The moose likes Other Open Source Projects and the fly likes Currency Symbol Issue in iText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Currency Symbol Issue in iText" Watch "Currency Symbol Issue in iText" New topic

Currency Symbol Issue in iText

Joshi Sujit

Joined: Jul 29, 2010
Posts: 6
Hi All,

I am using iText 5.1.2 library to generate the dynamic report in PDF format. I have a requirement to display some of the currency symbols in PDF.
We are using unicode decimals to display these symbols.
Below is the details of currency's,
Currency-----Unicode decimal-----Unicode hex value
Dollar-------- 36---------------------0024

iText is not displaying currency symbol for the currency YEN and Peso if i use unicode decimal.
But if i use unicode hex value for YEN and Peso, iText is able to display YEN currency properly but failing to display for Peso.

Does some one know how to solve this issue?

Sujit Joshi
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

It would help to know what "using unicode decimals" actually meant. To me the simple and obvious way to deal with those characters would be to simply put them in ordinary Java strings. Apparently you have been doing something different. It isn't going to be possible to answer your question without knowing what that was.
Joshi Sujit

Joined: Jul 29, 2010
Posts: 6
Hi Paul,

We are receiving the decimal code of the currency from our backend logic and we are converting this into UTF8 format using iText function as below,
String currency = com.itextpdf.text.Utilities.convertFromUtf32(8369);

and we add this currency into PDF as below,
table.addCell(new Paragraph(currency, amtValueFont));

here, amtValueFont is using FontFactory.getFont(BaseFont.HELVETICA, 50, Font.BOLD, BaseColor.BLACK);
This above logic does not seem to work in PDF generated for both YEN and PESO currency symbols. Hence I have tried passing the hex code of the currency as below,

String currency = "\u20B1";
table.addCell(new Paragraph(currency, amtValueFont));

This new logic is working for YEN but not working for PESO.

I have also tried with sample java code to display PESO using hexcode, but the console display ? instead of actual symbol.

I hope this is more clear, please let me know how to resolve this.
Joshi Sujit

Joined: Jul 29, 2010
Posts: 6

I am stuck in this issue for long time and i need an urgent help for this, could any one suggest me for the approach/solution?

Sujit Joshi
I agree. Here's the link:
subject: Currency Symbol Issue in iText
It's not a secret anymore!