How to get list of shapes in SdtBlock element using Open XML SDK?

后端 未结 1 713
心在旅途
心在旅途 2021-01-22 20:36

How can I get the list of shapes (textboxs) in an SdtBlock element using Open XML SDK?

Regards.

相关标签:
1条回答
  • 2021-01-22 21:05

    In order to grab all the shapes in a WordProcessingDocument you can use linq to traverse all the descendants of the body:

    using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(stream, true))
    {
        IEnumerable<DocumentFormat.OpenXml.Vml.Shape> shapes = wordDoc.MainDocumentPart.Document.Body.Descendants<DocumentFormat.OpenXml.Vml.Shape>();
    }
    
    0 讨论(0)
提交回复
热议问题