Aspose.Words .net issue converting word to pdf using some characters with ltr fonts in between Persian rtl fonts like "B Nazanin"

تست جدول.docx (228.8 KB)

B_NAZANIN.zip (26.9 KB)

Some characters for example left arrows or bullet points don’t convert correctly.
Is there something to be done or does it need to be fixed in the next release?

@meg.2891 The problem is not reproducible on my side using the following simple code:

Document doc = new Document(@"C:\Temp\in.docx");
doc.FontSettings = new FontSettings();
// 'C:\Temp\fonts' contains the attached font
doc.FontSettings.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), new FolderFontSource(@"C:\Temp\fonts", true) });
doc.WarningCallback = new WarningCallback();
doc.Save(@"C:\Temp\out.pdf");

out.pdf (342.0 KB)

The problem on your side might occur because the fonts used in your input document are not available on the machine where document is converted to PDF. The fonts are required to render document. 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 learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/net/specifying-truetype-fonts-location/

To render arrows and bullets Symbol and Wingdings symbolic fonts are used.

I was using the static font folder settings like this:

FontSettings.DefaultInstance.SetFontsFolder(fontsDirectory, true);

Doesn’t this work that way?
By the way it works with:

doc.FontSettings.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), new FolderFontSource(fontsDirectory, true) });

@meg.2891 If use the following code:

FontSettings.DefaultInstance.SetFontsFolder(fontsDirectory, true);

fontsDirectory is set globally and Aspose.Words will search for fonts only in the specified director.

The following code specifies font sources for a particular document only:

doc.FontSettings.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), new FolderFontSource(fontsDirectory, true) });

You can specify several font sources globally. For example:

FontSettings.DefaultInstance.SetFontsSources(new FontSourceBase[] { new SystemFontSource(), new FolderFontSource(fontsDirectory, true) });

In this case Aspose.Words will look for fonts installed in the system and in the specified folder.

Thank you for the support!

1 Like