Problem of Word euqation rendering as jpeg, ' in superscript is misrendered in the subscript

problem of word equation rendering as jpeg.docx (68.6 KB)

My Codes for export the euqation are as follows:

private String getOfficeMatchContent(Node node) throws Exception {
        OfficeMath officeMath = (OfficeMath) node;
        ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
        OfficeMathRenderer officeMathRenderer = new OfficeMathRenderer(officeMath);

        saveOptions.setResolution(300); 
        saveOptions.setUseAntiAliasing(true); 
        saveOptions.setUseHighQualityRendering(true);
        saveOptions.setJpegQuality(100);
        saveOptions.setAllowEmbeddingPostScriptFonts(true);
        
        String filename = UUID.randomUUID().toString() + ".jpg";
        
        officeMathRenderer.save(this.dir + File.separator + filename, saveOptions);

        return "<img src=\"" + filename + "\" />";
    }

The ’ in the superscript is misrendered in the subscript:

Any one has idea how to solve this?

@openpto

It seems you are experiencing an issue with the rendering of equations in JPEG format, specifically with the character ' in superscript being misrendered as subscript. This can sometimes occur due to the way the rendering engine interprets the formatting of the OfficeMath objects.

To address this issue, you might want to consider the following steps:

  1. Check the OfficeMath Object: Ensure that the OfficeMath object is correctly formatted before rendering. Sometimes, the issue may stem from how the equation is structured in the original document.

  2. Adjust Rendering Options: You are already using high-quality rendering options, but you might want to experiment with different settings in the ImageSaveOptions. For instance, try adjusting the resolution or the anti-aliasing settings to see if it affects the output.

  3. Update Aspose Library: Ensure that you are using the latest version of the Aspose.Words library. Updates often include bug fixes and improvements that could resolve rendering issues.

  4. Test with Different Formats: If possible, try rendering the equation in a different image format (like PNG) to see if the issue persists. This can help determine if the problem is specific to JPEG rendering.

  5. Review Example Code: You can refer to example implementations that demonstrate how to work with OfficeMath rendering. For instance, there are examples available that show how to render shapes and OfficeMath objects, which might provide insights into best practices for your implementation.

Here is a sample code snippet that demonstrates how to render an OfficeMath object, which you can compare with your implementation:

Document doc = new Document("path/to/your/document.docx");
OfficeMath officeMath = (OfficeMath) doc.getChild(NodeType.OfficeMath, 0, true);
ImageSaveOptions saveOptions = new ImageSaveOptions(SaveFormat.JPEG);
saveOptions.setResolution(300);
saveOptions.setUseAntiAliasing(true);
saveOptions.setUseHighQualityRendering(true);
saveOptions.setJpegQuality(100);

OfficeMathRenderer officeMathRenderer = new OfficeMathRenderer(officeMath);
officeMathRenderer.save("output/path/filename.jpg", saveOptions);

If the problem persists after trying these suggestions, consider reaching out to Aspose support with specific details about your issue, including the document and the exact rendering settings you are using.

Feel free to ask if you have any further questions or need additional assistance!

@openpto
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-27716

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.