Free Support Forum - aspose.com

EMF image export failed with java.lang.NullPointerException


#1

Hi,

I tried to save the attached emf image as png with the following java code:

import java.io.ByteArrayOutputStream;

import com.aspose.imaging.Image;
import com.aspose.imaging.imageoptions.PngOptions;
import com.aspose.imaging.imageoptions.EmfRasterizationOptions;

public class ImageRenderEmf
{
    public static void main( String[] args ) throws Exception
    {
		Image image = Image.load( "example.emf" );
				
		// Create output stream
		ByteArrayOutputStream bytearrayoutputStream = new ByteArrayOutputStream();
		
		PngOptions pngOptions = new PngOptions();

		pngOptions.setVectorRasterizationOptions( new EmfRasterizationOptions() );
		pngOptions.getVectorRasterizationOptions().setPageWidth( image.getWidth() );
		pngOptions.getVectorRasterizationOptions().setPageHeight( image.getHeight() );

		image.save( bytearrayoutputStream, pngOptions );
	}
}

The following exception is thrown:

Exception in thread "main" class com.aspose.imaging.coreexceptions.ImageSaveException: Image export failed. ---> java.lang.NullPointerException
   --- End of inner exception stack trace ---
com.aspose.imaging.Image.a(Unknown Source)
com.aspose.imaging.I.a(Unknown Source)
com.aspose.imaging.internal.fm.b.a(Unknown Source)
com.aspose.imaging.internal.fm.c.a(Unknown Source)
com.aspose.imaging.Image.save(Unknown Source)
ImageRenderEmf.main(ImageRenderEmf.java:26)
	at com.aspose.imaging.Image.a(Unknown Source)
	at com.aspose.imaging.I.a(Unknown Source)
	at com.aspose.imaging.internal.fm.b.a(Unknown Source)
	at com.aspose.imaging.internal.fm.c.a(Unknown Source)
	at com.aspose.imaging.Image.save(Unknown Source)
	at ImageRenderEmf.main(ImageRenderEmf.java:26)
Caused by: java.lang.NullPointerException
	at com.aspose.imaging.internal.go.c.a(Unknown Source)
	at com.aspose.imaging.internal.go.F.a(Unknown Source)
	at com.aspose.imaging.internal.gn.D.a(Unknown Source)
	at com.aspose.imaging.internal.gn.D.a(Unknown Source)
	at com.aspose.imaging.internal.gm.c.a(Unknown Source)
	at com.aspose.imaging.internal.gi.j.a(Unknown Source)
	at com.aspose.imaging.internal.gi.p.a(Unknown Source)
	at com.aspose.imaging.internal.gi.p.a(Unknown Source)
	at com.aspose.imaging.internal.gu.a.c(Unknown Source)
	at com.aspose.imaging.internal.fD.e.a(Unknown Source)
	at com.aspose.imaging.internal.fD.e.a(Unknown Source)
	at com.aspose.imaging.internal.fD.e.a(Unknown Source)
	at com.aspose.imaging.internal.fD.e.a(Unknown Source)
	at com.aspose.imaging.internal.fC.k.b(Unknown Source)
	at com.aspose.imaging.internal.fC.a.a(Unknown Source)
	at com.aspose.imaging.internal.fC.a.export(Unknown Source)
	... 6 more

Regards,
Michael

example.zip (1.2 MB)


#2

@mstrucken,

I have worked with the sample file shared by you and have been able to observe the issue specified. An issue with ID IMAGINGJAVA-1137 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once issue will be fixed.