sprtnbst
sprtnbst

Reputation: 60

Polish characters in PDF document using iTextSharp

I am trying to create a table in PDF file filled with text with polish characters (ą, ę, ć, ż etc.).

dokument.Open();

BaseFont arial = BaseFont.CreateFont(@"C:\Windows\Fonts\ARIALUNI.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
Font font = new Font(arial, 9);

(...)

dokument.Add(new iTextSharp.text.Paragraph(" ", font));

(...)

table.AddCell(new Phrase(wyraz, font));

And I get text with correct font (ARIALUNI at this case, but i have tried Arial, Helvetica, Courier, Times...) but without polish characters.

For example: I need a word "wymawiać".

With ARIALUNI i get: "wymawia�"

With other fonts i get: "wymawia"

I also tried other encodings, like CP1250, CP1252, CP1257 with these fonts. What should I do?

Upvotes: 0

Views: 1559

Answers (1)

milleniumbug
milleniumbug

Reputation: 15814

This doesn't look like a font issue, it's an encoding issue.

General rule with working with I/O is "decode all input, encode all output" - this also means you must know which encoding you use in your target file.

If you fail to do that, you may see artefacts like these.

Upvotes: 1

Related Questions