Bullet Point Not Displaying Correctly in Fixed HTML

Hi,
When I convert a Word document to fixed HTML using the code below, the bullet points do not appear as they do in the original Word document. I have hosted my API on a Linux system. It works fine on Windows, but when I try it on WSL, the output does not match the source document.

How can I resolve this issue?

Aspose.Words Version : 21.8.0.0

byte[] wordBytes; //here is a source word bytes
Aspose.Words.Saving.HtmlFixedSaveOptions options = new HtmlFixedSaveOptions()
{
    AllowEmbeddingPostScriptFonts = true,
    PrettyFormat = false,
    ShowPageBorder = true,
    ExportEmbeddedCss = true,
    ExportEmbeddedFonts = true,
    ExportEmbeddedImages = true,
    ExportEmbeddedSvg = true,
    UseHighQualityRendering = false,
    FontFormat = ExportFontFormat.Ttf,
    OptimizeOutput = true,
    MemoryOptimization = true,
    Encoding = Encoding.UTF8
};
options.MetafileRenderingOptions.RenderingMode = MetafileRenderingMode.Bitmap;
var wordloadoption = new Aspose.Words.Loading.LoadOptions() { LoadFormat = LoadFormat.Docx };
using (MemoryStream ms = new MemoryStream(wordBytes))
{
    Aspose.Words.Document outputDoc = new Aspose.Words.Document(ms, wordloadoption);
    outputDoc.Cleanup();
    outputDoc.WebExtensionTaskPanes.Clear();
    outputDoc.RemoveExternalSchemaReferences();
    outputDoc.RemoveMacros();
    outputDoc.RemovePersonalInformation = true;
    using (MemoryStream htmlMs = new MemoryStream())
    {
        outputDoc.Save(@"SampleBullet.html", options);
    }
}

Source :
SampleBullet.docx (15.4 KB)

Output :
SampleBullet.zip (34.0 KB)

@AlpeshChaudhariDev

To resolve the issue of bullet points not displaying correctly when converting a Word document to fixed HTML on a Linux system, you should ensure that the fonts used in the document are available on the target machine. This is particularly important when the output differs between Windows and Linux environments.

Here are some steps you can take to address the problem:

  1. Use Target Machine Fonts: Modify your HtmlFixedSaveOptions to include the property that allows the use of fonts from the target machine. This can help ensure that the bullet points render correctly if they rely on specific fonts that may not be embedded in the document.

    Here’s how you can set this option in your code:

    Aspose.Words.Saving.HtmlFixedSaveOptions options = new HtmlFixedSaveOptions()
    {
        AllowEmbeddingPostScriptFonts = true,
        PrettyFormat = false,
        ShowPageBorder = true,
        ExportEmbeddedCss = true,
        ExportEmbeddedFonts = true,
        ExportEmbeddedImages = true,
        ExportEmbeddedSvg = true,
        UseHighQualityRendering = false,
        FontFormat = ExportFontFormat.Ttf,
        OptimizeOutput = true,
        MemoryOptimization = true,
        Encoding = Encoding.UTF8,
        UseTargetMachineFonts = true // Add this line
    };
    
  2. Check Font Availability: Ensure that the fonts used in your Word document are installed on the Linux system where the conversion is taking place. If the required fonts are not available, the rendering may not match the original document.

  3. Embed Fonts: If you cannot guarantee that the target machine will have the necessary fonts, consider embedding the fonts in the document. This can be done by setting the ExportEmbeddedFonts property to true, which you have already done in your code.

  4. Test with Different Options: If the issue persists, try adjusting other properties in HtmlFixedSaveOptions, such as ExportEmbeddedCss and ExportEmbeddedImages, to see if they affect the output.

  5. Review Documentation: For more detailed guidance, you can refer to the Aspose documentation on using HtmlFixedSaveOptions, which provides insights into various properties that can be configured to improve the output quality.

By following these steps, you should be able to improve the rendering of bullet points and other elements in your fixed HTML output. If the problem continues, consider checking for any specific font-related issues or compatibility problems between the Word document and the Linux environment.

Sources:
[1]: Use Font From Target Machine | Aspose.Words Document Processing API

@AlpeshChaudhariDev The problem might occur because Symbol font used for displaying bullets in MS Word document is not available in the environment where document is rendered to HtmlFixed. The fonts are required to build document layout. 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 and as a result incorrect page detection. 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/

In addition, the problem might occur due to the known peculiarity - Windows “Symbol” font (which is used for bullets) is a symbolic font (like “Webdings”, “Wingdings”, etc.) which uses Unicode PUA. MacOS or Linux “Symbol” font on the other hand is a proper Unicode font (for example Greek characters are in the U+0370…U+03FF Greek and Coptic block). So these fonts are incompatible and Mac/Linux “Symbol” font cannot be used instead of Windows “Symbol” without additional actions. In your particular case, it looks like, the bullet is represented as U+2022, but in Windows “Symbol” it is PUA U+F0B7 (or U+00B7 which also can be used in MS Word for symbolic fonts). So if you use Linux or Mac version of Symbol font, you should change U+2022 character to U+00B7:

Document doc = new Document(@"C:\Temp\in.docx");

List<Run> items = doc.GetChildNodes(NodeType.Run, true).Cast<Run>()
    .Where(r => r.Font.Name == "Symbol").ToList();

foreach (Run r in items)
{
    if (r.Text == "\x2022")
        r.Text = "\x00b7";
}

Aspose.Words.Saving.HtmlFixedSaveOptions options = new HtmlFixedSaveOptions()
{
    AllowEmbeddingPostScriptFonts = true,
    PrettyFormat = false,
    ShowPageBorder = true,
    ExportEmbeddedCss = true,
    ExportEmbeddedFonts = true,
    ExportEmbeddedImages = true,
    ExportEmbeddedSvg = true,
    UseHighQualityRendering = false,
    FontFormat = ExportFontFormat.Ttf,
    OptimizeOutput = true,
    MemoryOptimization = true,
    Encoding = Encoding.UTF8
};

doc.Save(@"C:\Temp\out.html", options);

But the simplest way to resolve the problem is installing Windows Symbol font.

Thanks @alexey.noskov

i have installed this fonts in WSL but not able to solve this.

ttf-mscorefonts-installer
fonts-dejavu
fonts-liberation
fonts-noto
fonts-symbola

@AlpeshChaudhariDev Have you tried implementing IWarningCallback ? Does it show any warnings?

Yes, I have implemented it. However, a warning appears: “Font ‘Symbol’ was not found. Using ‘Webdings’ instead due to font info substitution”

@AlpeshChaudhariDev This is the exact reason of the problem. As it was mentioned above, to properly render the document the fonts used in the source document are required.

so which font i need to install ?

@AlpeshChaudhariDev ‘Symbol’ fonts, just like described in the warning message.

Yes thanks @alexey.noskov However, I’m unable to find this font. Could you please provide the download link so I can install it on my WSL?

@AlpeshChaudhariDev You can copy the font from your Windows machine.