|
//Create a new PDF document
PdfDocument document = new PdfDocument();
//Add a page to the document.
PdfPage page = document.Pages.Add();
//Create PDF graphics for the page.
PdfGraphics graphics = page.Graphics;
string path = @"E:\ArialUnicode\arial-unicode-ms.ttf";
Stream fontStream = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
//Create a new PDF true type font.
PdfTrueTypeFont tFont = new PdfTrueTypeFont(fontStream, 12, PdfFontStyle.Regular);
//Draw the text
graphics.DrawString("Sample Привет мир", tFont, PdfBrushes.Black, Syncfusion.Drawing.PointF.Empty);
FileStream file = new FileStream("../../../OutputRussian.pdf", FileMode.Create, FileAccess.Write);
//Save the PDF document
document.Save(file);
//Close the dococument
document.Close(true); |
The same solution does not work for Hindi (and other Indian language) although it works (for hindi etc.) in .Net Framework WebForms but does not work in ASP.NET Core/.net6.0 web applications.
Hi Abhishek,
We can draw the complex script language text such as Thai, Hindi, Tamil, Kannada and more in a PDF document by enabling the ComplexScript property available in PdfStringFormat class. We have attached the Net 6.0 sample for drawing the Hindi characters using our library, please try the sample on your end and let us know the result.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample6_076409139
Output: https://www.syncfusion.com/downloads/support/directtrac/general/pd/HindiCharacters576836894
Please refer to the below link for more information,
KB: https://www.syncfusion.com/kb/5996/how-to-draw-the-complex-scripts-in-a-pdf-document
UG: https://help.syncfusion.com/file-formats/pdf/working-with-text#drawing-complex-script-language-text
Please let us know if you need any further assistance in this.
Regards,
Surya V