HTMLFixed in Font not getting as per Word Document

While Converting docx to HTMLFixed then font not getting as per word document
Like AvantGarde font changed to times new roman and FranklinGothic font changed to Cambria.
Snippet :

Aspose.Words.Saving.HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.AllowEmbeddingPostScriptFonts = true;
options.PrettyFormat = true;
options.ShowPageBorder = true;
options.ExportEmbeddedCss = true;
options.ExportEmbeddedFonts = true;
options.ExportEmbeddedImages = true;
options.ExportEmbeddedSvg = true;
options.UseHighQualityRendering = true;
//options.UseTargetMachineFonts = true;
//options.FontFormat = ExportFontFormat.Ttf;
 //options.SaveFontFaceCssSeparately = true;
Document doc = new Document(@"C:\\Users\\achaudhari\\Desktop\\font_check.docx");
Document outputDoc = (Document)doc.Clone(true);               

outputDoc.FontInfos.EmbedTrueTypeFonts = true;
outputDoc.FontInfos.EmbedSystemFonts = true;
outputDoc.FontInfos.SaveSubsetFonts = true; 
outputDoc.Save(@"C:\\Users\\achaudhari\\Desktop\\FontCheck.html", options);

Font_issue.zip (76.3 KB)

@AlpeshDev This occurs because the fonts used in the document are not available in the environment where document is converted. Upon conversion document to fixed page formats like PDF, XPS or HtmlFixed Aspose.Words need the fonts used in the document to build the document layout, if the fonts are not available Aspose.Words substitutes the missed fonts. You can implement IWarningCallabck to get notifications when font substitution is performed. On my side I see the following warnings upon conversion your document:

Font 'AvantGarde' has not been found. Using 'Cambria' font instead. Reason: alternative name from document.
Font 'FranklinGothic' has not been found. Using 'Cambria' font instead. Reason: alternative name from document.

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

@alexey.noskov thanks for your response.

1 Like