We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to set font of HTML on loading it into Aspose.Words DOM using C#

Hi, we are trying to export a table from an Excel spreadsheet range to a new Word document.

In the attached spreadsheet (Test1.xlsx), all the cells in RANGE1 has “Frutiger LT Pro 67 Bold Cn” as font.
This font is not installed in our Windows OS.

Then, we export this range with the attached C# program by using:

  • Aspose.Cells.HtmlSaveOptions to get the HTML of the range
  • Aspose.Words.DocumentBuilder.InsertHtml to import the html table into a new Word document.

However, if we use the latest version of Aspose.Words, the table cells in the generated document (Test1.docx) have “sans-serif” as font shown. If we use an Aspose.Words version < 19.4, the font shown is “Frutiger LT Pro 67 Bold Cn”.

Is there a way to reproduce this previous behavior (maintain the font name) using the latest version of Aspose.Words?

Attachments.zip (27.8 KB)


The latest version of Aspose.Cells 20.3 for .NET does not generate HTML that has font ‘Frutiger LT Pro 67 Bold Cn’. So, please make sure that this font is installed where you are converting Excel document to HTML.

We are using Aspose.Cells 20.3 and it generates HTML containing the Frutiger font.

The td tags of the table have classes like .x54 or .x58 that have this style:

font-family:"Frutiger LT Pro 67 Bold Cn","sans-serif";

Attached the HTML generated

HTML.zip (3.1 KB)


The shared HTML shows font ‘Arial’ when open in MS Word. Could you please ZIP and attach the “Frutiger LT Pro 67 Bold Cn” font here for further testing? We will investigate the issue and provide you more information on it.

Well, we also do not have the Frutiger font installed.
This is the reason why you see the Arial font when opening the HTML file with MS Word.

What we want to do is to insert the HTML table in a docx with Aspose.Words.DocumentBuilder.InsertHtml(string html) in our server witch does not have the Frutiger font installed and then send the document to a client witch have the Frutiger installed.

Before Aspose.Words 19.4 when we open the docx in the server, we see Frutiger as font in the MS Word toolbar, although the font is not installed. As a consequence the client sees the font correctly.

Now, with the latest version of Aspose.Words, when we open the docx in the server we see “sans-serif” as font because it has been replaced, since the Frutiger font is not installed. As a consequence the client sees the font wrongly.

Is there a way to restore the InsertHtml behavior as it was before Aspose.Words 19.4 ?

FrutigerLTPro-BoldCn.zip (27.8 KB)


Please note that Aspose.Words tries to mimic MS Words’ behavior. If you open the HTML in MS Word and convert it to DOCX using MS Word, the same font is not set for text. You need to install the desired font where you are converting HTML to DOCX using Aspose.Words.

Only the client has the Frutiger font.

The client sends his document to the server, where the InsertHtml is executed and the updated document is returned to the client. The client opens the document and sees the right font (Frutiger). We have been working for 2 years in this way and we had no problems with fonts.

Now we want to update to the latest version of Aspose and we found out that this behavior has changed. Until Aspose.Words 19.3 the font names were not replaced if they were not installed and we want to keep this behavior.

Is it possible with the latest version of Aspose.Words?


The behavior of old versions of Aspose.Words is not expected. However, the behavior of latest version of Aspose.Words is correct.

If you want to change the font of text according to your requirement, you can iterate over Run nodes of document and set their font name.

If we do not want to install new fonts or iterate over Run nodes, is it ok to set a font folder containing all fonts or are there any side effects?

var fontFolder = "MyFontFolderPath";
FontSettings fontSettings = new FontSettings();
document.FontSettings = fontSettings;
var folderFontSource = new Aspose.Words.Fonts.FolderFontSource(fontFolder, false);
fontSettings.SetFontsSources(new Aspose.Words.Fonts.FontSourceBase[] { folderFontSource });


Yes, you can use FontSettings to set the font folder and substitute the fonts. Please check the following code example. Hope this helps you.

FontSettings fontSettings = new FontSettings();
fontSettings.SetFontsFolder(@"C:\temp\fonts\FrutigerLTPro-BoldCn\", true);

fontSettings.SubstitutionSettings.FontInfoSubstitution.Enabled = true;
fontSettings.SubstitutionSettings.TableSubstitution.AddSubstitutes("sans-serif", new string[] { "Frutiger LT Pro 47 Light Cn" });

Aspose.Words.HtmlLoadOptions options = new Aspose.Words.HtmlLoadOptions();
options.FontSettings = fontSettings;
var document = new Document(MyDir + "HTML.html", options);
document.Save(MyDir + "20.3.docx");