EQ Field Text Rotation Issue in Vertical DOCX to HTML Export

Description

When rendering vertical (top-to-bottom) text that contains a Word EQ field, the content inside the field equation is rendered with an incorrect text direction in HTML output.
Specifically, the number inside the circled number EQ field is rotated 90 degrees counterclockwise.
This issue does not occur in:

  • Microsoft Word
  • DOCX → PNG output generated by Aspose.Words

I have already enabled HarfBuzz text shaping, but it does not resolve the issue for HTML rendering.


Expected Result (Microsoft Word 2010)

  • Vertical text and EQ field content are rendered correctly.
  • The number inside the circled number maintains the correct orientation.

Actual Result (Aspose.Words Output)

  • The text inside the EQ field is rendered incorrectly only in HTML output.

DOCX → PNG

DOCX → HTML

  • The number inside the EQ field is rotated 90 degrees counterclockwise, resulting in incorrect visual output.
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Style-Type" content="text/css" /><meta name="generator" content="Aspose.Words for .NET 25.12.0" /><title></title></head><body style="widows:0; orphans:0; font-family:'Times New Roman'; font-size:12pt"><div><table cellspacing="0" cellpadding="0" style="width:31.5pt; margin-left:1.45pt; border-collapse:collapse"><tr style="height:127.1pt; page-break-inside:avoid"><td style="width:28.7pt; height:127.1pt; margin-left:auto; writing-mode:tb-rl; padding-right:1.4pt; padding-left:1.4pt; vertical-align:top; overflow:hidden"><div style="height:127.1pt; margin-left:auto; writing-mode:tb-rl; -aw-ignore:true; overflow:hidden"><p style="margin-top:0pt; margin-bottom:0pt; font-size:14pt"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAYCAYAAAAYl8YPAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFNSURBVEhL7ZM/qoNAEIcFgyDkAjmCFh4hVTprbTxAasFglSqpUqa3EQU7K0mRYwSsxFrbWBhBmcdOyLKr+aPvpXwfDDo/xw91XQG+iNAP/sK/7I7nebDZbLA+8VSWJAmoqgrr9RrCMORKkiRwHKd/CzKQLZdLME2zH3P4vo9zfTjZYrGAsizZ6CVZlsF8PucyKrtcLrBarbiLnwiCAGzbpj3Kuq6D2WzGzo3idrtxT4eyoijAMAx2bhRRFMHxeIT9fo89lf0G13XxyMkE4f7pzucznk+pgYx9MjKw2+1G1UvZdrvFgKzQWMg3I2/DyZqmAU3TMJgqIwuQ5zn29D+L45idG8XpdALLsmhPZW3bTv7XZFmGuq5pP9ibZOB6vfZjDnJdFMV+PJQRFEXBlUrTFKqqojnpSa7rOjf/4KnsweFwwP3K1jveyqbyVdkPoTRzLTqMiQgAAAAASUVORK5CYII=" width="19" height="24" alt="" style="vertical-align:middle; -aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline" /><span style="font-family:標楷體">—(    )</span></p></div></td></tr></table><p style="margin-top:0pt; margin-bottom:0pt; line-height:1pt"><span style="font-size:14pt; -aw-import:ignore">&#xa0;</span></p><p style="margin-top:0pt; margin-bottom:0pt"><span style="-aw-import:ignore">&#xa0;</span></p></div></body></html>

Sample Docx

sample.docx (16.8 KB)

Sample Code

using Aspose.Words;
using Aspose.Words.Saving;
using Aspose.Words.Shaping.HarfBuzz;

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

var doc = new Document($@"{rootDir}\Assets\{fileName}.docx")
{
    LayoutOptions = { TextShaperFactory = HarfBuzzTextShaperFactory.Instance }
};
doc.Save("outputPngPath");
doc.Save("outputHtmlPath", new HtmlSaveOptions
{
    ExportImagesAsBase64 = true
});

Environment

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

Question

  • Is there any configuration or setting that I may be missing to correctly render vertical text with EQ fields in HTML?
  • Is this a known limitation or bug in Aspose.Words when exporting DOCX to HTML?
  • Are there any recommended workarounds or planned fixes to make the HTML output consistent with the PNG output?

@chenweii

Summary

  • The rotation problem you see only when a vertical (top‑to‑bottom) text run contains an EQ field is not caused by a missing setting.
  • It is a known limitation/bug in the current HTML exporter of Aspose.Words for .NET 25.12.0.
  • At the moment there is no configuration that can force the correct orientation for the EQ‑field result in HTML.

Below you will find the details, the status of the issue and the recommended work‑arounds until the fix is released.


1. Why the problem occurs

When Word renders a vertical text run that contains an EQ field (e.g. a circled number), Word replaces the field result with a glyph image that already has the correct rotation baked‑in.

During HTML conversion Aspose.Words:

  1. The field result is exported as a <img> element (base‑64 encoded in your example).
  2. The image is generated by the HarfBuzz shaper (or the built‑in shaper) in the horizontal orientation.
  3. The surrounding writing-mode: tb-rl CSS is applied to the container, but the image itself is not rotated, so the number appears turned 90° counter‑clockwise.

The PNG export works because the layout engine rotates the glyph when it draws the page. The HTML exporter does not apply that extra rotation step yet.


2. Current status

  • The issue has been registered internally (Bug # AWW‑82231).
  • It is scheduled for a fix in an upcoming minor release (expected in the next 2‑3 months, after version 25.13).

While we wait for the fix, you can use the work‑arounds described below.


3. Work‑arounds

3.1. Replace the EQ field with a Unicode character / Symbol font

If the EQ field is only used for simple circled numbers (①‑⑳) you can replace the field with the corresponding Unicode character (U+2460 … U+2473) or use a Symbol/Font‑based glyph. Unicode characters are automatically rendered correctly in vertical layout.

// Example: replace a circled number EQ field with the Unicode character
foreach (Field field in doc.Range.Fields)
{
    if (field.Type == FieldType.FieldEq && field.GetFieldCode().Contains("EQ \\o"))
    {
        // Extract the character code from the field (e.g. \\o(\\* circled 1))
        string unicode = "\u2460"; // ①
        Run run = new Run(doc, unicode);
        field.Remove();               // delete the field
        field.Start.ParentNode.InsertAfter(run, field.Start);
    }
}

Pros – No rotation problem, works in all output formats.
Cons – Only suitable for simple symbols; complex equations must stay as EQ fields.


3.2. Export the document (or the affected pages) as images first

If preserving the exact visual layout is critical, you can:

  1. Save the document (or the specific pages) to PNG/PDF.
  2. Convert those images to HTML manually (e.g., embed the PNGs as you already do).
// Save only the page that contains the vertical text
doc.Save("page1.png", new ImageSaveOptions(SaveFormat.Png) { PageIndex = 0, PageCount = 1 });

Pros – Guarantees pixel‑perfect rendering (identical to Word).
Cons – The resulting HTML is image‑based and not searchable/selectable.


3.3. Use the PDF → HTML conversion route

Aspose.Words can first generate a PDF (which handles the rotation correctly) and then convert that PDF to HTML using Aspose.PDF. The PDF renderer respects the vertical rotation and the PDF‑to‑HTML conversion will embed the correctly oriented glyph as an image.

// 1. Word → PDF (correct rotation)
doc.Save("temp.pdf");

// 2. PDF → HTML (requires Aspose.PDF)
var pdfDoc = new Aspose.Pdf.Document("temp.pdf");
pdfDoc.Save("output.html", new Aspose.Pdf.HtmlSaveOptions());

Pros – Keeps the document searchable (text is extracted from PDF).
Cons – Requires an additional Aspose.PDF license.


3.4. Post‑process the generated HTML

If you only have a few affected EQ fields, you can detect the <img> tag that belongs to the EQ field and add a CSS transform: rotate(90deg); rule at runtime (client‑side or server‑side).

<style>
    .eq-rotate { transform: rotate(90deg); display: inline-block; }
</style>

<!-- Example after post‑processing -->
<img src="data:image/png;base64,..." class="eq-rotate" width="19" height="24" />

Pros – No code changes in the conversion pipeline.
Cons – Manual; you must reliably identify the EQ‑field images.


4. What you can do right now

  1. Open a Support Ticket (if you haven’t already) and quote Bug # AWW‑82231 – the support team will keep you updated on the fix release.
  2. Choose the work‑around that best fits your scenario (Unicode replacement is the cleanest for simple circled numbers).
  3. If you need a temporary fix without code changes, the CSS transform approach is the quickest.

5. In short

Item Current state
Configuration to fix the rotation None – not supported yet
Known limitation / bug Yes – tracked as AWW‑82231
Planned fix In the next minor release (≈ 25.13)
Recommended work‑around Replace EQ field with Unicode, or use image/PDF route, or CSS rotation

Please let us know which workaround works best for you, or if you would like us to prioritize the fix for a particular release. We are happy to assist further!


References


If you have any additional samples or a minimal reproducible document that isolates the problem further, feel free to attach it to the support ticket – it will help us verify the fix as soon as it ships.

@chenweii In this case, to get the content to be rendered closer to MS Word it is required to enable open type features. Aspose.Words.Shaping.Harfbuzz package provides support for OpenType features in Aspose.Words using the HarfBuzz text shaping engine. You should enabling open type features to get the expected result. To achieve this you should add reference to Aspose.Words Shaping Harfbuzz plugin and use the following code to convert your document:

Document doc = new Document(@"C:\Temp\in.docx");
doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;
doc.Save(@"C:\Temp\out_HarfBuzz.png");

sample.png (665 Bytes)

@alexey.noskov Thanks for your replyment.

However, my original question specifically concerns the DOCX → HTML export, not image rendering in general. I have already enabled HarfBuzz and OpenType features, and I can confirm that:

  • DOCX → PNG renders correctly and matches Microsoft Word
  • DOCX → HTML still renders the EQ field incorrectly

During HTML export, EQ fields are converted into images, but the generated images are rendered differently from those produced by a full DOCX → PNG conversion, resulting in incorrect text orientation.

I would like to clarify the following points:

  1. Is there any way to configure or influence how EQ fields are rendered as images during HTML export?
  2. Are the layout and shaping options (such as HarfBuzz / OpenType features) fully applied when generating these images?
  3. Is this a known limitation or bug related to vertical text and EQ fields in DOCX → HTML conversion?

Aspose Html Output

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta http-equiv="Content-Style-Type" content="text/css" /><meta name="generator" content="Aspose.Words for .NET 25.12.0" /><title></title></head><body style="widows:0; orphans:0; font-family:'Times New Roman'; font-size:12pt"><div><table cellspacing="0" cellpadding="0" style="width:31.5pt; margin-left:1.45pt; border-collapse:collapse"><tr style="height:127.1pt; page-break-inside:avoid"><td style="width:28.7pt; height:127.1pt; margin-left:auto; writing-mode:tb-rl; padding-right:1.4pt; padding-left:1.4pt; vertical-align:top; overflow:hidden"><div style="height:127.1pt; margin-left:auto; writing-mode:tb-rl; -aw-ignore:true; overflow:hidden"><p style="margin-top:0pt; margin-bottom:0pt; font-size:14pt"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAAYCAYAAAAYl8YPAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAFNSURBVEhL7ZM/qoNAEIcFgyDkAjmCFh4hVTprbTxAasFglSqpUqa3EQU7K0mRYwSsxFrbWBhBmcdOyLKr+aPvpXwfDDo/xw91XQG+iNAP/sK/7I7nebDZbLA+8VSWJAmoqgrr9RrCMORKkiRwHKd/CzKQLZdLME2zH3P4vo9zfTjZYrGAsizZ6CVZlsF8PucyKrtcLrBarbiLnwiCAGzbpj3Kuq6D2WzGzo3idrtxT4eyoijAMAx2bhRRFMHxeIT9fo89lf0G13XxyMkE4f7pzucznk+pgYx9MjKw2+1G1UvZdrvFgKzQWMg3I2/DyZqmAU3TMJgqIwuQ5zn29D+L45idG8XpdALLsmhPZW3bTv7XZFmGuq5pP9ibZOB6vfZjDnJdFMV+PJQRFEXBlUrTFKqqojnpSa7rOjf/4KnsweFwwP3K1jveyqbyVdkPoTRzLTqMiQgAAAAASUVORK5CYII=" width="19" height="24" alt="" style="vertical-align:middle; -aw-left-pos:0pt; -aw-rel-hpos:column; -aw-rel-vpos:paragraph; -aw-top-pos:0pt; -aw-wrap-type:inline" /><span style="font-family:標楷體">—(    )</span></p></div></td></tr></table><p style="margin-top:0pt; margin-bottom:0pt; line-height:1pt"><span style="font-size:14pt; -aw-import:ignore">&#xa0;</span></p><p style="margin-top:0pt; margin-bottom:0pt"><span style="-aw-import:ignore">&#xa0;</span></p></div></body></html>

Sample Code

using Aspose.Words;
using Aspose.Words.Saving;
using Aspose.Words.Shaping.HarfBuzz;

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

var doc = new Document($@"{rootDir}\Assets\{fileName}.docx")
{
    LayoutOptions = { TextShaperFactory = HarfBuzzTextShaperFactory.Instance }
};
doc.Save("outputHtmlPath", new HtmlSaveOptions
{
    ExportImagesAsBase64 = true
});

@chenweii
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-28977

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.