aggicd
aggicd

Reputation: 737

C# itext pdf creator Greek fonts not displaying

I am trying to create a pdf which contains greek characters. But it doesn't display them at all. I know its something to do with the font but I can't find out the correct way to print the greek characters.

Here is my code:

PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));
        iTextSharp.text.Font font5 = iTextSharp.text.FontFactory.GetFont(FontFactory.HELVETICA, 10);

document.Add(new Paragraph("User: " + NameTxt.Value));

If NameTxt.Value uses greek characters then is not displayed at all

Upvotes: 0

Views: 491

Answers (1)

atroul
atroul

Reputation: 219

Try that:

string sylfaenpath = Environment.GetEnvironmentVariable("SystemRoot") + "\\fonts\\sylfaen.ttf";
BaseFont sylfaen = BaseFont.CreateFont(sylfaenpath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font normal = new Font(sylfaen, 10f, Font.NORMAL, BaseColor.BLACK);

document.Add(new Paragraph("User: " + NameTxt.Value, normal));

Upvotes: 2

Related Questions