Equation field rendering issue in DOCX to PDF/PNG

When I try to convert a DOCX containing equation fields to PDF or PNG, the equation fields are not rendered correctly.

Input DOCX
test.docx (15.9 KB)

Aspose outputs (equation field rendering is incorrect)
output.pdf (43.6 KB)

MS Word output (renders correctly when saving directly from Word)
test.pdf (26.3 KB)

I also tried the following, but none of them worked:

  • Calling UpdateFields() before saving
  • Using GDI+ rendering or HarfBuzzTextShaperFactory (enabled/disabled)

Here is my sample code:

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

var document = new Document(@"inputPath")
{
    LayoutOptions = { TextShaperFactory = HarfBuzzTextShaperFactory.Instance }
};
// document.UpdateFields();

document.Save(@"outputPdfPath", SaveFormat.Pdf);

var pngSaveOptions = new ImageSaveOptions(SaveFormat.Png)
{
    // MetafileRenderingOptions =
    // {
    //     RenderingMode = MetafileRenderingMode.VectorWithFallback,
    //     EmulateRasterOperations = false
    // }
};
document.Save(@"outputPngPath", pngSaveOptions);

Environment:

  • .NET Framework 4.8
  • Aspose.Words 25.9.0
  • Aspose.Words.Shaping.HarfBuzz 25.9.0

Could you please help check why equation fields are not rendering properly and suggest any workaround or fix?

@SzuChiChen

Summary

The EQ field (the legacy “Equation” field that Word uses for the old Equation Editor) is not supported for rendering by Aspose.Words. When a document that contains such fields is saved as PDF, PNG, or any other raster/vector format, the field is left untouched and the result is the “garbled” image you are seeing.

The modern Office Math (OMML) equations that are created with Insert → Equation in recent versions of Word are rendered correctly, but the older EQ‑field based equations are outside the rendering engine’s capabilities.


Why your code does not help

Action you tried What it does Why it does not fix the problem
document.UpdateFields() Updates the results of fields (e.g., TOC, DATE) but does not convert EQ fields to a displayable format. The EQ field still remains an unsupported field.
Switching TextShaperFactory to HarfBuzz Affects only complex‑script text shaping (Arabic, Hindi, etc.). Equation rendering is unrelated to text shaping.
GDI+ rendering Uses the same rendering pipeline as the PDF/PNG exporters. The pipeline still cannot draw EQ fields.

What you can do

1. Convert the legacy EQ fields to Office Math (OMML) before handing the document to Aspose.Words

The only reliable way is to let Microsoft Word (or the Word automation COM object) perform the conversion, then save the resulting document and pass it to Aspose.Words.

// Example using Word Interop (run on a machine with MS Word installed)
var wordApp = new Microsoft.Office.Interop.Word.Application();
var doc = wordApp.Documents.Open(@"C:\input.docx");

// This command converts legacy equations to the new MathML format
doc.UpgradeLegacyMath();
doc.SaveAs2(@"C:\input_converted.docx", Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatXMLDocument);
doc.Close();
wordApp.Quit();

// Now use Aspose.Words on the converted file
var asposeDoc = new Aspose.Words.Document(@"C:\input_converted.docx");
asposeDoc.Save(@"C:\output.pdf", SaveFormat.Pdf);

Note: UpgradeLegacyMath() is available from Word 2010 onward. If you cannot use Word automation, you will need to ask the document creator to replace the old equations with the new “Insert → Equation” form.

2. Replace the EQ fields manually (if the number is small)

You can walk the document node tree, locate FieldType.FieldEq and replace each field with a picture of the equation (generated, for example, by MathType or by rendering the field in Word and saving it as an image). Sample code snippet:

foreach (Field field in doc.Range.Fields)
{
    if (field.Type == FieldType.FieldEq)
    {
        // Extract the field result (the rendered equation image) from Word beforehand,
        // then replace the field with a Shape (Picture) node.
        // This is a custom solution – Aspose.Words itself cannot render the EQ field.
    }
}

3. Request a feature / file a bug

If you often receive documents that contain legacy EQ fields and cannot control their source, you may open a support ticket with Aspose. The team can log the limitation and, if there is sufficient demand, consider adding rendering support in a future release.


Official documentation


TL;DR

  • EQ fields = not renderable by Aspose.Words (PDF/PNG/Image).
  • Use Word (or Word automation) to upgrade those equations to the modern Office Math format before loading the document into Aspose.Words.
  • After the upgrade, your existing code works perfectly – no need for HarfBuzz or special renderers.

If you need further assistance with the upgrade script or have any other Aspose.Words questions, feel free to let us know!

Thank you for your clarification.

I noticed that the documentation link you provided is not accessible (it returns 404).

My goal is to have the EQ fields rendered into PDF/PNG with the same appearance as in the DOCX.
Since Aspose.Words does not support rendering EQ fields directly, is there a way to manually replace or convert these EQ fields (for example, into OMML or another supported format) using Aspose.Words, so that the output looks correct?

@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-28618

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 found additional scenarios that reproduce the same rendering problem.
Here is the sample DOCX:
underline.docx (13.9 KB)

@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-28653

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.