majorsilence / My-FyiReporting

Majorsilence Reporting, .NET report designer and viewer. Fork of fyireporting,
Apache License 2.0
348 stars 201 forks source link

PDF Report Japanese and Chinese reports ? #152

Closed doerler closed 1 year ago

doerler commented 7 years ago

Is it possible to generate PDF reports with Japanese and Chinese Charakters. They look fine in the designer, but the generated reports are not showing them. The old PDF Output method doesn't show the right characters.

Is this just a report issue (correct font) or is there a bigger problem with My-FyiReporting supporting chinese and japanese reports ?

doerler commented 7 years ago

I've found the problem - the Arial fonts (which are used in RenderPdf_iTextSharp.cs) don't support Japanese or Chinese characters.

My changes in RdlEngine/Render/RenderPdf_iTextSharp.cs: I've added this function

public bool IsAsian(string[] text)
{
    bool asian = false;
    for (var i = 0; i < text.Length; ++i)
    {
        asian |= text[i].Any(c => c >= 0x4e00);
        if (asian)
        {
            break;
        }
    }
    return asian;
}

and changed the function AddText (line 374):

else if (face == "Arial")
{
    if (IsAsian(sa))
    {
        face = "Arial Unicode MS";
        fontname = "arialuni.ttf";
    }
    else if (si.IsFontBold() && si.FontStyle == FontStyleEnum.Italic)

Not the most elegant way to solve this problem, but maybe it helps somebody else.

majorsilence commented 7 years ago

Open a pull request and I'll merge in the changes.

doerler commented 7 years ago

Created pull request: https://github.com/majorsilence/My-FyiReporting/pull/153

doerler commented 7 years ago

the pull request was missing two Japanese scripts. Opened a new pull request: https://github.com/majorsilence/My-FyiReporting/pull/154

majorsilence commented 7 years ago

great. thanks.

psoares33 commented 6 years ago

My fix allows the use of other CJK fonts, I think this can be closed.