Html to pdf some characters are missing (itextsharp)

前端 未结 11 1754
不思量自难忘°
不思量自难忘° 2020-12-06 02:34

I want to export gridview to pdf by using the itextsharp library. The problem is that some turkish characters such as İ,ı,Ş,ş etc... are missing in the pdf document. The cod

11条回答
  •  鱼传尺愫
    2020-12-06 02:54

    thank you very much all who posted the samples..

    i use the below solution from codeproject , and there was the turkish char set problems due to font..

    If you use htmlworker you should register font and pass to htmlworker

    http://www.codeproject.com/Articles/260470/PDF-reporting-using-ASP-NET-MVC3

          StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
                    styles.LoadTagStyle("h3", "size", "5");
                    styles.LoadTagStyle("td", "size", ".6");
                    FontFactory.Register("c:\\windows\\fonts\\arial.ttf", "Garamond");   // just give a path of arial.ttf 
                    styles.LoadTagStyle("body", "face", "Garamond");
                    styles.LoadTagStyle("body", "encoding", "Identity-H");
                    styles.LoadTagStyle("body", "size", "12pt");
                    using (var htmlViewReader = new StringReader(htmlText))
                    {
                        using (var htmlWorker = new HTMLWorker(pdfDocument, null, styles))
                        {
                            htmlWorker.Parse(htmlViewReader);
                        }
                    }
    

提交回复
热议问题