We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Extract mathematical formulas from word and convert it to images

I am parsing word document, and i want to extract mathematical formulas and conver them to image, can Aspose.wrod api realize my require?

Hi there,


Thanks for your inquiry. OfficeMath.GetMathRenderer method creates and returns an object that can be used to render math equation into an image. The OfficeMathRenderer class provides methods to render an individual OfficeMath to a raster or vector image or to a Graphics object.

Please use OfficeMathRenderer.Save method as shown below to convert OfficeMath node to image. Hope this helps you.

<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 9pt; background-color: rgb(255, 255, 255);”>Document doc = <span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>new <span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 9pt; background-color: rgb(255, 255, 255);”>Document(<span style=“color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt; font-style: italic;”>getMyDir<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 9pt; background-color: rgb(255, 255, 255);”>() + <span style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt; color: rgb(0, 128, 0); font-weight: bold;”>“input.docx”<span style=“color: rgb(51, 51, 51); font-family: “Courier New”; font-size: 9pt; background-color: rgb(255, 255, 255);”>);
<pre style=“font-family: “Courier New”; font-size: 9pt;”>OfficeMath math = (OfficeMath)doc.getChild(NodeType.OFFICE_MATH, 0, true);
math.getMathRenderer().save(getMyDir() + “formula.png”, new ImageSaveOptions(SaveFormat.PNG));