Problem when rendering kurdish characters in PDF

Hi,

I'm trying PDF suite and there is a problem.

When creating a PDF file with KURDISH characters, words are rendering in a wrong way.

Untitled.png

Here is my sample code:

var document = new PdfDocument();

var page = document.Pages.Add();

PdfStringFormat sf = new PdfStringFormat();

sf.TextDirection = PdfTextDirection.RightToLeft;

PdfGraphics gr = page.Graphics;

var stream = new MemoryStream(File.ReadAllBytes("fonts\\tahoma.ttf"));

var font = new PdfTrueTypeFont(stream, 10);

gr.DrawString("‌هێرش فیتەر وەرشەی ئاراس", font, new PdfSolidBrush(new PdfColor(0, 0, 0)), new PointF(10, 10), sf);


document.Save("D:\\1.pdf");


9 Replies 1 reply marked as answer

SV Surya Venkatesan Syncfusion Team January 3, 2022 02:59 PM UTC

Hi mehdi,


We have checked the provided code snippet input text with the generated PDF document text. Both texts are similar. We have attached the text comparing snapshot for your reference,


If we check the given input text with different TrueType fonts. It shows the same result which was in the generated PDF document. We have attached the snapshot for your reference,


The reported issue does not from our library, it's from TTF file. We recommend to use the input text containing glyph style TrueType font to get a better result. Kindly let us know if you need any further assistance with this.


Regards,

Surya V



ME mehdi January 8, 2022 12:07 PM UTC

Hi  Surya,

Thanks for reply.

I think there is a problem with the PDF library. I provided a sample project that creates a PDF document and a bitmap file with the same fonts and same drawing methods.

The text in the bitmap is rendered perfectly and correctly, but in the PDF, it is not.

Untitled-1.png

The true type fonts are standard windows fonts. Please take a look at the attached project.

Regards,

Mehdi


Attachment: ConsoleApp2_7277d51a.zip


SV Surya Venkatesan Syncfusion Team replied to mehdi January 10, 2022 10:19 AM UTC

Hi Mehdi,


Thanks for the details. We were found the difference when rendering Kurdish characters in PDF while compared to bitmap. Currently, we are analyzing this and we will update the further details on January 12th 2022.


Regards,

Surya V



ME mehdi January 10, 2022 10:33 AM UTC

Hi  Surya,


Thanks for reply, I'm looking forward to new updates.


Regards,

Mehdi



GK Gowthamraj Kumar Syncfusion Team January 12, 2022 10:45 AM UTC

Hi Mehdi, 
 
Thank you for your patience,  
 
The input text has contain script language. We have support to draw complex script language text in the PDF document by using the ComplexScript property available in PdfStringFormat class. 
 
Please update the below highlighted changes in your sample to render the script language text properly, 
var document = new PdfDocument(); 
var page = document.Pages.Add(); 
PdfStringFormat sf = new PdfStringFormat(); 
sf.ComplexScript = true; 
sf.TextDirection = PdfTextDirection.RightToLeft; 
 
PdfGraphics gr = page.Graphics; 
 
var fontFiles = Directory.GetFiles("fonts"); 
 
var brush = PdfBrushes.Black; 
 
var top = 10; 
foreach (var file in fontFiles) 
{ 
var stream = new MemoryStream(File.ReadAllBytes(file)); 
var font = new PdfTrueTypeFont(stream, 10); 
gr.DrawString("‌هێرش فیتەر وەرشەی ئاراس", font, brush, new PointF(10, top), sf); 
gr.DrawString(font.Name, font, brush, new PointF(170, top), sf); 
top += 15; 
} 
 
 
 
 
Regards, 
Gowthamraj K 


Marked as answer

ME mehdi January 15, 2022 10:46 AM UTC

Hi  Gowthamraj,

Thanks a lot. Problem solved.



GK Gowthamraj Kumar Syncfusion Team January 17, 2022 06:42 AM UTC

Hi mehdi,

 
Thank you for your update. We are glad to know that your problem has been solved. 

Regards, 
Gowthamraj K 



SQ Sangar Qader replied to Gowthamraj Kumar July 12, 2023 02:55 PM UTC

Hi Gowthamraj...


im using FLutter, and I have same problem like Mehdi had regarding to rendering Kurdish Text.. i tried to apply the soluction mentioned earlier, but, there is not ComplexScript method available in PdfStringFormat class.. can you please provide the solution if there is an update in the syncfusion pdf generator package.. 


thanks



IJ Irfana Jaffer Sadhik Syncfusion Team July 13, 2023 09:54 AM UTC

Currently, we do not have support to draw complex script language texts such as Marathi, Tamil, Hindi, and more. We have logged the feature for “Complex script text drawing support in Flutter PDF” and added it to our feature request list. We will implement this feature in any of our upcoming releases.

 

You can track the feature status using the feedback from https://www.syncfusion.com/feedback/20541/complex-script-text-drawing-support-in-flutter-pdf



Loader.
Up arrow icon