How to add the width and height of the output mathml to the code?

when convert word to htm,officemath to mathml,how to add the width and height in the mahtml code。

getSizeInPixels(float scale, float dpi)

this api calculated result how to add into the corresponding mathml code

just like

<math xmlns="http://www.w3.org/1998/Math/MathML" style="width:11px;height=22px"><mi>f</mi><mo>=</mo><mfrac><mrow><mi>F</mi></mrow><mrow><mn>2</mn></mrow></mfrac>

thanks

@hlgao,

Please ZIP and upload your input Word document and your expected HTML showing the desired output here for testing. We will then investigate the scenario on our end and provide you more information.

@awais.hafeez
thanks
math.zip (11.1 KB)

the width and height of the mahtml code is using the following code

math.getMathRenderer().getSizeInPixels(1, 96)

@hlgao,

Please try using the following code if you want to preserve MathML in exported HTML:

Document doc = new Document("E:\\math\\math.docx");

HtmlSaveOptions opts = new HtmlSaveOptions(SaveFormat.HTML);
opts.setPrettyFormat(true);
opts.setOfficeMathOutputMode(HtmlOfficeMathOutputMode.IMAGE);
opts.setExportImagesAsBase64(true);

doc.save("E:\\Temp\\awjava-19.3.html", opts);

Hope, this helps.

@awais.hafeez
Thank you for your help, but that’s not what I wanted.
I want to output mathml code, but the code has the length and width of this formula

@hlgao,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-18393. We will further look into the details of this requirement and will keep you updated on the status of the linked issue.

@hlgao,

Please also tell how do you plan to use the information about size of rendered formulas? The style="width:11px;height=22px" CSS has no effect on MathML in browsers. We have tested on our end and it seems useless to us. So, please provide complete details of your use-case. Thanks for your cooperation.

@awais.hafeez
I know that has no effect on MathML in browsers.
We will plan render this mathml code as visual content in our own app, and we need to know the size of the rendered mathml code, so that we can leave a place in front of the overall layout.

@hlgao,

Thanks for your further input on this topic. We have logged these details in our issue tracking system and will keep you posted on any further updates.

@hlgao,

Regarding WORDSNET-18393, we have completed the initial analysis of this issue and do not think it is a good idea to implement the feature in Aspose.Words in the way it is requested by you, because:

  • “width” and “height” styles are ignored by MathML renderers so these styles will be useful as size annotations for your particular case only and will be considered needless by other customers.
  • You say that you plan to render MathML in your application and we assume you are not going to use the Aspose.Words’ math renderer for this purpose. It is possible that the result returned by the MathML renderer you use might differ in size from what is produced by Aspose.Words. This will break the scenario, where size from Aspose.Words’ math renderer is used to lay out document contents before MathML is rendered in your application.

If our assumption is right and you are using another MathML renderer in your application, we believe you should use this renderer to get sizes of formulas for layout purposes.

@awais.hafeez
Thank you very much.
I know this requirement is not really in line with the definition of mathml, this is based on one of our requirements, I have used aspose.Words 's api to complete the requirements, but the steps are more complex, thank you again ~

@hlgaom,

Will you manage to fix the issue on your own or are you still in need of assistance?

@awais.hafeez
We’ll take care of the problem ourselves. Thank you very much for your patience.

@hlgao,

Sure. Regarding WORDSNET-18393, we have completed the work on this issue and concluded to close this issue as “Won’t fix”. We are not going to implement this feature, because the use of “width” and “height” styles suggested by you is not in accordance with MathML rendering and specifications. In case you have any further inquiries or need any help in future, please let us know.