Aspose Pdf doen't support Japanese language (20.12.0) in net core 6.0

 string html = "日本語テキスト";    
 MemoryStream mStream = new MemoryStream();
 Aspose.Words.Document document = new Aspose.Words.Document();
 DocumentBuilder docBuilber = new DocumentBuilder(document);
 docBuilber.InsertHtml(html);
 MemoryStream docStream = new MemoryStream();
 document.Save(docStream, Aspose.Words.SaveFormat.Pdf);

here i used Aspose Word 20.12.0 to convert string into pdf file using memoryStream.
pdf file doen’t support japanes lang
i also used latest version of Aspose word but getting same issue.
here i attach my output pdf file which doen’t support japanes language.
test_22.12.pdf (30.2 KB)

please give some solution …

@ravina

Aspose APIs use fonts installed in the system to render characters in the generated files. Please make sure that such fonts that support Japanese characters are present and properly installed in your system. In case issue still persists, please let us know.

@ravina The problem is not reproduceable on my side. Here is the output document generated by the same code on my side: out.pdf (7.7 KB)

Most likely the problem occurs because the fonts required for rendering document are not available on the machine where document is converted to PDF. If Aspose.Words cannot find the font used in the document, the font is substituted. This might lead into fonts mismatch and document layout differences due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to lean where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

i added this command in docker file for install font but getting same output.
apt-get install -y fonts-noto-cjk fonts-ipaexfont-gothic fonts-mplus fonts-vlgothic
Please give some solution …
because my code work locally for me but its not work after published on sever.
i need solution for how to add font on server side machine.

@ravina You can put the required font into the folder and use this folder as a font source as described here:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/#loading-fonts-from-folder

I applied same
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/#loading-fonts-from-folder
but it didn’t work in my project. please give some other solution

@ravina Have you tried implementing IWarningCallback? Does it show any warnings about font substitutions? The fonts is the only reason of such problems upon document rendering.

Font substitution warning: Font 'Times New Roman' has not been found. Using 'Fanwood' font instead. Reason: first available font.
Font substitution warning: Font 'Symbol' has not been found. Using 'Fanwood' font instead. Reason: first available font.
Font substitution warning: Font 'Wingdings' has not been found. Using 'Fanwood' font instead. Reason: first available font.
Font substitution warning: Font 'Courier New' has not been found. Using 'Fanwood' font instead. Reason: first available font.

getting above all warnings.

@ravina Thank you for additional information. It looks like there are no available font in the environment where the document is converted, since the last resort font Fanwood is used for rendering the document. This font is embedded into Aspose.Words dll and is used if no other fonts are available.

I install font in docker container but it didn’t work. and
i Added font folder and used that folder as a font source but it didn’t work.
i feel like is Aspose word problem because when i used same Approch for convert string into Word document using Aspose word its working fine for japanese language.
so,
Is there any solution related to Aspose word.
please give some solution.

@ravina Could you please run the following code on your side and make sure Aspose.Words can locate any fonts on your side:

FontSourceBase[] sources = FontSettings.DefaultInstance.GetFontsSources();
foreach (FontSourceBase fs in sources)
{
    foreach (PhysicalFontInfo info in fs.GetAvailableFonts())
    {
        Console.WriteLine("{0} - {1}", info.FullFontName, info.FilePath);
    }
}

Also, please provide code you use to specify font location on your side. We will check the issue and provide you more information.

MemoryStream mStream = new MemoryStream();
Aspose.Words.Document document = new Aspose.Words.Document();

FontSettings FontSettings = new FontSettings();
FontSettings.SetFontsFolder("Fonts", true);
document.FontSettings = FontSettings;

// Get available fonts from FontSettings
foreach (FontSourceBase fontsSource in FontSettings.DefaultInstance.GetFontsSources())
{
    foreach (PhysicalFontInfo fontInfo in fontsSource.GetAvailableFonts())
    {
        Console.WriteLine("\nFontFamilyName DefaultInstance: " + fontInfo.FontFamilyName);
        Console.WriteLine("FullFontName  DefaultInstance: " + fontInfo.FullFontName);
        Console.WriteLine("Version DefaultInstance : " + fontInfo.Version);
        Console.WriteLine("FilePath DefaultInstance: " + fontInfo.FilePath);
    }
}


DocumentBuilder docBuilber = new DocumentBuilder(document);
docBuilber.InsertHtml(html);

MemoryStream docStream = new MemoryStream();
document.Save(docStream, Aspose.Words.SaveFormat.Pdf);

i used this code
getting console like :

FontFamilyName DefaultInstance: DejaVu Sans
FullFontName  DefaultInstance: DejaVu Sans Bold
Version DefaultInstance : Version 2.37
FilePath DefaultInstance: /usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf

@ravina As seen from the log Aspose.Words cannot find any font except DejaVu Sans. Please try specifying an absolute path to the fonts folder:

FontSettings FontSettings = new FontSettings();
FontSettings.SetFontsFolder("C:\\Temp\\Fonts\\", true); // Use an absolute path to the fonts folder
document.FontSettings = FontSettings;

i also tried with absolute path to the fonts folder but it didn’t work.

@ravina The problem might occur because the fonts folder is not accessible by Aspose.Words. You can try specifying FontSourceBase.WarningCallback property to get notification when there are problems with loading fonts from the font source.

i tried FontSourceBase.WarningCallback property and getting following warnings and after that i copy all font which in warning in docker file, now not getting any warning but japanese font are not support getting box instead japanese word.

Font substitution warning: Font 'Times New Roman' has not been found. Using 'Fanwood' font instead. Reason: first available font.
Font substitution warning: Font 'Symbol' has not been found. Using 'Fanwood' font instead. Reason: first available font.
Font substitution warning: Font 'Wingdings' has not been found. Using 'Fanwood' font instead. Reason: first available font.
Font substitution warning: Font 'Courier New' has not been found. Using 'Fanwood' font instead. Reason: first available font.

@ravina Since the font name is not explicitly specified for Japanese text in your code, the default font is used - Time New Roman. But since Time New Roman font does not have Japanese characters Aspose.Words tries to find a font with the required glyphs. This process is called font fallback. On my side SimSun font is used as fallback font. Please try adding this font to your docker image too.

its not work for me.

@ravina unfortunately, i cannot reproduce the problem. I have used the following simple code for testing:

string html = "日本語テキスト";
MemoryStream mStream = new MemoryStream();
Document doc = new Document();
DocumentBuilder docBuilber = new DocumentBuilder(doc);
docBuilber.InsertHtml(html);
// Specify warning callback
doc.WarningCallback = new WarningCallback();
// Specify font sources. use only folder font source to emulate environmen with limited fonts avalable.
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] {new FolderFontSource(@"C:\Temp\fonts", true) });
doc.Save(@"C:\Temp\out.pdf");
private class WarningCallback : IWarningCallback
{
    public void Warning(WarningInfo info)
    {
        if (info.WarningType == WarningType.FontSubstitution)
            Console.WriteLine(info.Description);
    }
}

The problem is reproducible only if no fonts are available. If put SimSun font into the fonts folder the document is rendered properly:
out.pdf (7.7 KB)
Here is SimSun font I have used or testing:
simsun.zip (8.9 MB)