I want to display Special Character India Rupee Symbol in iTextPDf,
My Code:
Font fontRupee = FontFactory.GetFont("Arial", "₹", true, 12);
Chunk chunkRupee = new Chunk(" ₹ 5410", font3);
I want to display Special Character India Rupee Symbol in iTextPDf,
My Code:
Font fontRupee = FontFactory.GetFont("Arial", "₹", true, 12);
Chunk chunkRupee = new Chunk(" ₹ 5410", font3);
Find out which font has indian rupee symbol and import that to iTexy by
Note: While using custom fonts you may need to use some other characters or unicode(U+20B9) for Indian rupee
like
Chunk chunkRupee = new Chunk("W", rupeeFont);
here in that particular custom font W is for Indian rupee. it depends on that font.It's never a good idea to store a Unicode character such as ₹ in your source code. Plenty of things can go wrong if you do so:
From your code sample, it's evident that you're not familiar with the concept known as encoding. When creating a
Font
object, you pass the rupee symbol as encoding.The correct way to achieve what you want looks like this:
Note that there are two possible Unicode values for the Rupee symbol (source Wikipedia): \u20B9 is the value you're looking for; the alternative value is \u20A8 (which looks like this: ₨).
I've tested this with arialuni.ttf and arial.ttf. Surprisingly MS Arial Unicode was only able to render ₨; it couldn't render ₹. Plain arial was able to render both symbols. It's very important to check if the font you're using knows how to draw the symbol. If it doesn't, nothing will show up on your page.