1

I am using iText to create pdf in Java and want to add currency symbol to it. I have both ISO 3 digit currency code and Unicode for each respective symbols. Condition is: Only one currency symbol will be added at a time. I have done some work in this direction but I need some better and quick solution.

: MY Work :

For example if I want to add ₹ symbol for INR. I need the font file that supports ₹ symbol

String currency = "INR"; //Will be provided but will be dynamic
public String FONT = "resources/fonts/FreeSans.ttf"; //should be selected dynamically depending upon the currency language

I have Embedded the font file in my code

Font f = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);


Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(dest)); //dest is the destination of file
document.open();
String currencyUnicode = "\u20B9"; //Here unicode will come dynamically depending on currency code
Paragraph currencySymbol = new Paragraph(currencyUnicode, f);
document.add(currencySymbol); //This will add ₹ to pdf

I have read few similar type of questions with their solutions, but there currency symbol is static and I want to support all currency symbols dynamically.

Radhesh Vayeda
  • 881
  • 7
  • 20
  • Read the documentation: [Why isn't the Rupee symbol showing?](http://developers.itextpdf.com/question/why-isnt-rupee-symbol-showing) / [How to display indian rupee symbol?](http://developers.itextpdf.com/question/how-display-indian-rupee-symbol) (iText 5) or [Why isn't the Rupee symbol showing?](http://developers.itextpdf.com/content/best-itext-questions-stackoverview/font-examples/itext7-why-isnt-rupee-symbol-showing) / [How to display indian rupee symbol?](http://developers.itextpdf.com/content/best-itext-questions-stackoverview/font-examples/itext7-how-display-indian-rupee-symbol) (iText 7) – Bruno Lowagie Jun 30 '17 at 12:01
  • @BrunoLowagie Hey... Yes I already read that question, but in that method currency symbol is static whereas in my case, currency symbol will be dynamic and if I use that method I will have to change font file depending upon the currency. I want some common solution for all supported currency symbols. – Radhesh Vayeda Jun 30 '17 at 12:29
  • Since you are using iText 5, did you try using the `FontSelector`? See [How to identify a single font that can print all the characters in a string?](http://developers.itextpdf.com/question/how-identify-single-font-can-print-all-characters-string) The answers are out there (and people like me have sacrificed plenty of time to put them there). – Bruno Lowagie Jun 30 '17 at 12:34
  • @BrunoLowagie Thanks, but this too is not fulfilling my requirement. Since I cant disclose my project over here can you please provide me your other point of contact where we can discuss little more about it. – Radhesh Vayeda Jun 30 '17 at 12:52
  • If you are working in a closed source context, you are not allowed to use iText for free under the AGPL. That means that you (should) have purchased a commercial license from iText Software. With this commercial contract, you also have a support contract. That support contract gives you access to a closed ticketing system. See http://itextpdf.com/support – Bruno Lowagie Jun 30 '17 at 13:41
  • Ohh... I will mark your point and do as required.. – Radhesh Vayeda Jun 30 '17 at 13:56

0 Answers0