PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Problem showing gujarati word
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4431
Page 1 of 1

Author:  snj886 [ Sat Apr 15, 2023 1:52 pm ]
Post subject:  Problem showing gujarati word

I am trying to generate PDF document using pdfsharp with gujarati font (Noto Sans Gujarati - https://fonts.google.com/noto/specimen/Noto+Sans+Gujarati/)

I am writing text "સભ્યના બિલ ઓર્ડર નંબરની વિગતો" but on pdf it is shown differently, here is image
Image

But when you copy & paste that text you will get the exact text "સભ્યના બિલ ઓર્ડર નંબરની વિગતો" - just showing incorrectly

Here is the code,
Code:
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();
}


So, i think i am missing something to make it work correctly. please someone point me out.

thanks

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/