Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Currency Symbol Issue in iText

 
Joshi Sujit
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
==================================
YEN-----------165--------------------00a5
Dollar-------- 36---------------------0024
Euro----------8364-------------------20ac
Pound--------163---------------------00a3
Peso----------8369--------------------20b1

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?

Thanks,
Sujit Joshi
 
Paul Clapham
Sheriff
Pie
Posts: 20764
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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?

Thanks,
Sujit Joshi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic