Greek letters becomes boxes when saving Document to pdf

I use Mail merge with templates to generate PDFs and Word documents to my users. I am using a custom font which does not support every language that the users can put in and Arial is suppose to be used as fallback.

Using Aspose Words 15.5 I noticed that most non-western came out as boxes when saving Document to pdf. So I tried the latest version 22.5 and it worked way better - but Greek letters are still coming out as boxes (see image).
Saving to .docx works perfectly fine, all languages comes out nicely

What is going on here?

Some more info:

  • I am providing our custom font in a folder
  • I have checked the IWarningCallback and it does not complain of any fonts being missed
  • The custom font is not True-Type which I know you say is a requirement. Still it works most of the time.
  • I’ve tried in different ways to force substitution for my custom font but it does not make any difference

I am willing to by a license for the latest version but not until this is sorted out.

@JeppeRip Could you please attach your input and output documents here for testing? We will check the issue and provide you more information.

Yes of course
Input.docx (48.5 KB)
Result.pdf (90.8 KB)

@JeppeRip Could you please also provide data used to fill the template with data or save the output document as DOCX and attach it here? This is help to understand what the problem is.

Yes, this is what is inserted into “html:introduction”:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Latin 1(Western)ÁÀÂÄÅÃÆÇÐÉÈÊËÍÌÎÏÑÓÒÔÖÕØŒÞÚÙÛÜÝŸáàâäãåæçðéèêëíìîïıñóòôöõøœßþúùûüýÿ

Latin 2 (Eastern)ĀĂĄĆČĎĐĒĖĘĚĞĢĪĮİĶŁĹĻĽŃŅŇŌŐŔŖŘŠŚŞȘŢȚŤŪŮŰŲŽŹŻāăąćčďđēėęěğģīįķłĺļľńņňōőŕŗřšśşșţțťūůűųžźż

Greek (Modern)ΑΒΓ∆ΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΆΈΉΊΌΎΏΪΫαβγδεζηθικλµνξοπρςστυφχψωάέήίόύώϊϋΐΰ

Cyrillic 1 (Russian)АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя

Cyrillic 2 (Extended)ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏҐӁƏҒҖҚҢҮҰҲҶҺӘӢӨӮѐёђѓєѕіїјљњћќѝўџґӂǝғҗқңүұҳҷһәӣөӯ

@JeppeRip I have simplified the template to avoid using nested regions and used the following code for testing

DataTable t = new DataTable("IntroductionInfo");
t.Columns.Add("html:Introduction");
t.Rows.Add("Latin 1(Western)ÁÀÂÄÅÃÆÇÐÉÈÊËÍÌÎÏÑÓÒÔÖÕØŒÞÚÙÛÜÝŸáàâäãåæçðéèêëíìîïıñóòôöõøœßþúùûüýÿ");
t.Rows.Add("Latin 2 (Eastern)ĀĂĄĆČĎĐĒĖĘĚĞĢĪĮİĶŁĹĻĽŃŅŇŌŐŔŖŘŠŚŞȘŢȚŤŪŮŰŲŽŹŻāăąćčďđēėęěğģīįķłĺļľńņňōőŕŗřšśşșţțťūůűųžźż");
t.Rows.Add("Greek (Modern)ΑΒΓ∆ΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩΆΈΉΊΌΎΏΪΫαβγδεζηθικλµνξοπρςστυφχψωάέήίόύώϊϋΐΰ");
t.Rows.Add("Cyrillic 1 (Russian)АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя");
t.Rows.Add("Cyrillic 2 (Extended)ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏҐӁƏҒҖҚҢҮҰҲҶҺӘӢӨӮѐёђѓєѕіїјљњћќѝўџґӂǝғҗқңүұҳҷһәӣөӯ");

Document doc = new Document(@"C:\Temp\in.docx");

doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveUnusedFields;
doc.MailMerge.UseWholeParagraphAsRegion = true;
doc.MailMerge.ExecuteWithRegions(t);

doc.Save(@"C:\Temp\out.pdf"); 

The output document looks correct: out.pdf (60.5 KB)
in.docx (48.8 KB)

Could you please provide you code or create a simple console application that will allow us to reproduce the problem.

Here is an example console application. I usewd your provided example with my template and my fonts.
As you can see the docx-file comes out fine but the pdf are missing Greek letters.

AsposeExample.7z (74.1 KB)

Edit: The app is dotnet core 2.1

I tried running it on dotnet core 6 and got the same result

@JeppeRip The problem occurs because the fonts does not have glyphs for Greek characters. On my side the problem is not reproducible because Greek characters are rendered using Arial Unicode MS font.
Alternatively, you can Google Noto Fonts and FallbackSettings.LoadNotoFallbackSettings.
If you check default fallback settings, you can notice that Arial Unicode MS is th default fallback font:

FontSettings.DefaultInstance.FallbackSettings.Save(@"C:\Temp\out.xml");
<Rule FallbackFonts="Arial Unicode MS" />

Hi, thanks for the fast replies today.

So if you run my code you get the correct Greek characters? Why are the Greek characters rendered using Arial Unicode for you but not for me?

Note that it would be perfectly fine for me if the Greek character where rendered in another font, my problem is that they aren’t.

In the meantime I will look into the Noto-fonts.

@JeppeRip

Yes, the document is rendered correctly on my side.

Most likely the font is not available on your side. You can try either put this font into the folder with custom fonts or install it. Here is the font

It worked! Thank you :slight_smile:

1 Like