Inconsistent Line Height Rendering When Converting DOCX to Image with Parentheses

Problem Description

When converting DOCX files to images using Aspose, documents containing parentheses show inconsistent line height rendering compared to documents without parentheses, even when paragraph line spacing settings are identical.

Sample Files

I have prepared two sample DOCX files demonstrating this issue:

Both files have identical paragraph formatting settings, but show different line heights when converted to images.

Environment

  • Aspose Version: 25.9.0
  • Platform: .NET Framework 4.8

Sample Code

using Aspose.Words;

new License().SetLicense(@"licensePath");
var doc = new Document($@"intputDocxPath");
doc.Save(@"outputPngPath");

@SzuChiChen

Inconsistent line height rendering when converting DOCX files to images can be influenced by several factors, including font settings and paragraph formatting. Here are some steps you can take to address the issue:

  1. Check Font Availability: Ensure that the fonts used in your DOCX documents are installed on the system where the conversion is taking place. Missing fonts can lead to unexpected rendering results.

  2. Verify Formatting Consistency: Double-check that the line height settings (such as spacing before and after paragraphs) are uniformly applied throughout the document. Inconsistencies in formatting can cause discrepancies in rendering.

  3. Adjust ImageSaveOptions: When saving the document as an image, you can use the ImageSaveOptions class to modify settings that may affect line height rendering. For example, adjusting the DPI settings can sometimes improve the output.

    Example:

    Document doc = new Document("input.docx");
    ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
    options.DpiX = 300; // Adjust as needed
    options.DpiY = 300; // Adjust as needed
    doc.Save("output.png", options);
    
  4. Render to a Graphics Object: Instead of saving directly to an image format, consider rendering the document to a .NET Graphics object. This method provides more control over the rendering context and allows for adjustments as necessary.

    Example:

    Document doc = new Document("input.docx");
    using (Bitmap bmp = new Bitmap(800, 600)) // Adjust size as needed
    {
        using (Graphics gr = Graphics.FromImage(bmp))
        {
            doc.RenderToSize(gr, 0, 0, bmp.Width, bmp.Height);
            bmp.Save("output.png");
        }
    }
    
  5. Check Paragraph Styles: If your DOCX file uses styles that define line spacing, ensure those styles are correctly applied. Sometimes, styles may not render as expected if overridden at the paragraph level.

  6. Update Aspose.Words: Make sure you are using the latest version of Aspose.Words, as updates may include bug fixes and improvements related to rendering and formatting.

If the issue persists after trying these steps, consider reaching out to Aspose support for further assistance.

I cannot locate the DpiX and DpiY properties in the ImageSaveOptions class.

To clarify the test case: the two DOCX files I provided differ only in the presence/absence of parentheses. All other formatting settings are completely identical.

@SzuChiChen
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-28673

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

I noticed that my issue has been marked as “postponed” and I would like to better understand what this status indicates. I want to ensure that I have provided all necessary information for your team to address the issue effectively.

Could you please clarify:

  1. What are the typical reasons for an issue to be marked as “postponed”?
  2. Is there any additional information, context, or documentation that I should provide to help move the issue forward?

@SzuChiChen Postponed status means the issue is not scheduled for development or is blocked by another issue.

Regarding your issue, it is caused by the incorrect metrics computed by Aspose.Words for DFKai-SB font. This issue is related to another WORDSNET-28329, which is already in development.

The issue has been postponed until the changes for WORDSNET-28329 are integrated.

We will keep you updated and let you know once the issue is resolved or we have more information for you.

1 Like