Font export to html

Hello team, when I export a docx with the font “speak pro” which is included on the system to html, the font does not come along. An arial is exported for this. if this font is embedded, then it is included. shouldn’t it be enough if the font is available on the system? Thanks for the feedback

@pronet-1

When exporting a DOCX document to HTML using Aspose.Words, if the font “Speak Pro” is not embedded, it may not be included in the output HTML, and a default font like Arial might be used instead. This behavior occurs because the Aspose.Words library relies on the availability of the font on the system, but it does not automatically include non-embedded fonts in the exported HTML.

To ensure that the desired font is included in the HTML output, you can use the ExportFontResources option in the HtmlSaveOptions class. This option allows you to export font resources to separate files, which can then be referenced in the HTML. Additionally, you can set the ExportFontsAsBase64 property to embed the font directly into the HTML as Base64-encoded data.

Here’s a code example demonstrating how to set these options:

Document doc = new Document("path/to/your/document.docx");

HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.setExportFontResources(true); // Export fonts to separate files
saveOptions.setExportFontsAsBase64(true); // Embed fonts as Base64 in the HTML

doc.save("path/to/output/document.html", saveOptions);

By using these options, you can ensure that the fonts are properly included in the exported HTML, regardless of whether they are embedded in the original document or available on the system.

For more detailed information on saving documents to HTML, including handling fonts, you can refer to the Aspose documentation on converting documents to HTML, MHTML, or EPUB formats [1].

Sources:
[1]: Convert a Document to HTML, MHTML or EPUB - Aspose Documentation

@pronet-1 Could you please attach your input and output documents along with the problematic font? We will check the issue and provide you more information.