Save EMF img to local disk

Hi Developer,

I am using aspose and docx4j to extract data from .docx. when save EMF in docx to xx.PNG in disk, parts of EMF img lost. I am not sure where the problem occur. So ask help here.

In one case,
1 I get EMF with docx4j and piped it into a stream.

BinaryPart bp = (BinaryPart) rp.getPart(rel);
bp.writeDataToOutputStream(bos);
bis = new ByteArrayInputStream(bos.toByteArray());

2 And use aspose to encapsulate it in aspose class “EmfMetafile”.
emf = new EmfMetafile(bis).

3 And create awt image “RenderedImage”.
emf .createDefaultRendering()

4 use awt method to save it to disk with png format.

I not sure where the issue located(docx4j / aspose / awt), so want to ask a question:
aspose has chance to lose data in this process?

Thanks!
sshenllan


Hi Sshenllan,


Thank you for using Aspose products.

As you are using multiple libraries to achieve your ultimate goal therefore I can only comment on Aspose.Imaging part. You can skip using AWT if it is only handling the EMF to PNG conversion because the latest version of Aspose.Imaging for Java 2.1.0 can efficiently convert meta-files to raster images including PNG format without loosing any data. Please check the article, and give the latest version a try on your end.

In case the problem persists, we would request you to please provide us a sample project covering your complete scenario along with referenced libraries. We will review it on our end to assist you further in this regard.

Hi Babar Raza,

Thanks for quick reply.

I tried the lib you gave today. And follow that article, replace the awt download code by aspose one.(of course, binary still got from docx4j). But nothing changed. histogram and line graph still show the left 60%. And the right 40% missing.

Sorry I can not give a demo project now.

Thanks again,

sshenllan

Hi Sshenllan,


Thank you for writing back, and sorry to know the Aspose.Imaging for Java 2.1.0 didn’t help in your scenario. Unfortunately, we require samples (project and files) to evaluate the problem on our end, and especially to establish the presented scenario as bug on the part of Aspose APIs. Therefore it is essential for us to acquire such information, and log tickets (where applicable) in case of undesired results.

Thank you for your cooperation and understanding.

Hi Babar Raza,

I tried use aspose only to extract my emf from docx. it's easy to use and perfect.

So maybe docx4j lost some data when pipe in stream.

Sorry for your time for my legacy code.

Thanks again,

sshenllan

Hi Sshenllan,


Thank you for your confirmation, and good to know that you are up & running again. Please feel free to write back in case you need our further assistance with your project.