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

Free Support Forum - aspose.com

API returns value for "width" as zero for the AutoShape

Hi Team

Aspose Version: 20.1
Language: C#


m_Presentation = new Presentation(pptpath);

Debug Expression:

((Aspose.Slides.Shape)(new System.Linq.SystemCore_EnumerableDebugView<Aspose.Slides.IShape>(((Aspose.Slides.BaseSlide)(new System.Linq.SystemCore_EnumerableDebugView<Aspose.Slides.ISlide>(m_Presentation.Slides).Items[0])).Shapes).Items[0])).Width


Auto shape used in PPTX, Aspose library is returning proper value for height but not for width.
The width is coming as 0.
Attached file has 1 slide with 1 shape used in it
sample.zip (73.0 KB)

Can you share your thoughts on this?

~ Praveen

Thank you for your query. I investigated this case and found that IShape.Width property returns correct value. Please look at the value displayed in PowerPoint: shape_width.png (10.5 KB). You should find out how this shape has been created.

Hi Andrey,

Thanks for looking into it, and sharing your thoughts,

I was looking at this particular width property in the attached sample file. When I change this value (as shown in the below file, I see the width of the shape increase whereas when I change what you are referring to, I see that shape rotates on a particular axis.

Width Sample.png (12.9 KB)

How does Aspose differentiate between the width you were referring to and the one in the attachment (Width Sample.png)?

~ Praveen


Yes, I noticed this strange behavior in PowerPoint as well. If that shape was created using Aspose.Slides and its behavior is incorrect, please share the code example reproducing the error.

The width displayed in your screenshot is the line width. You can get its value as below:

var width = presentation.Slides[0].Shapes[0].LineFormat.GetEffective().Width;

More details: Line
API Reference: ILineFormat Interface

Hi @Andrey_Potapov,

Thanks for the input, I took a look at it.

Here is my question about where you can help.

I created a blank slide, added a line using shapes in PowerPoint. (All with MS PowerPoint, no API code).

Now, I see there are two width options (shown in attached images), one increases the width and another rotates the line.

We have a piece of code internally which does some of the checks on height and width Example

if(shape.height == 0 || shape.width == 0) {
// Do something

Question 1
Based on the above discussion, are you suggesting if the shape we are acting on is a line shape, then we should not be relying on shape.width and instead rely on LineFormat.GetEffective().Width;

Can you confirm that?

Question 2
Also, is there any specific reason why line shape uses a different method on relying on using LineFormat.GetEffective().Width instead of just shape.width ?

My understanding was that even in the case of line, shape.width should return the correct WIDTH of shape

~ Praveen

Sample.zip (23.5 KB)
Width in line fill section.png (8.2 KB)
Width in size section.png (5.4 KB)


Please check the attached image that is view of shape properties opened in PowerPoint. The width of the shape is appearing to be 0 in PowerPoint. I request you to please check the presentation on your end, make some changes and then verify. If there is still an issue, please feel free to share with us.
image.png (319.8 KB)

Hi @mudassir.fayyaz,

I do understand that it shows width but when increasing its value, it rotates the shape.

Which is why I asked those questions previously, as when the width is derived from another section, why does API returns the value of something which rotates and does not increase width?

Can you please go through my previous comment and understand the concern I am sharing.

~ Praveen


The image that I showed to you was of your source file being opened in PowerPoint and exhibiting 0 width even in PowerPoint. The API read the values of shape width just as PowerPoint from presentation XML data.

Can you please elaborate this with example code, source file and generated output.