Hi
Hi Mohammad Reza,
Thanks for contacting support.
In order to render Right to Left languages (Urdu, Arabic, Persian etc), you need to set the value of text.TextInfo.IsRightToLeft
as true;
. However, I have observed that when using IsHtmlTagSupported
as True
, the Arabic contents are not appearing in the correct manner (characters appearing in reverse order and they are not appearing as single word). For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-37065. We will investigate this issue in detail and will keep you updated on a correction. We apologize for your inconvenience.
However, if you set the value of IsHtmlTagSupported
as False
, the contents appear properly. Please take a look at the following code snippet and sample PDF generated on my end.
[C#]
var pdfDocument = new Pdf();
var pdfSection = pdfDocument.Sections.Add();
pdfSection.TextInfo.FontEncoding = "UTF-8";
pdfDocument.TextInfo.FontEncoding = "UTF-8";
pdfSection.Paragraphs.Add(new Text("report.Title"));
pdfSection.Paragraphs.Add(new Text("report.DateTime.ToShortDateString()"));
var text = new Text("سلام") { IsHtmlTagSupported = false };
text.TextInfo.IsRightToLeft = true;
// set font as Arial Unicode MS as it supports Non-English characters
text.TextInfo.FontName = "Arial Unicode MS";
pdfSection.Paragraphs.Add(text);
// embed unicode font subset in PDF
pdfDocument.SetUnicode();
pdfDocument.Save("c:/pdftest/Arabic_Persian_test.pdf");
Good to know that adding the font name (arial unicode ms) is helping solve the problem.
Thank you, I have done as you said but the problem still exist :((
ipazooki:
Thank you, I have done as you said but the problem still exist :((When IsHtmlTagSupported = true then all text content will be separated but when it is FALSE then content is like usual and correct !
The issues you have found earlier (filed as PDFNEWNET-37065) have been fixed in Aspose.Pdf for .NET 9.6.0.
Hi Mohammad,
In reference to the fix for PDFNEWNET-37065, please use the new generator code below. It will help you accomplish the task.
string outFile = "37065.pdf";
Document doc = new Document();
Page page = doc.Pages.Add();
TextFragment text = new TextFragment("سلام");
text.TextState.Font = FontRepository.FindFont("Arial Unicode MS");
page.Paragraphs.Add(text);
doc.Save(outFile);
Please feel free to contact us for any further assistance.
Best Regards,