简体   繁体   English

DrawingML将绘图插入/粘贴到Word文档中

[英]DrawingML insert/paste drawing into a Word document

I am a complete beginner with DrawingML. 我是DrawingML的完整入门者。 I am trying to figure out if I can define a shape using the language, save it in some format and import it directly into a drawing canvas inside a Word document. 我试图弄清楚是否可以使用该语言定义形状,将其保存为某种格式并将其直接导入到Word文档中的绘图画布中。

The motivation behind this is to enable users save an on-line generated graph as a file and import it into a canvas inside a Word document. 其背后的动机是使用户能够将在线生成的图形另存为文件,并将其导入到Word文档内的画布中。 The graph nodes should be connected so that when a node is dragged it will also mode the connector. 图形节点应已连接,以便在拖动节点时也可对连接器进行模式设置。 My understanding is that it is possible to create such drawings using DrawingML but am not sure how to import such drawing into a document. 我的理解是可以使用DrawingML创建此类图形,但不确定如何将此类图形导入文档。

You can create a Flat OPC XML file containing your DrawingML. 您可以创建一个包含DrawingML的Flat OPC XML文件。

Then you add it to your docx open in Word. 然后,将其添加到在Word中打开的docx中。 You can do that using VBA (a macro), or VSTO (a Word Add-In). 您可以使用VBA(宏)或VSTO(Word加载项)来实现。

For more on Flat OPC XML, see http://blogs.msdn.com/b/ericwhite/archive/2008/09/29/the-flat-opc-format.aspx 有关Flat OPC XML的更多信息,请参见http://blogs.msdn.com/b/ericwhite/archive/2008/09/29/the-flat-opc-format.aspx

You can add the Flat OPC XML using Range.InsertXml. 您可以使用Range.InsertXml添加Flat OPC XML。 See also Can I use VSTO instead of Open XML to manipulate altChunk features? 另请参见我可以使用VSTO代替Open XML来操作altChunk功能吗?

VSTO is a .NET thing. VSTO是.NET。 Generally you'd code in C# or VB.NET. 通常,您将使用C#或VB.NET进行编码。 You can use Microsoft's Open XML SDK as necessary. 您可以根据需要使用Microsoft的Open XML SDK。 So Java doesn't usually have a role. 因此,Java通常不起作用。 Having said that, I do know of companies that are committed to Java server side and using docx4j there, and want to use the same technology client side, and so use docx4j IKVM'd as a DLL. 话虽如此,我确实知道那些致力于Java服务器端并在其中使用docx4j的公司,并且希望使用相同的技术客户端,因此将docx4j IKVM用作DLL。 In this context, that could be how you create your DrawingML (ie using JAXB), then produce the Flat OPC XML. 在这种情况下,这可能就是您创建DrawingML(即使用JAXB)然后生成Flat OPC XML的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM