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

Free Support Forum - aspose.com

Change specific font of document while import it using C#

I need to apply custom font family named “Some ABC” which is not present in my System i.e path-Control Panel\Appearance and Personalization\Fonts, when i am converting my .HTML to .docx file.


You can use LoadOptions.FontSettings property as shown below to use the custom fonts while importing HTML into Aspose.Words’ DOM. Hope this helps you.

FontSettings fontSettings = new FontSettings();
fontSettings.SetFontsFolder(@"c:\temp\", true);

// If "HaettenSchweiler" is not installed on the local machine,
// it is still considered available, because it is substituted with "Comic Sans MS"
substitutionRule.AddSubstitutes("HaettenSchweiler", new string[] { "Comic Sans MS" });

LoadOptions loadOptions = new LoadOptions();
loadOptions.FontSettings = fontSettings;
Document doc = new Document(MyDir + "input.html", loadOptions);
doc.Save(MyDir + "output.docx");