向演示文稿添加形状

VSTO

下面是添加线形状的代码片段:


   Slide slide = Application.ActivePresentation.Slides[1];

  slide.Shapes.AddLine(10, 10, 100, 10);

Aspose.Slides

要向演示文稿的所选幻灯片添加一条简单的直线,请遵循以下步骤:

  • 创建 Presentation 类的实例
  • 使用索引获取幻灯片的引用
  • 使用 Shapes 对象提供的 AddAutoShape 方法添加线类型的 AutoShape
  • 将修改后的演示文稿写入 PPTX 文件

在下面的示例中,我们向演示文稿的第一张幻灯片添加了一条线。


   //Instantiate Prseetation class that represents the PPTX

  Presentation pres = new Presentation();

  //Get the first slide

  ISlide slide = pres.Slides[0];

  //Add an autoshape of type line

  slide.Shapes.AddAutoShape(ShapeType.Line, 50, 150, 300, 0);

Download Running Code

Download Sample Code