【问题标题】:Doddle Report iTextSharp Turkish CharactersDoddle 报告 iTextSharp 土耳其语字符
【发布时间】:2013-08-21 17:27:31
【问题描述】:

我正在使用 codeplex doddlereport 项目来报告我的 linq 查询。这很简单而且非常成功。但对我来说只有一个问题。当我向 excel、html 或 csv 文件报告时,土耳其语字符似乎没问题。但是,当我尝试将我的查询导出为 pdf 并隐藏 doddlereport.itextsharp 土耳其字符时。隐藏字符是 ("İ,ı,Ş,ş,Ğ,ğ,Ö,ö,ç,Ç,ü,Ü")。任何人都使用 doddlereport 并导出到带有土耳其字符的 pdf 帮助我如何成功?

或者如何更改 pdf 文件的 doddlereport 字体系列?可以为我解决。

【问题讨论】:

    标签: c# asp.net itextsharp


    【解决方案1】:

    您需要更改https://doddlereport.codeplex.com/SourceControl/latest#src/DoddleReport.iTextSharp/PdfReportWriter.cs 文件的ConvertStyleToFont 方法以支持Identity_H 编码(Unicode 编码)。 More info here

    using DoddleReport;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using Font = iTextSharp.text.Font;
    
    namespace Test
    {
        public class PdfReportWriter // …
        {
            public static Font ConvertStyleToFont(ReportStyle reportStyle, string fontFamily)
            {
                var style = Font.NORMAL;
                if (reportStyle.Underline)
                {
                    style = Font.UNDERLINE;
                }
                else if (reportStyle.Bold || reportStyle.Italic)
                {
                    if (reportStyle.Bold && reportStyle.Italic)
                    {
                        style = Font.BOLDITALIC;
                    }
                    else if (reportStyle.Bold)
                    {
                        style = Font.BOLD;
                    }
                    else
                    {
                        style = Font.ITALIC;
                    }
                }
    
                // todo: to use this method you need to register your fonts at the beginning of the report
                // FontFactory.Register(@"c:\windows\fonts\myfont.ttf");
    
                return FontFactory.GetFont(
                    fontFamily, BaseFont.IDENTITY_H, BaseFont.EMBEDDED,
                    reportStyle.FontSize, style,
                    new BaseColor(reportStyle.ForeColor.R, reportStyle.ForeColor.G, reportStyle.ForeColor.B));
            }
        }
    }
    

    或者你可以试试http://pdfreport.codeplex.com

    【讨论】:

    • 添加修改方法。
    猜你喜欢
    • 1970-01-01
    • 2014-02-19
    • 2015-01-07
    • 2018-08-03
    • 1970-01-01
    • 2014-07-25
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多