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.docx: eq1.docx (17.3 KB)
Aspose result (GDI+):
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.
Preferred solution: A fix that ensures consistent, accurate rendering of MathType OLE objects (Equation.DSMT4) without bolding or misformatting.
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?
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:
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.
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
Next Action:
Please provide the above information, and I can connect you with our sales team during business hours to discuss your support options.
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);
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/
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)
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
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)?
DPI guidance: Is there a recommended resolution threshold where Bitmap mode typically matches Word’s text weight? I still see boldness at 384 DPI.
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?
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.