none
Read text, X, Y coordinates of shape placed on slide layout

    Question

  • Sorry for my English :)

    I try read XY coordinates and text of shapes placed on the first slide:

    public static void Read(string presentationPath)
    {
        using (var doc = PresentationDocument.Open(presentationPath, false))
        {
            var firstSlideShapes = doc.PresentationPart.SlideParts.First().Slide.CommonSlideData
                .ShapeTree.Elements<DocumentFormat.OpenXml.Presentation.Shape>();
            foreach (var shape in firstSlideShapes)
            {
                // If shape has text write to debug
                var texts = shape.Descendants<DocumentFormat.OpenXml.Drawing.Text>();
                foreach (var text in texts)
                {
                    Debug.WriteLine(text.Text);
                }
    
                // Read x and y coordinates
                var t2D = shape.ShapeProperties.Transform2D;
                if (t2D != null)
                {
                    Debug.WriteLine($"{t2D.Offset.X}:{t2D.Offset.Y}");
                }
    
                Debug.WriteLine("");
            }
        }
    }

    but I can not get Transform2D (is null) for the shape which placed on slide layout. Problem: some shape stores its text in the slide, but x, y in slide layout.

    How can I get a text, x, and y of shape which stores its x, y in slide layout?


    jeudi 26 avril 2018 07:35

Toutes les réponses