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

Free Support Forum - aspose.com

EMF/WMF format to png missing chinese characters

hi there,

The library is really easy to use, but when my client translate emf file to png, which contains some chinese characters, these characters in the png file are missing, instead, some rectangles is showed. The code is copied from github .is there any solution?

     public static byte[] transWmf(byte[] src) throws Exception {
		Image image = Image.load(new ByteArrayInputStream(src));
		ByteArrayOutputStream output = new ByteArrayOutputStream();
		try {
			// Calculate new height
			double k = (image.getWidth() * 1.00) / image.getHeight();

			// Create an instance of EmfRasterizationOptions class and define
			EmfRasterizationOptions emf = new EmfRasterizationOptions();
			emf.setPageHeight((int) Math.round(400 / k));
			PngOptions options = new PngOptions();

			// Call the save method, provide output path and PngOptions to
			// convert the WMF file to PNG and save the output

			image.save(output, options);
		} catch (Exception e){
			return null;
		} finally {
		return output.toByteArray();


I have observed your comments. Can you please share source files, generated result, environment details along with which Aspose.Imaging version you are using on your end so that we can help you out.

image_and_code.zip (356.1 KB)

thanks for reply, here is the test code, source emf, target png and the run result.
The version is aspose-imaging-18.4-jdk16.jar


I have worked with source file and sample code shared by you using Aspose.Imaging for Java 18.7 and unable to observe any issue. I have also shared my generated result with you for your kind reference. Please check attachment. Can you please try to use Aspose.Imaging 18.7 on your end and share environment details with us if there is still an issue.ConvertEMFtoAllRasterImageFormats_out.zip (300.1 KB)

Still the same problem. In the zip file i uploaded, the mainly problem lays in that the library used Dialog.bold Dialog.plain font, and i think they don’t support chinese character.

The strange thing is that:

  1. If i set the default font name to X(com.aspose.imaging.FontSettings.setDefaultFontName ) and install the font X, the library works well. However, if the real font is not exactly the special font i set, the result is not prefect…
  2. If i don’t set the font name, on some machine, the library can choose the right font name. Of course, there is
    the right font on the machine.

solution 2 may be better, but I have no idea why.

OK, after some test, solution 2 seems to be fine. Maybe need more test.


I have observed your comments. Can you please share environment details with us so that we may further investigate to help you out.

The evnironment is some version linux custom made by our company, and the font library is printed in the attachment.


I have observed your comments. An issue with ID IMAGINGJAVA-1068 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.