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

Free Support Forum - aspose.com

Equation in EMF image is not saving to PNG properly

Hi Team,

Aspose: 21.6
Language: net.

We have added an emf image in a slide that contains an equation.
When saving an image of the shape, its output image is squished and not proper.

Can you please take a look and share your thoughts?
sample.zip (25.3 KB)
output.png (7.0 KB)

            Presentation m_Presentation = new Presentation("sample.pptx");

        	for (int i = 0; i < m_Presentation.Slides.Count; i++)
				var slides = m_Presentation.Slides[i];
				for (int j = 0; j < slides.Shapes.Count; j++)
					var shape = slides.Shapes[j];
					var curAutoShape = shape as IPictureFrame;
					String ImagePath = "./input/imagepershape/";

					using (var cloneShapeImage = curAutoShape.ToBitmap())
						Guid curId = Guid.NewGuid();

						cloneShapeImage.Save(ImagePath + "Slide_" + curId.ToString() + ".png", System.Drawing.Imaging.ImageFormat.Png);

    public static Bitmap ToBitmap(this IShape shape)
		return shape.GetThumbnail(ShapeThumbnailBounds.Slide, 2, 2);


Thank you for the issue description. I reproduced the problem and logged the issue with ID SLIDESNET-42680 in our tracking system. Our development team will investigate this case. You will be notified when it is fixed.

Thanks, @Andrey_Potapov,

Meanwhile, can you share a workaround that is available?

Also, Is there any ETA you can provide us?

~ Praveen

Unfortunately, I don’t see any workaround for this case. I requested the ETA for this issue from our development team. I will let you know as soon as I know.

Hi @Andrey_Potapov

Can you share any ETA if you have one?


We have investigated the issue further on our end. There’re two font create records (EmfExtCreateFontInDirectW), both “Cambria Math”: VARIABLE_PITCH and DEFAULT_PITCH.

The actual text is 2-byte per char (multibyte), and the method/code that causes the issue is:

EmfBaseTextOutPlayer.DrawText, line 190:

                    for (int i = 0; i < text.Length; i++)
                        PointF pointF = new PointF(location.X+ dx, location.Y + dy);

                        DrawString(text[i].ToString(), font, brush, new RectangleF(pointF.X, pointF.Y, 0, 0), sf, wmfFontQuality, mode, context);

                        dx += dxBuffer[dIndex++];

                        if ((options & EmfExtTextOutOptions.ETO_PDY) == EmfExtTextOutOptions.ETO_PDY)
                            dy += dxBuffer[dIndex++];

The length of the text is not the same as the text array length. When we tried to pass the multibyte string parts for “DrawString(text[i].ToString(), …)” the output is correct. Can you please perform the suggested option.

Hi @mudassir.fayyaz,

Seems either there is some confusion or something I am missing.

We do not use API code to draw text, rather directly use an EMF image inside the slide.

Now, all we do is iterate all the shapes (emf image being one) and create an image using getthumbnail() method.

I am unable to understand the context of fonts and EmfBaseTextOutPlayer.DrawText,

Can you please elaborate a bit more?

~ Praveen


Thank you for the elaboration. I have associated the information in our issue tracking system and we will get back to you with further feedback as soon as it will be shared.

Thanks @mudassir.fayyaz

Can you please reopen the issue, I don’t think it should be marked resolved yet.


It’s already in progress based on your comments and our development team will mark it opened if they will observe any issue. We will share good news with you as soon as it will be completed.

Hi @mudassir.fayyaz,

I am slightly worried as the issue still showing me to be resolved

Issues Status

SLIDESNET-42680 ---- Status : Resolved

But since it’s a bug with the product, can you provide an ETA?


It is not yet fixed and likely (not sure) to get fixed in Aspose.Slides for .NET 21.8. We request for your patience and will share good news with you as soon as the issue will be fixed.

The issues you have found earlier (filed as SLIDESNET-42680) have been fixed in this update.