添加形状

形状是 PowerPoint 中的一个基本元素,有助于组织内容、强调重点和增强视觉吸引力。 有效运用形状可以让演讲者组织信息、创建图表并引导观众的注意力。 无论是表示方向的箭头、表示文本框的矩形,还是表示突出显示的圆形,各种形状都能使演示文稿更具吸引力和专业性。

有了 IronPPT,开发人员可以无缝集成和修改形状,从而完全控制 PowerPoint 幻灯片。 这种灵活性使得演示文稿能够生动、精炼,有效地传达思想,并留下持久的影响。

五步代码即可添加形状

  • Shape shape = new Shape();
  • shape.Type = IronPPT.Enums.ShapeType.Triangle
  • shape.Width = 100;
  • shape.OutlineColor = Color.Black
  • shape.Position = (200, 200);

代码解释

To add a new shape to our empty PowerPoint presentation, we start by creating a new Shape object using the constructor. Next, we define the type of shape we want to create by modifying the Type property and assigning it one of the values from the ShapeType enum. For example, to create a triangle, we would set the Type to ShapeType.Triangle. After that, we can set the dimensions of the shape by assigning an integer value to the Width property, which specifies the shape's width. To customize the appearance of the shape, we can adjust the OutlineColor property; 在这个例子中,我们将颜色设置为黑色。 最后,我们通过指定 x 和 y 坐标将形状定位在幻灯片上,在本例中,坐标将设置为 (200, 200)。 这样就能将图形放置在演示文稿中的所需位置。

学习如何使用 IronPPT 管理幻灯片

准备开始了吗?
Nuget 下载 3,739 | 版本: 2025.12 刚刚发布