gpt4 book ai didi

javascript - Kendo 导出到 PDF Unicode 支持

转载 作者:行者123 更新时间:2023-12-03 17:23:14 26 4
gpt4 key购买 nike

我一直在尝试将语言动态地合并到 Kendo 控件中,并且遇到了中文翻译问题,这些中文翻译存储为 Sql Server 数据库中的 Unicode 列表。

存储在数据库中的翻译

Chinese translations stored in DB as unicode

通过使用列 template 很快就启动并运行了 Kendo Grid 以显示这些 Unicode 中文。属性:

template: '#= Translation #'

剑道网格显示翻译

Grid displaying transformed Unicode in Chinese

我遇到的问题是 Excel/PDF 导出。它们不呈现 Unicode 值,就像 Kendo Grid 通过使用 template 所做的一样。 .相反,它们显示默认字体字符:

PDF 导出

Current export to PDF with missing translations

CSV 导出

Current export to Excel displaying unicode instead of translation

在对该问题进行研究后,我尝试了以下解决方案,但无济于事:
  • this recommendation 之后设置网格控件的字体系列; (为了与网站的其他部分保持一致,我不想这样做,我也不明白为什么这会起作用,因为实际的 Kendo Grid 本身正在完美地显示汉字):
    .k-widget {
    font-family: 'Arial Unicode MS';
    }


  • 设置列 encoded 属性为真:
    { field: "AnalyteName", title: "Analyte", attributes: { "class": "customKendoGridCell"}, width: "25%", encoded: true, template: '#= TranslationField #' },


  • 使用 kendo.template :

    If you want to render an encoded HTML value in a template, Kendo UI templates can automatically handle the encoding.


    template: '#=setFieldName(TranslationField)#'

    function setFieldName(TranslationField) {
    return kendo.template("<div id='box'>#: TranslationField #</div>");
    }

  • 这似乎显示了整个函数,而不仅仅是字段,也许 kendo.template需要在剑道网格列的上下文中以不同方式使用?

    Columns displaying kendo template approach

    我做了一个 Dojo example演示 PDF 导出的问题。

    最佳答案

    我从来没有遇到过 Unicode 的问题,不过,我知道一个可以帮助你的解决方案。

    .k-grid {
    font-family: "DejaVu Sans", "Arial", sans-serif;
    }

    在您的网格文件中使用此行,如在剑道中, 标准 PDF 字体不支持 Unicode 字符 .

    关于javascript - Kendo 导出到 PDF Unicode 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44966820/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com