gpt4 book ai didi

C# - NReco.PdfGenerator 非英文字符不呈现

转载 作者:行者123 更新时间:2023-11-30 21:39:15 33 4
gpt4 key购买 nike

我正在使用 NReco.PdfGenerator 库从 html 生成 pdf。它适用于英语。我还需要包括 non-english language(marathi) ,在那种情况下不能像预期的那样工作。渲染黑盒。

这是我的操作方法:

public ActionResult Assesment_DownloadResultSummaryData(string htmlContent){
var htmlToPdf = new HtmlToPdfConverter();
var margins = new PageMargins();
margins.Bottom = 10; // margins.Left = 5;margins.Right = 5;
margins.Top = 10;
htmlToPdf.Margins = margins;
htmlToPdf.CustomWkHtmlPageArgs = "--enable-smart-shrinking --encoding <encoding>";
htmlToPdf.PageFooterHtml = $@"page <span class=""page""></span> of <span class=""topage""></span><br />";
//htmlToPdf.Orientation = NReco.PdfGenerator.PageOrientation.Portrait;
htmlToPdf.Zoom = 1.0f;
return File(htmlToPdf.GeneratePdf(htmlContent, null), "application/pdf","myFile.pdf");

}

我也试过用

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

但不工作。也尝试像这样解码为 un​​icode:

      byte[] utf8Bytes = Encoding.Default.GetBytes(htmlContent);

byte[] utf16Bytes = Encoding.Convert(Encoding.UTF8, Encoding.Unicode, utf8Bytes);

htmlContent = Encoding.Unicode.GetString(utf16Bytes);

这对我也不起作用。我的 html 包含像 विषय,मूल्यांकन प्रकार 这样的字符。在我的 pdf 中它显示为

部分htmlContent:

   <tbody><tr>
<td colspan="6"><p><b>मुल्यांकन निकाल</b></p></td>
</tr>
<tr>

<td style="width:5%"><h4><b>वर्ग :</b></h4></td>
<td style="width:10%;text-align:left;"><h4><b>Class 1-A</b></h4></td>
<td style="width:10%"><h4><b>बॅच :</b></h4></td>
<td style="width:40%;text-align:left;"><h4><b> 25-07-2017-Class 1-A-General Knowledge-English-1</b></h4></td>
<td style="width:20%"><h4><b>विद्यार्थ्यांची एकूण संख्या :</b></h4></td>
<td style="width:10%"><h4><b>18</b></h4></td>
</tr>
<tr >
<td style="width:20%"><h4><b>विषय :</b></h4></td>
<td style="width:10%;text-align:left;"><h4><b>English</b></h4></td>
<td style="width:10%"><h4><b>विषय :</b></h4></td>
<td style="width:30%;text-align:left;"><h4><b>General Knowledge</b></h4></td>
<td style="width:20%"><h4><b>उपस्थित विद्यार्थी संख्या :</b></h4></td>
<td style="width:10%"><h4><b>17</b></h4></td>
</tr>

</tbody>

我们将不胜感激。

最佳答案

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

这个命令对我有用。

关于C# - NReco.PdfGenerator 非英文字符不呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45305211/

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