Rya*_*ott 5 powerpoint openxml openxml-sdk
我正在与OpenXmlSDK一起玩,看看它是否可以满足我们Powerpoint的需求。所需的一件事是在Powerpoint中定位形状的能力。我一直在寻找一种获取Shape位置的方法,但只遇到了MSDN“操作方法” http://msdn.microsoft.com/zh-cn/library/cc850828.aspx和一个位置类(但无法从Shape中获取它)http://msdn.microsoft.com/zh-cn/library/office/documentformat.openxml.wordprocessing.position%28v=office.14%29.aspx。
我该怎么做:
PresentationDocument presentationDocument = PresentationDocument.Open("C:\\MyDoc.pptx", true);
IdPartPair pp = presentationDocument.PresentationPart.SlideParts.First().Parts.FirstOrDefault();
var shape = pp.OpenXmlPart;
// How do I get the position and dimensions?
Run Code Online (Sandbox Code Playgroud)
形状尺寸有 2 个变量: - 偏移量给出形状顶角的位置 - 范围给出形状的大小
shape.ShapeProperties.Transform2D.Offset.X //gives the x position of top left corner
shape.ShapeProperties.Transform2D.Offset.Y //gives the y position of top left corner
shape.ShapeProperties.Transform2D.Extents.X //gives the x size of the shape : the width
shape.ShapeProperties.Transform2D.Extents.Y //gives the y size of the shape : the height
Run Code Online (Sandbox Code Playgroud)
浏览相关幻灯片的 XML 并查找 xfrm 元素,该元素应包含 off(偏移量)和 ext(范围)子元素。测量结果以动车组为单位(参见 Wouter van Vugt 文档的最后一页)。
| 归档时间: |
|
| 查看次数: |
2603 次 |
| 最近记录: |