Search code examples
asp.net-mvcpdflocalizationglobalizationviewbag

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


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


Solution

  • Issue resolved:

    To get around the issue I installed the Arial Unicode MS Bold font and removed the strong tag html reference.

    I now use a CSS Class instead of the strong tag, example below:

    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>