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

Free Support Forum - aspose.com

Reading formulas as images instead of text/OMML

Hi all,

in older versions of Aspose.Words for Java (we were using 3.3.0), the equations in the attached DOCX were read as shapes with image data apparently from the bitmaps embedded in the DOCX archive 5002425_10_part.docx.zip (22.1 KB)
. Using 17.7, the library seems smart enough to parse the math markup in document.xml and convert it to text, so there is no shape. However we need the images for our postprocessing workflow. Is there a way to mimic the old behaviour in 17.7?

Best regards,
Markus

@sschepper

Thanks for your inquiry. You can use getMathRenderer method to render Office Math to image. Please check following sample code snippet for the purpose.

Document doc = new Document("5002425_10_part.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
int imageIndex = 1;

NodeCollection<OfficeMath> equations = doc.getChildNodes(	NodeType.OFFICE_MATH, true);

for (OfficeMath equation : equations) {
	// Save Group shape as image
	equation.getMathRenderer().save("output"+ imageIndex++ + ".bmp", new ImageSaveOptions(SaveFormat.BMP));
	
}