0

I try to create a PDF file with iTextSharp version 5.5.9.0 (I added from NuGet). All works fine but not and Romanian diacritics (ȘșȚțăĂÂâ). I read a lot of articles with solutions about that but nothing work. Now I founded a solution that from all diacritics appear only "ăĂÂâ" others not appear. That is my code:

Dim bf As BaseFont = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, False)
Dim normalFont As New iTextSharp.text.Font(bf, 9, Font.NORMAL)
Dim par As New Paragraph("ȘșȚțăĂÂâ", normalFont)
pdfDoc.Add(par)

Can anybody write me what encoding I must write to have all Romanian diacritics.

Solution: from "Paulo Soares" is right. I made only some correction. I downloaded one font that support Romanian language from this site: https://www.fontsquirrel.com/fonts/list/language/romanian/ than I loaded it on myBaseFont with encoding BaseFont.IDENTITY_H Here is the code:

Dim ttfPath As String = "C:\Test\DejaVuSerif.ttf" 'Path to font file
Dim bf As BaseFont = BaseFont.CreateFont(ttfPath, BaseFont.IDENTITY_H, False)
Dim normalFont As New iTextSharp.text.Font(bf, 9, iTextSharp.text.Font.NORMAL)

1 Answer 1

6

The built-in fonts like BaseFont.TIMES_ROMANdon't have the Romanian diacritics. You'll need an external font like times.ttf:

Dim bf As BaseFont = BaseFont.CreateFont("c:\windows\fonts\times.ttf", BaseFont.IDENTITY_H, True)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.