Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Well, I am trying to export some data from my WinForms application to a PDF file. I have downloaded some fonts which support Turkish language characters. In the Turkish language, there are some letters like ?,?,?,?,ü,?. My code has no problems with showing ?,?,ü but somehow when the user inputs ?, ? or ?, these letters get represented as blank in the PDF file.

My code is below:

Document doc= new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
PdfWriter wri=PdfWriter.GetInstance(doc, new FileStream("Test.pdf", FileMode.Create));
doc.Open();

BaseFont bf = BaseFont.CreateFont(@"C:aller.ttf", BaseFont.CP1252, BaseFont.EMBEDDED);
iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 10, iTextSharp.text.Font.NORMAL);
Paragraph p1 = new Paragraph(new Chunk("????ü?", font));

doc.AddLanguage("tr-TR");
wri.SetLanguage("tr-TR");
doc.Add(p1);
doc.Close();

So, where is my mistake?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
759 views
Welcome To Ask or Share your Answers For Others

1 Answer

after tryings, I found the answer;

BaseFont bF = BaseFont.CreateFont("C:\windows\fonts\arial.ttf", "windows-1254", true);
 iTextSharp.text.Font f = new iTextSharp.text.Font(bF, 12f, iTextSharp.text.Font.NORMAL);
 Chunk c = new Chunk();
 c.Font = f;
 iTextSharp.text.Document document = new iTextSharp.text.Document();
 PdfWriter.GetInstance(document, new FileStream(@"C:gorsel.pdf", FileMode.Create));
 string text = "kü?ük harf türk?e karakterler : ? ? ? ? ? ü 
" +
 " BüYüK TüRK?E KARAKTERLER : ? ? ? ? ? ü";
 c.Append(text);
 document.Open();
 document.Add(new Paragraph(c));
 document.Close();

now I can use all special characters in my PDF file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...