Free Support Forum - aspose.com

Amharic language doesn't display

Hello,

I’m trying to display some amharic language like this

Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();
Text txt = new Aspose.Pdf.Generator.Text(“የአዲሱ ጠ/ሚ ሹመት መፅደቅ”);
txt.TextInfo.IsUnicode = true;
txt.TextInfo.FontName = “Arial Unicode MS”;
sec1.Paragraphs.Add(txt);

//I try that too
//pdfConv.SetUnicode();

pdfConv.Save(@“D:/testAmharic.pdf”);
(new System.Diagnostics.Process { StartInfo = { FileName = @“D:/testAmharic.pdf” } }).Start();

I try the last version of aspose pdf fro .NET but couldn’t make it work. Can you help me please ?

Thanks in advance

Hi Anouck,


Thanks for using our products.

In order to display the Amharic text in PDF document, you need to try using the font which supports these characters/language. I have tested the scenario where I have used Amharic-VG2 Main.ttf and as per my observations, only one characters is appearing in resultant document. For
the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-34656. We
will investigate this issue in details and will keep you updated on the status
of a correction.

We
apologize for your inconvenience.

PS, For your reference, I have also attached the resultant PDF which I have generated over my end.

Hi !

Thanks a lot for your quick answer. I discover that the font named “Nyala” worked with amharic. In fact I copied/pasted my characters in amharic language in a word processor software and it chose itself this font.

Then I tried to apply it to my code and it worked.
txt.TextInfo.FontName = “Nyala”;

Then I can use a regexp like this one :
var regex = new Regex(@"[\p{IsEthiopic}]");
regex.IsMatch(“የአዲሱ ጠ/ሚ ሹመት መፅደቅ”);
Which send me true when found Ethiopic and Amharisch characters and then I can change my fontName depending on it.

Hope it will help other people and thanks a lot for giving me the idea :slight_smile:

Sorry, I’m here again.
In my table where I can have amharic characters, I have other characters so all the cells are not with the same font. Below you can see my code where I add two cells in a table and use two different font in the two cells. As soon as I’m doing that the amharic doesn’t display anymore.

Can you help me again, please ?

Here’s my code

Aspose.Pdf.Generator.Pdf pdfConv = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sec1 = pdfConv.Sections.Add();

Aspose.Pdf.Generator.Table tab = new Aspose.Pdf.Generator.Table();
tab.ColumnWidths = “500”;
Aspose.Pdf.Generator.Row rowContent = tab.Rows.Add();
var cell = rowContent.Cells.Add(“የአዲሱ ጠ/ሚ ሹመት መፅደቅ”);
var borderColor = new Color { ColorSpaceType = ColorSpaceType.Rgb, RgbColorSpace = System.Drawing.Color.Black };
cell.Border = new BorderInfo();
cell.Border.Top = new GraphInfo { Color = borderColor, LineWidth = 0.5f };
cell.Border.Bottom = new GraphInfo { Color = borderColor, LineWidth = 0.5f };
cell.Border.Left = new GraphInfo { Color = borderColor, LineWidth = 0.5f };
cell.Border.Right = new GraphInfo { Color = borderColor, LineWidth = 0.5f };
cell.DefaultCellTextInfo = new TextInfo { FontName = “Nyala”, IsUnicode = true };

Aspose.Pdf.Generator.Row rowContent2 = tab.Rows.Add();
var cell2 = rowContent2.Cells.Add(“test”);
cell.DefaultCellTextInfo = new TextInfo { FontName = “Arial Unicode MS”, IsUnicode = true };

sec1.Paragraphs.Add(tab);

pdfConv.Save(@“D:/testAmharic.pdf”);
(new System.Diagnostics.Process { StartInfo = { FileName = @“D:/testAmharic.pdf” } }).Start();

Hi,


I have tested the scenario and have observed that the reason Amharic characters do not appear in PDF file is because after adding cell in second row, you have specified Arial Unicode MS as font for cell in first row of table containing Amharic characters. Simply update the code as

cell2.DefaultCellTextInfo = new TextInfo { FontName = “Arial Unicode MS”, IsUnicode = true };

See attached PDF file which I have generated over my end.

Oops yep you have good eyes. Shame on me for doing such a mistake.

Many thanks to you :slight_smile: I’m finally able to achieve my goal ! Amharic language, here I am !

Hi,


I am glad to hear that your problem is resolved and you are able to accomplish your requirements. In the event of any further query, please feel free to contact.