0

How can I insert this currency symbol: "₡" to pdf, using itextSharp 5.5.10?

this is what I have:

string fontpath = "C:\\Users\\PC\\Desktop\\";

var font = BaseFont.CreateFont(fontpath + "arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

iTextSharp.text.Font fontArial = new iTextSharp.text.Font(font, 8);

string Colones = new Chunk("\u20A1", fontArial).ToString();

I am able to get the symbol but. When I want to insert the symbol in the pdf, it does not work. I do it like this:

table2.AddCell(new PdfPCell(new Paragraph(Colones+" "+Subtotal)));

I don't know what I am doing wrong.

Thanks in advance.

Errol Chaves Moya
  • 307
  • 2
  • 5
  • 20

1 Answers1

0

I think this might be a font problem. If iText detects that the font you're using (Arial in this case) can not render that symbol, it will not insert the glyph in the content.

Creating a simple example

PdfWriter writer = new PdfWriter("C:\\CurrencySymbol.pdf");
PdfDocument pdf = new PdfDocument(writer);
Document doc = new Document(pdf);

doc.add(new Paragraph("AB₡DEF"));

doc.flush();
doc.close();

yields the same problem. The resulting pdf only contains the text "ABDEF".
Try switching the font.

Joris Schellekens
  • 8,483
  • 2
  • 23
  • 54