Rending Issue with MathType Equation OLE Object

I am encountering rendering issues with MathType Equation OLE objects (progId == "Equation.DSMT4") when converting DOCX to images using Aspose.Words.

Sample Code :

using Aspose.Words;
using Aspose.Words.Saving;

var license = new License();
license.SetLicense(@"licensePath");

const string fileName = "eq1"; // or "eq2"
var document = new Document(@$"inputPath");
var options = new ImageSaveOptions(SaveFormat.Png)
{
    // Comment when using GDI+ mode
    MetafileRenderingOptions =
    {
        RenderingMode = MetafileRenderingMode.VectorWithFallback,
        EmulateRasterOperations = false
    }
};
document.Save($@"outputPath", options);

Environment:

  • .NET Framework 4.8
  • Aspose.Words 25.9.0

Test Documents

Eq1.docxeq1.docx (17.3 KB)
Aspose result (GDI+):


Aspose result (Vector):

Expeceted Result:

Eq2.docxeq2.docx (19.3 KB)
Aspose result (GDI+):


Aspose result (Vector):

Expeceted Result:

Observations

  • GDI+ mode: The rendering looks closer to Microsoft Word’s EMF preview, but the lines appear too bold.
  • Vector mode: The line thickness looks more accurate compared to Word, but some shapes are misaligned or distorted (e.g., in eq1.docx certain elements shift).

Goal

Ideally, I would like the equations to render as precisely as they appear in Microsoft Word.

  1. Preferred solution: A fix that ensures consistent, accurate rendering of MathType OLE objects (Equation.DSMT4) without bolding or misformatting.
  2. Fallback solution: If a fix is not possible, I would like to render:
  • eq1.docx with GDI+ mode
  • eq2.docx with Vector mode
    However, I cannot determine how to distinguish these OLE objects programmatically (e.g., by inspecting their content) in order to apply the correct rendering mode automatically.

Question

  • Is there a way to achieve accurate rendering of MathType OLE objects so they look the same as in Microsoft Word?
  • If not, is there a method to identify OLE objects with “eq1-like” characteristics so I can selectively render them with GDI+, while leaving the others to the default Aspose vector renderer?

@SzuChiChen

Hello!

Thank you for reaching out regarding your rendering issue with MathType Equation OLE objects in Aspose.Words. For paid support, here’s a quick overview:

  1. Paid Support Plans:

    • Priority Support: Fast response times for urgent issues.
    • Standard Support: Regular support with a standard response time.
    • Enterprise Support: Comprehensive support with dedicated resources.
  2. Information Needed to Proceed:

    • Company name
    • Use case description
    • Number of users/seats
    • SLA urgency (how quickly you need a response)
    • Region (for support availability)
    • Preferred payment method
    • Contact email and/or phone number
  3. Next Action:

    • Please provide the above information, and I can connect you with our sales team during business hours to discuss your support options.

Looking forward to assisting you further!

@SzuChiChen

eq1.docx

  1. The problem with boldness in MetafileRenderingMode.Bitmap occurs due to low image rendering resolution. If increate resolution the problem is not observed:
Document doc = new Document(@"C:\Temp\in.docx");
ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.Png);
opt.MetafileRenderingOptions.RenderingMode = MetafileRenderingMode.Bitmap;
opt.Resolution = 300;
doc.Save(@"C:\Temp\out.png", opt);

Here is the produced result:
out.png (48.6 KB)

  1. With high resolution, there is no significant rendering difference in MetafileRenderingMode.Bitmap and MetafileRenderingMode.Vector.

eq2.docx

The same applies to the second document.

Thank you for your reply.

eq2.docx

Sample Code:

using Aspose.Words;
using Aspose.Words.Saving;

var license = new License();
license.SetLicense(@"licensePath");

var document = new Document(@$"inputPath");
var options = new ImageSaveOptions(SaveFormat.Png)
{
    UseAntiAliasing = true,
    UseHighQualityRendering = true,
    UpdateAmbiguousTextFont = true,
    AllowEmbeddingPostScriptFonts = true,
    Resolution = 384,
    // Comment when using GDI+ mode
    MetafileRenderingOptions =
    {
        RenderingMode = MetafileRenderingMode.VectorWithFallback,
        EmulateRasterOperations = false
    }
};
document.Save($@"outputPath", options);

Aspose result (GDI+):
eq2_GDI+.png (78.5 KB)

Aspose result (Vector):
eq2_vector.png (80.0 KB)

Even when I increase the resolution, the GDI+ output still produces noticeably bolder lines compared to surrounding text.
In contrast, the vector mode output looks thinner and closer to Microsoft Word’s rendering, but it sometimes causes misalignment issues (as in eq1).

I have tried raising the resolution as suggested, but the difference remains visible: GDI+ text continues to appear thicker than expected.

Is there any other approach or workaround that could help resolve this rendering issue?

@SzuChiChen Unfortunately, there is no other way to work the problem around. By the way I do not see any misalignment issues in the rendered equations on my side.
The difference in rendering in MetafileRenderingMode.Bitmap and MetafileRenderingMode.Vector is that in the first case Aspose.Words delegates metafile rendering to GDI+, so Aspose.Words does not have any control on the metafile rendering in this mode. In MetafileRenderingMode.Vector Aspose.Words renders the metafile on its own.

You should not that the difference in rendering might occur because the required fonts are not available on your side. 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. 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/

Thanks for your reply.

Here is the Sample Code (Minimal sample; only RenderingMode and Resolution vary.)

using Aspose.Words;
using Aspose.Words.Saving;

new License().SetLicense(@"licensePath");

const string fileName = "eq1"; // "eq2"
const string docxPath = @$"inputFolderPath\{fileName}.docx";
WarningCollector.Clear();
var doc = new Document(docxPath)
{
    WarningCallback = new WarningCollector()
};

const int resolution = 96 * 4;
const MetafileRenderingMode renderingMode = MetafileRenderingMode.Vector; // MetafileRenderingMode.Bitmap
var saveOptions = new ImageSaveOptions(SaveFormat.Png)
{
    Resolution = resolution,
    MetafileRenderingOptions =
    {
        RenderingMode = renderingMode
    }
};
doc.Save($@"outputFolderPath\{fileName}_resolution_{resolution}_{renderingMode.ToString()}.png", saveOptions);

var warnings = WarningCollector.GetWarnings();
if (warnings.Any())
{
    foreach (var w in warnings)
    {
        Console.WriteLine($"[{w.WarningType}] {w.Description}");
    }
}
else
{
    Console.WriteLine("(No warnings)");
}


public sealed class WarningCollector : IWarningCallback
{
    private static readonly List<WarningInfo> Warnings = [];

    public void Warning(WarningInfo info) => Warnings.Add(info);
    public static List<WarningInfo> GetWarnings() => [..Warnings];
    public static void Clear() => Warnings.Clear();
}

eq1.docx : eq1.docx (17.3 KB)

  • Vector: dots appear as separate glyphs, uneven in size/position; substitution warnings for DFKai-SB. ( [FontSubstitution] GDI+ can’t load ‘DFKai-SB’ font. Using ‘標楷體’ font instead. DFKai-SB → 標楷體 (BiauKai) substitution is expected on this machine.”)
    eq1_resolution_384_Vector.png (79.7 KB)
  • Bitmap (GDI+): dots render as a uniform dotted leader; no warnings.
    eq1_resolution_384_Bitmap.png (75.4 KB)

eq2.docx : eq2.docx (21.9 KB)

Documentation reference (from ImageSaveOptions.MetafileRenderingOptions):

Vector → Aspose renderer (consistent, slower, may misrender complex metafiles)
Bitmap → GDI+ renderer (faster, supports most features, but text may look inconsistent at low DPI)

Questions

  1. GDI+ boldness: Is the heavier stroke weight in Bitmap mode an inherent GDI+ behavior, or is there any Aspose-exposed option to reduce it (e.g., text-as-path, hinting/antialiasing, EMF+ handling)?
  2. DPI guidance: Is there a recommended resolution threshold where Bitmap mode typically matches Word’s text weight? I still see boldness at 384 DPI.
  3. Selective strategy: If no universal fix exists, is there a way to programmatically detect “eq1-like” MathType OLEs so I can choose Vector for some and Bitmap for others?

@SzuChiChen

As it was mentioned in MetafileRenderingMode.Bitmap Aspose.Words delegates metafile rendering to GDI+, so Aspose.Words does not have any control on the metafile rendering in this mode.

There is no recommendation. all depends on your needs and input metafiles.

I am afraid there is no way to differentiate between different WMF metafiles.

@alexey.noskov Understood, thank you very much for your reply and clarification.

1 Like