powerpoint - 如何在Powerpoint中获取形状的位置和尺寸?

标签 powerpoint openxml openxml-sdk

我正在尝试使用 OpenXmlSDK,看看它是否是满足我们 Powerpoint 需求的可行解决方案。需要做的一件事是能够在 Powerpoint 中定位形状。我一直在寻找一种获取形状位置的方法,但只遇到了 MSDN“操作方法”http://msdn.microsoft.com/en-us/library/cc850828.aspx和 Position 类(但无法从 Shape 中获取它)http://msdn.microsoft.com/en-us/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?

最佳答案

您有 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

关于powerpoint - 如何在Powerpoint中获取形状的位置和尺寸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13631381/

相关文章:

c# - 使用 activex 控件的 PowerPoint 打印

excel - 从 Excel 关闭 PowerPoint 中的显示警报

c# - 使用 DocumentFormat OpenXml 创建 DOCX 时,是否可以找出我们当前在页面上的位置?

c# - 使用 OpenXML SDK 在富文本控件中查找图形部分

c# - 使用 Open XML SDK 将幻灯片从一个演示文稿复制到另一个

vba - 获取 Excel 作为对象附加的 PowerPoint 演示文稿的文件名和路径

c# - 如何使用 OpenXML 查找数据透视表的数据源

c# - 需要有关如何从 .docx/.doc 文件中提取数据然后将数据提取到 SQL Server 中的建议

c# - 收到有关 Excel 文件内容有问题的消息

iphone - 如何在 iPhone 或 iPad 中从 ppt 文件中的幻灯片中获取图像?