2013-08-21 86 views
0

我正在使用codeplex doddlereport項目來報告我的linq查詢。這很簡單,非常成功。但對我來說只有一個問題。當我報告excel,html或csv文件土耳其人字符似乎確定。但是,當我嘗試導出我的查詢PDF隱藏doddlereport.itextsharp土耳其字符。隱藏的字符是(「İ,ı,Ş,ş,Ğ,Ö,ö,ç,Ç,ü,Ü」)。任何人使用doddlereport和出口到pdf土耳其字符幫助我,我如何成功?Doddle Report iTextSharp土耳其文字符

或者我該如何更改pdf文件的doddlereport字體家族?可以爲我解決。

回答

0

您需要更改ConvertStyleToFont方法https://doddlereport.codeplex.com/SourceControl/latest#src/DoddleReport.iTextSharp/PdfReportWriter.cs文件以支持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

+0

請你給我一個代碼示例嗎? –

+0

添加了修改後的方法。 – VahidN