'Is there a way to adjust Powerpoint chart inside of web application?

Current behavior: I'm generating PowerPoint presentation using Aspose Slides and I'm adding some charts (simple rectangles) with connectors in few slides.

What I want to achieve: I'd like to have a possibility to adjust some shapes/connectors positions manually in my web application and reflect those adjustments in final powerpoint file.

Example:

Next code e.g. is creating 3 rectangles and a connector between 2 of them. This connector is crossing the third rectangle and I want user to do final adjustments, to shift the intersected rectangle or to rearrange the connector itself

using (var presentation = new Presentation())
        {
            var slide = presentation.Slides[0];
            var primaryShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 50, 100, 30);
            primaryShape.TextFrame.Text = "shape 1";

            var targetShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 350, 250, 100, 30);
            targetShape.TextFrame.Text = "shape 2";

            var intersectedShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 300, 180, 100, 30);
            intersectedShape.TextFrame.Text = "intersected shape";

            var arrow = slide.Shapes.AddConnector(ShapeType.CurvedConnector2, 0, 0, 10, 10, true);
            arrow.LineFormat.FillFormat.FillType = FillType.Solid;
            arrow.LineFormat.FillFormat.SolidFillColor.Color = System.Drawing.Color.Red;
            arrow.StartShapeConnectionSiteIndex = 3;
            arrow.StartShapeConnectedTo = primaryShape;
            arrow.EndShapeConnectedTo = targetShape;
            arrow.EndShapeConnectionSiteIndex = 0;

            presentation.Save(fileNameToSave, Aspose.Slides.Export.SaveFormat.Pptx);
        }

What I tried and issues:

1) I tried to display my charts in Angular charting frameworks since I know rectangles positions and type of connectors. Issues: Aspose is not providing exact information where connectors are passing and if for example they overlap some shape. The same issue is for saving back process. If some connector is crossing a shape and I will adjust it in my web app - I cannot save it 1 to 1 in the powerpoint slide. In general the issue here is that I'm introducing my own rules on how to draw connectors and it is in-line with powerpoint engine rules.

2) I tried to export chart as SVG to have some manipulations over SVG objects and then import it back. Issues: SVG is representing connectors as rectangles with some image of connector. No connection information, nothing. Moreover, during the import back from SVG to Powerpoint - the result is totally unpredictable and connection of shapes are not stored. The PPT becomes useless for later manipulations.

Questions

Is there any other way of such manipulation? Maybe another approach - like using native Office API? I was also thinking about any way of embedded adjustement, e.g. to have an Iframe in which I can display only my chart (extracted from the initial file) and allow adjustments, and then import it back. In this case it will be guaranteed 1 to 1 relation and I will not throw in the middle my own rules of drawing, but I found nothing to achieve such behavior. Only Office 365, but it cannot be integrated in a such way as I know.

Thank you for any advice



Solution 1:[1]

I have observed your requirements and regret to share that there is no provision in Aspose.Slides at the moment that would return the actual X,Y coordinates of connector points on the slide. However, we have created a new feature request in our issue tracking system with ID SLIDESNET-41675 that would return Coordinates of connector points on slide. Using these points you may draw arbitrary line and devise your own logic if that line passes through any of already added shape. I hope this feature will be helpful to you when implemented.

As far as your second point concerning to SVG to slide is concerned, I like to share that when you import SVG to slide, it is imported as image and not as slide object or shapes. If you are facing any issue in importing SVG to slide, please share the source SVG and generated PPTX having issue on your end with us and we will try our best to help you further.

I am working as Support developer/ Evangelist at Aspose.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wai Ha Lee