itextSharp - html to pdf some turkish characters are missing

后端 未结 3 515
清酒与你
清酒与你 2020-12-10 22:51

When I am trying to generate PDF from HTML, some Turkish characters like ĞÜŞİÖÇ ğüşıöç are missing in PDF, I see a space in place of these characte

3条回答
  •  情书的邮戳
    2020-12-10 23:21

    Same my problem solved this code;

    var pathUpload = Server.MapPath($"~/Test.pdf");
    using (var fs = System.IO.File.Create(pathUpload))
    {
       using (var doc = new Document(PageSize.A4, 0f, 0f, 10f, 10f))
       {
           using (var writer = PdfWriter.GetInstance(doc, fs))
           {
               doc.Open();
               BaseFont baseFont = BaseFont.CreateFont("C:\\Windows\\Fonts\\Arial.ttf", "windows-1254", true);
               Font fontNormal = new Font(baseFont, 24, Font.NORMAL);
    
               var p = new Paragraph("Test paragrapgh İÇşıĞğŞçöÖ", fontNormal);
               doc.Add(p);
               doc.Close();
           }
       } }
    

提交回复
热议问题