Shape conversion into image with same font different results

Hello, we found an issue with the conversion of the shape of the following docx.
Smart objects - formatting issue (2).docx (24.1 KB)

Our environment:

  • Debian 12
  • Python 3.12
  • Aspose-Words - 25.7.0

Image after conversion:

As can be seen in the image, the bullet points are missing. Is this a font issue? Is there a way we can control the font fallback?

Also is there anyway to improve the image quality since it is losing readability?

Thank you!

@lbraguesdodoc

It appears that the missing bullet points in your converted image may be related to font issues. Since you are working with a DOCX file, you can utilize the FontSettings class in Aspose.Words to manage font sources and ensure proper rendering during conversion.

Here’s a step-by-step approach to set up font settings and convert your DOCX file:

  1. Set Up Font Settings: Create a FontSettings instance and specify where Aspose.Words should look for fonts.

    // Create a new FontSettings instance
    FontSettings fontSettings = new FontSettings();
    
    // Set the font sources to a specific folder
    fontSettings.SetFontsSources(new FontSourceBase[] {
        new FolderFontSource("PathToYourFontsFolder", true)
    });
    
  2. Load the Document with Font Settings: Use the LoadOptions to pass the FontSettings instance when loading your DOCX document.

    // Prepare load options with the defined FontSettings
    LoadOptions loadOptions = new LoadOptions();
    loadOptions.FontSettings = fontSettings;
    
    // Load the document
    Document doc = new Document("input.docx", loadOptions);
    
  3. Convert the Document: Save the document in your desired format (e.g., PDF, XPS) while ensuring that the specified fonts are embedded correctly.

    // Save the document to a PDF file
    doc.Save("output.pdf");
    
  4. Handling Font Substitution: Customize font substitution settings to manage how Aspose.Words handles missing fonts.

    // Example of enabling or disabling substitution settings
    fontSettings.SubstitutionSettings.FontInfoSubstitution.Enabled = false; // Disable FontInfo substitution
    fontSettings.SubstitutionSettings.DefaultFontSubstitution.DefaultFontName = "Arial"; // Set a default font
    
  5. Monitor Font Issues: Implement the IWarningCallback interface to track any font substitution warnings during processing.

    public class MyWarningCallback : IWarningCallback
    {
        public void Warning(WarningInfo warning)
        {
            Console.WriteLine($"Warning: {warning.Code} - {warning.Description}");
        }
    }
    
    // Set the warning callback
    doc.WarningCallback = new MyWarningCallback();
    

Regarding image quality, you can adjust the resolution settings when saving the document to improve readability. For example, when saving to a PNG format, you can specify the desired resolution.

By following these steps, you should be able to manage font settings effectively and enhance the quality of your converted images.

@lbraguesdodoc Most likely the problem on your side occurs because fonts required for building document layout are not available in your environment. To build an accurate document layout the fonts are required. If Aspose.Words cannot find the fonts used in the document the fonts are substituted . This might lead into the document layout difference due to difference in font metrics.
Please see our documentation to learn where Aspose.Words looks for fonts:
https://docs.aspose.com/words/python-net/specifying-truetype-fonts-location/

You can check this using WarningCallback:

doc = aw.Document("C:\\Temp\\in.docx")
# Specify warning callback
warnings = aw.WarningInfoCollection()
doc.warning_callback = warnings
doc.save("C:\\Temp\\out.pdf")

# print font substitution warnings.
for info in warnings:
    if info.warning_type == aw.WarningType.FONT_SUBSTITUTION:
        print(info.description)