0

I am using codeplex doddlereport project to report my linq queries. It's simple and very successful. But there is only one problem for me. When i report to excel , html or csv files turkish characters seems ok. But when i try to export my queries to pdf with doddlereport.itextsharp turkish characters hidden. Hidden characters are ("İ,ı,Ş,ş,Ğ,ğ,Ö,ö,ç,Ç,ü,Ü"). Anyone uses doddlereport and export to pdf with turkish characters help me how do i success?

Or how can i change doddlereport font family for pdf files? Can be solution for me.

Ohlin
  • 4,068
  • 2
  • 29
  • 35
Erdinç
  • 267
  • 2
  • 7
  • 15

1 Answers1

0

You need to change ConvertStyleToFont method of https://doddlereport.codeplex.com/SourceControl/latest#src/DoddleReport.iTextSharp/PdfReportWriter.cs file to support Identity_H encoding (Unicode encoding). 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));
        }
    }
}

Or you can try http://pdfreport.codeplex.com

Community
  • 1
  • 1
VahidN
  • 18,457
  • 8
  • 73
  • 117