Asp.Net Core Simplified Chinese Characters Not Displaying Correct PDF Export (Localization, Globalization)

时间:2017-07-12 08:16:41

标签: asp.net-mvc pdf localization globalization viewbag

I am having an issue with displaying special characters on a PDF Export however it seems to be an issue with Translations on the View page itself.

The Image below shows a html table on the top right corner not translating correctly to Chinese. However The data table below the html table exports correctly. This was after adding in the font font-family: "Arial Unicode MS" and "Arial Unicode MS Bold"

pdf_export Html Table Code

<div>
            <table class="refRangeTable">
                <tr>
                    <th>@Html.Raw((ViewBag.Translations["CatalogueNumber"]))</th>
                    <th>@Html.Raw((ViewBag.Translations["LotNumber"] ))</th>
                    <th>@Html.Raw((ViewBag.Translations["Size"]))</th>
                    <th>@Html.Raw((ViewBag.Translations["Expiry"] ))</th>
                </tr>
                <tr>
                    <td width="150px"><strong>#: viewModel.CatalogueNumber #</strong></td>
                    <td width="100px"><strong>#: viewModel.LotNumber #</strong></td>
                    <td width="100px"><strong>#: viewModel.Size #</strong></td>
                    <td width="150px"><strong>#: viewModel.ExpiryDate #</strong></td>
                </tr>
            </table>
</div>

Any suggestions would be appreciated if any more details are needed I am happy to provide.. Thanks

1 个答案:

答案 0 :(得分:0)

已解决问题

为了解决这个问题,我安装了Arial Unicode MS Bold字体并删除了强标记html参考。

我现在使用CSS Class而不是强标记,例如:

<强> CSS

@font-face {
   font-family: "Arial Unicode MS";
   src: url("../Localisation/Fonts/ARIALUNI.TTF") format("truetype");
}

@font-face {
   font-family: "Arial Unicode MS Bold";
   src: url("../Localisation/Fonts/Arial-Unicode-Bold.ttf") format("truetype");
}


.boldPdfExport {
   font-family: "Arial Unicode MS Bold" !important;
}

<强> HTML

<div>
        <table class="refRangeTable">
            <tr>
                <th>@Html.Raw((ViewBag.Translations["CatalogueNumber"]))</th>
            </tr>
            <tr>
                <td width="150px" class="boldPdfExport"> #: viewModel.CatalogueNumber #</td>
            </tr>
        </table>
</div>