Free Support Forum - aspose.com

Missing content in the EMF file

Please take a look at the following code snippet:

import com.aspose.diagram.Diagram;    
import com.aspose.diagram.SaveFileFormat;
import com.aspose.imaging.Image;
import com.aspose.imaging.fileformats.emf.MetaImage;
import org.apache.commons.io.FileUtils;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;

String visioPath = "Microsoft_Visio_Drawing.vsdx";
String emfPath = "Microsoft_Visio_Drawing.emf";

byte[] bytes = null;

try(ByteArrayOutputStream baos = new ByteArrayOutputStream())
{
    Diagram diagram = new Diagram(visioPath);
    diagram.save(baos, SaveFileFormat.EMF);
    bytes = baos.toByteArray();
}
catch (Exception e)
{
    e.printStackTrace();
}

try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
     InputStream is = new ByteArrayInputStream(bytes);
     MetaImage metaImage = (MetaImage) Image.load(is))
{
    metaImage.save(baos);
    FileUtils.writeByteArrayToFile(new File(emfPath), baos.toByteArray());
}
catch (Exception e)
{
    e.printStackTrace();
}

The code converts following VSDX file: Microsoft_Visio_Drawing.zip (333.5 KB)
There is some missing content in the EMF target file: Microsoft_Visio_Drawing-emf.zip (277.1 KB)

@wjeczalik

Can you please confirm if you are observing missing content of VSDX file when saving using Aspose.Diagram on your end. Can you please verify and share the output EMF of following code with us as it will help in narrowing down the root cause that wether issue is in Aspose.Diagram or Aspose.Imaging.

try(ByteArrayOutputStream baos = new ByteArrayOutputStream())
{
    Diagram diagram = new Diagram(visioPath);
    diagram.save("saved.emf", SaveFileFormat.EMF);
    bytes = baos.toByteArray();
}
catch (Exception e)
{
    e.printStackTrace();
}

The following outputs is received on saving visio file to PNG which appears to have issue.
page_1 4.png (91.8 KB)

It seems to be a problem with Aspose-Imaging, because a problem with Aspose-Diagram was reported here: Missing content in the EMF converted from the VSDX and it works with the recently released Aspose-Diagram library. There is also attached output EMF file.

@wjeczalik

Can you please provide the EMF generated on your end using Aspose.Diagram and that I may use to verify using Aspose.Imaging. You can save the exported EMF on disk using above code.

Here it is: emf.zip (276.9 KB).

@wjeczalik

Thank you for sharing the feedback. A ticket with ID IMAGINGJAVA-7811 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been lined with the issue so that you may be notified once the issue will be fixed.