A problem about mathematical formula

Hi,
We have a problem about mathematical formula using by Aspose.words.jdk15 for java,we try to convert the formula to image,but the image could’t be opend by IE Explorer.What can I do for it?

Hi Lin,

Thanks for your inquiry. I have converted your document to JPEG, BMP, PNG file format and have successfully opened in internet explorer. It would be great if you please share to which image format you are saving image file. Please share your internet explorer version.

I suggest you to use latest version of Aspose.Words for Java and let us know how it goes on your side. I hope, this will help.

Hi,
I’m sorry for that I uploaded the wrong file.
I try to covert the attachment to PNG, JPEG, WMF file format and only the WMF format could opened in internet explorer 8.0 but failed opend in other browser such as Chrome.

Hi Lin,

Thanks for sharing the details. I have used the latest version of Aspose.Words for Java to convert Doc to Png/Jpeg file with following code snippet. I have not faced any issue while opening images in browser Chrome/FireFox/IE. Please see the attached images.

Document doc = new Document(MyDir + "Test10.doc");
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.JPEG);
options.setPageCount(1);
options.setPageIndex(0);
doc.save(MyDir + "Test10.jpeg", options);

I suggest you to use latest version of Aspose.Words for Java and let us know how it goes on your side. I hope, this will help.

If you still face problem, please share browser version along with output images.

Hi,
I’m sorry that I try to convert the mathematical
formula in the document instead of the document to PNG.

String path = "D:/test/";
Document doc = new Document(path + "08-1030.doc");
NodeCollection nodes = doc.getChildNodes(NodeType.SHAPE, true);
int index = 1;
for (Shape shape : nodes)
{
    if (shape.hasImage())
    {
        shape.getImageData().save(path + "images/" + index++ + ".PNG");
    }
}

Hi Lin,

Thanks for sharing the details. Please use the following code snippet to extract images from document. Your document contains some images of type .wmf.

Document doc = new Document(getMyDir() + "Image.SampleImages.doc");
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
int imageIndex = 0;
for (Shape shape : (Iterable<Shape>) shapes)
{
    if (shape.hasImage())
    {
        String imageFileName = java.text.MessageFormat.format(
                "Image.ExportImages.{0} Out{1}", imageIndex, 
           FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType()));
        shape.getImageData().save(getMyDir() + imageFileName);
        imageIndex++;
    }
}

Hi,
Thanks for the reply,I know the type of the images is wmf, but it can’t be opened by Chrome or Firefox. What my aim is to generate rich html with the document,I must convert the wmf to some type such as PNG and JPEG which can be opened by any browser . What can I do with aspose?

Hi Lin,

Thanks for sharing the further details. You can use Shape.getShapeRenderer method to convert shapes to JPEG/PNG file format as shown in following code snippet.

Document doc = new Document(MyDir + "in.doc");
int i = 0;
for (Shape shape : (Iterable<Shape>)doc.getChildNodes(NodeType.SHAPE, true))
{
    if (shape.hasImage())
    {
        ShapeRenderer r = shape.getShapeRenderer();
        ImageSaveOptions imageOptions = new ImageSaveOptions(SaveFormat.JPEG);
        r.save(MyDir + "img" + i + ".jpg", imageOptions);
        i++;
    }
}

Moreover, I suggest you to read HtmlSaveOptions deails from here:
https://reference.aspose.com/words/java/com.aspose.words/htmlsaveoptions/
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi,
Thanks for the reply,I have successfully converted the images to JPG and opened in the internet explorer,but I’m very disappointed the content of the images are overlapping, and I have no idea to solve the problem. What can I do for it?

Hi Lin,

Please accept my apologies for your inconvenience.

Perhaps, you are using an older version of Aspose.Words; as with Aspose.Words v11.10.0, I am unable to reproduce this problem on my side. I would suggest you please upgrade to the latest version of Aspose.Words i.e. v11.10.0 and let us know how it goes on your side. I hope, this will help. I have attached the output images with this post.

If you are using the latest version, please share your working environment. I have tested this scenario at Windows7/Jdk 1.5.