none
Help with PresetGeometry output to docx RRS feed

  • Question

  • How can I create objects of DocumentFormat.OpenXml.Drawing.PresetGeometry? in a Microsoft Word docx file? These are shapes such as lines, arrows, and polygons.

    What I need

    It would be very helpful to have an example similar to the ones provided for Images and Tables

    What I tried

    1. Searching for docx and PresetGeometry didn't find any helpful links
    2. I used the "Open XML SDK 2.5 Productivity Tool for Microsoft Office" to compare an empty docx to one with an arrow. The code generated by the View Part Code button for /word/document.xml compiles but Word reports a schema error when I run that code and open the generated file.
    3. There've been no replies to my similar post on github's OfficeDev/Open-XML-SDK.

    Howard Rubin



    Monday, July 25, 2016 1:56 PM

Answers

  • Hi Howard, I'm glad that you found a solution. I also found this article on how to insert an image into a document that you might find useful.

     

    How to: Insert a picture into a word processing document (Open XML SDK)

    https://msdn.microsoft.com/EN-US/library/office/bb497430.aspx

     

    This is from the SDK 2.5 documentation which I think has a lot more information than the SDK 2.0 documentation that you referenced previously. There's a significant number of samples provided. Please let me know if you think any other specific examples are needed and I'll forward that to the appropriate contact.

     

    Thank you.


    Josh Curry (jcurry) | Escalation Engineer | Open Specifications Support Team

    Wednesday, July 27, 2016 6:32 PM
    Moderator

All replies

  • Hi Howard:

    I have alerted the open specifications team regarding your inquiry. A member of the team will be in touch soon.


    Regards, Obaid Farooqi

    Monday, July 25, 2016 4:53 PM
    Owner
  • Hi Howard, I am the engineer who will be working with you on this issue. First, I want to share some resources with you that may help. If you still have questions after looking at these please let me know.

     

    The PresetShapeDefinitions.xml file contains all of the DrawingML for shapes used by the <prstGeom> element. You can obtain that from the ISO/IEC 29500-1:2012 Electronic Inserts located at the following site: http://standards.iso.org/ittf/PubliclyAvailableStandards/index.html

     

    The following article shows you how to use the XML from the PresetShapeDefinitions.xml file to replace a <prstGeom> element with the actual DrawingML code in a <custGeom> element. The example uses PowerPoint, but the process should be identical for Word.

     

    How to use the presetShapeDefinitions.xml file and fun with DrawingML

    http://blogs.msdn.com/b/openspecification/archive/2011/11/14/how-to-use-the-presetshapedefinitions-xml-file-and-fun-with-drawingml.aspx


    Josh Curry (jcurry) | Escalation Engineer | Open Specifications Support Team

    Monday, July 25, 2016 8:03 PM
    Moderator
  • Hi Josh,

    Thanks for the reply. The ISO/IEC 29500-1:2012 Electronic Inserts link you provided lists the various preset shapes that are available, which should be useful later but not quite yet. And the How to use the presetShapeDefinitions.xml file and fun with DrawingML link shows how to modify an existing preset shape.

    What I need is information on how to create a preset shape from scratch using the Open-XML-SDK. Neither link is helpful with that.

    That is, I need to add a preset shape to the approximately 20 line Hello World docx example.

    Howard Rubin

    Monday, July 25, 2016 8:32 PM
  • Hi Howard, thanks for the clarification. I'm looking into this and will let you know when I have more information.

    Josh Curry (jcurry) | Escalation Engineer | Open Specifications Support Team

    Tuesday, July 26, 2016 5:48 PM
    Moderator
  • I tried the "Open XML SDK 2.5 Productivity Tool for Microsoft Office" again to compare an empty docx to one with an arrow, and it works now. There's lots of C# code in there that might not be needed so a minimum example would still be helpful, but I'm able to move forward now.

    Howard Rubin

    Tuesday, July 26, 2016 6:46 PM
  • Hi Howard, I'm glad that you found a solution. I also found this article on how to insert an image into a document that you might find useful.

     

    How to: Insert a picture into a word processing document (Open XML SDK)

    https://msdn.microsoft.com/EN-US/library/office/bb497430.aspx

     

    This is from the SDK 2.5 documentation which I think has a lot more information than the SDK 2.0 documentation that you referenced previously. There's a significant number of samples provided. Please let me know if you think any other specific examples are needed and I'll forward that to the appropriate contact.

     

    Thank you.


    Josh Curry (jcurry) | Escalation Engineer | Open Specifications Support Team

    Wednesday, July 27, 2016 6:32 PM
    Moderator