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

Free Support Forum - aspose.com

Convert emf to png is corrupted

I use the following code to convert emf to png.
When run the code on linux distributions the created png is corrupted.

public class EmfToPng {
public static void main(String… args)
try (EmfImage emfImage = (EmfImage) Image.load(“image.emf”))
PngOptions pngOptions = new PngOptions();
VectorRasterizationOptions rasterizationOptions = new EmfRasterizationOptions();
if (rasterizationOptions != null) {
rasterizationOptions.setPageSize(new SizeF(emfImage.getWidth(), emfImage.getHeight()));
rasterizationOptions.setBackgroundColor(emfImage.hasBackgroundColor() ? emfImage.getBackgroundColor() : Color.getTransparent());
emfImage.save(“image.png”, pngOptions);


Origin image.emf:
image.png (11.0 KB)
image.png - running on windows (OK):
image.png (44.6 KB)
image.png - running on kali (corrupted):
image.png (101.1 KB)
image.png - running on rhel linux (corrupted):
image.jpg (83.6 KB)


Hello, @yifatb,
Could you attach the emf sample causing the exception? So we can explore the issue and provide a feedback then.

image.7z (5.5 KB)

@yifatb Thanks for provided file, we will investigate and answer.

@yifatb We have investigated issue and found, that you need to specify folder with fonts for rendering. You have such fonts in your file: M.S. Gothic, Arial UI, Calibri. You need to add fonts to separate folder and specify path to it using FontSettings.SetFontsFolder(@“c:\Users\USER\Downloads\fonts”);
You can view more at https://docs.aspose.com/imaging/net/manipulating-metafiles/#specifying-font-folder-while-converting or https://docs.aspose.com/imaging/java/manipulating-metafiles/#specifying-font-folder-while-converting