0

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

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

4

1 回答 1

0

您需要更改https://doddlereport.codeplex.com/SourceControl/latest#src/DoddleReport.iTextSharp/PdfReportWriter.csConvertStyleToFont文件的方法以支持 Identity_H 编码(Unicode 编码)。更多信息在这里

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

于 2013-08-22T18:44:13.960 回答