Shape Size in PPTX is Different from the Shape Size in SVG

Hi!

I detected that some auto shapes have differences between the size returned by corresponding “getWidth()” and “getHeight()” methods, and the size used when writting as SVG.

I used:

  • O.S: Ubuntu 20.04.2 LTS
  • Java: openjdk 11.0.9.1
  • Source PPT: autoshapes2.zip (14.8 KB)
  • Resulting SVGs: shapes.zip (10.7 KB)
  • Sample code:

IPresentation ppt = new com.aspose.slides.Presentation("/home/users/Downloads/autoshapes2.pptx");

/**
Code to license
**/

for (IShape shape : ppt.getSlides().get_Item(0).getShapes()) {
SVGOptions opts = new SVGOptions();
opts.setPicturesCompression(0);

System.out.println(shape.getWidth());
System.out.println(shape.getHeight());

shape.writeAsSvg(new FileOutputStream(new File("/home/user/folder/image.svg")), opts);
}

@rsalado,
Thank you for the query. I checked the shape size using Aspose.Slides. If you compare it with the size in PowerPoint, you can see the same values.

But the size used in the generated SVG is not the same. There are differences between the values returned by the methods “getWidth” and “getHeight”, and the size used in the SVG. Specifically, the width is different.

In this case, “getWidth” returns 302.22992, but in the SVG, the width is 247.999968.

@rsalado,

Could you please clarify, how was this value calculated?

If you open the exported SVG in a text editor, the tag has width=“2.583333in”. And, “2.583333in” as 247.999968 px

@rsalado,
Thank you, I will answer you later.

@rsalado,
The SVG width attribute contains the displayed width of the rectangular viewport. SVG images obtained through Aspose.Slides and PowerPoint are identical in size but created in different coordinate systems. You can compare the sizes in a vector graphics editor.

According to Aspose.Slides, this AutoShape has the same width and height, but the resulting SVG has different proportions as you can see (another way to check this: if you try to convert the resulting SVG in a JPG with any image conversor, you can see that the resulting image is not square). So the problem has to be somewhere.

@rsalado,
I checked and made sure that PowerPoint created the SVG shape with different proportions as well. This is because SVG is the vector format.

Ok… this problem is not present in other versions of Aspose (for example, Aspose.Slides 20.1). In this version, the resulting SVG proportions are correct.

I suppose then that is something that you have consciously changed, right?

Anyway, this behavior still seems strange to me in the new versions of Aspose.

@rsalado,
Thank you for the additional information. I checked it and found no public information about this change for SVG export. I added a ticket with ID SLIDESJAVA-38556 in our tracking system. Our development team will investigate this change. I will inform you of any news.

@rsalado,
Our development team investigated the issue. At the moment, Aspose.Slides reproduces the behavior of PowerPoint. But if you need to save shapes as SVG in different ways, we can add an appropriate API. Please take a look at IShape.getThumbnail method. If the capabilities of this method suit you, we could implement something similar for SVG.

@Andrey_Potapov IShape.getThumbnail is enough for us. Thanks!