在 pdfsharp c#中显示古吉拉特语单词的问题

问题描述 投票:0回答:0

我正在尝试使用带有古吉拉特语字体的 pdfsharp 生成 PDF 文档(Noto Sans Gujarati - https://fonts.google.com/noto/specimen/Noto+Sans+Gujarati/

我正在写文本“સભ્યના બિલ ઓર્ડર નંબરની વિગતો”但在 pdf 上它显示不同,这里是图片

但是,当您将该文本复制并粘贴到另一个编辑器(如记事本 ++)时,您将获得准确的文本“સભ્યના બિલ ઓર્ડર નંબરની વિગતો”- 只是显示不正确

这是代码,

XFont font_400 = new XFont("Noto Sans Gujarati", 12, XFontStyle.Regular, new XPdfFontOptions(PdfFontEncoding.Unicode));

using (PdfDocument document = new PdfDocument())
{
   document.Info.Title = "My Gujarati Test Document";
   document.Info.Author = "snj886";

   PdfPage page = document.AddPage();
   page.Size = PdfSharp.PageSize.A4;

   using (XGraphics gfx = XGraphics.FromPdfPage(page))
   {
      gfx.MUH = PdfFontEncoding.Unicode;
      XTextFormatter tf = new XTextFormatter(gfx);
      tf.Alignment = XParagraphAlignment.Left;
      tf.DrawString("સભ્યના બિલ ઓર્ડર નંબરની વિગતો", font_400, XBrushes.Black, new XRect(45, 45, page.Width - 90, 90), XStringFormats.TopLeft);
      gfx.DrawString("સભ્યના બિલ ઓર્ડર નંબરની વિગતો", font_400, XBrushes.Black, new XRect(45, 90, page.Width - 90, 90), XStringFormats.TopLeft);
   }

   document.Save("GujaratiTest.pdf");
   document.Close();
}

所以,我想我缺少一些让它正常工作的东西。请有人指出我。

谢谢

c# unicode pdfsharp
© www.soinside.com 2019 - 2024. All rights reserved.