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

Free Support Forum - aspose.com

Drawing a line with negative width or height causes AddClone to fail and/or corrupted .pptx

As the title says : "Drawing a line with negative width or height causes AddClone to fail and/or corrupted .pptx"

Try the following code snippet...

PresentationEx pex1 = new PresentationEx();

PresentationEx pex2 = new PresentationEx();

SlideEx s1 = pex1.Slides[0];

float x = 100.1F;

float y = 100.1F;

float width = -100.1F;

float height = 100.1F;

int idRect = s1.Shapes.AddAutoShape(ShapeTypeEx.Line, x, y, width, height);

AutoShapeEx shape = (AutoShapeEx)s1.Shapes[idRect];

pex2.Slides.AddClone(s1);

For me it fails with "Das 'cx'-Attribut hat gemäß seinem Datentyp einen ungültigen Wert."

I am using the most upto date version of the library.

If you set the width/height to positive values... all is ok. Change either to a negative value... CRASH.

Hi,


I have observed that while setting the line width to negative the issue happens. If you see, you can’t even set the line width to negative even in PowerPoint. Please try setting the line width to positive values.

Many Thanks,

Hi Mudassir,

I'm not really sure you understand the problem.

In the PPT API you (sensibly) draw a line by specifying two Points, a begin and end coordinate.

In the PPTx API (if I am not mistaken) this is no longer possible - a line is described as a rectangle.

Now... tell me how to draw a line from the "top right" corner of a rectangle to the "bottom left", for instance. Go on, try it.

As far as I can see, it is only possible (given the current way lines are described) to draw lines in the first quadrant (i.e. from vertical to horizontal from left to right).

We have a complete "solution", but it is an expensive kludge.

We can change the question, if you like, to "how do you draw a line with a negative gradient from a known point" if you like...

... but you should also know that even if negative width/heights are not allowed, Aspose should not fail at runtime without good error messages, should it. That was a nasty bug to track down.

Hi,
Thanks for using Aspose.Slides.

Code snippet for drawing a line with a negative gradient.

PresentationEx pex1 = new PresentationEx();
PresentationEx pex2 = new PresentationEx();

SlideEx s1 = pex1.Slides[0];

float x = 0.0F;
float y = 100.0F;
float width = 100.0F;
float height = 0.0F;

int idRect = s1.Shapes.AddAutoShape(ShapeTypeEx.Line, x, y, width, height);

AutoShapeEx shape = (AutoShapeEx)s1.Shapes[idRect];
shape.Rotation = -45;

pex2.Slides.AddClone(s1);

I hope this will work for you.

We are here to serve our valued customers.

Best Regards

ok, now think of a *realistic* use case.

Somebody wants to draw a line, lets say a line leading from a point to a textual annotation (as is ONE of our use cases).

You know the position of the point you want to draw the line to, and where you want it to go.

Now, try getting that to work with rotation - which *rotates around the center point*. Go on, implement it.

Using rotation was the first idea for a kludge, but dismissed pretty much instantaniously. Try implementing it and you'll see it's more pain than it is worth.

We have a fairly elegant hack, which doesn't use rotation, but I want to drive home the point that your implementation of lines in the PPTx API is a failure.

You will realise you are imposing an unacceptable burden on your customers, when 1000000 developers all have to reinvent the same ugly wheel each time.

If, on the other hand, I am mistaken about rotate, and there is a way to rotate it around a given corner, or point - I will humbly withdraw my criticism of your solution, but instead criticise your sparse documentation.

Implement whatever logic you need to internally, but give us back the ability to define lines by points. Please.

Hi Daimler,

I have tested the scenario and I am able to reproduce the same problem which you faced. For the sake of correction, I have logged this issue as SLIDESNET-33139 in our issue tracking system. Our development team will look into this issue and you will be updated via this forum thread once it is resolved.

We apologize for your inconvenience.

Best Regards