views:

279

answers:

2

Hi, I am trying to typeset a pdf with iTextSharp library, but I cannot find anywhere how to handle diacritics. Since I found tables of contents of two books about iTextSharp where diacritics has a section, I suppose it is doable. So the question is

How to typeset "ř" ?

In addition, is there some guide or link about this problem?

Thanks in advance.

A: 

Diacritics are simply unicode characters. You will have to embed an unicode font into the PDF. See this thread for Java examples, I assume they will be almost the same in C#

Bozho
+3  A: 

You're going to need to figure out what the Unicode representation is for your diacritical characters. You can embed Unicode characters into a string literal with \u[unicode value in hex]; e.g.

string s = "\u0159";  // Should be your character

You may also need to choose a font that can represent the characters correctly:

bf = BaseFont.CreateFont(...);
font = new Font(bf, 12);
document.Add(new Paragraph(s, font);
glaxaco
The problem was not exactly on the chosen font, but on the encoding. I didn't notice that previously, however thanks.Btw as far as i know all strings in c# are translated into unicode characters.
Trimack
True enough. In contrived code examples typically used in answers, we're often hard-coding strings, but in real use, the problem is often getting the encoding right when reading text into a string from an outside source (user input, text file, database, etc.)
glaxaco