Create PowerPoint Presentation in JavaScript

Create PowerPoint Presentation

To add a simple plain line to a selected slide of the presentation, please follow the steps below:

  1. Create an instance of Presentation class.
  2. Obtain the reference of a slide by using its Index.
  3. Add an AutoShape of Line type using addAutoShape method exposed by Shapes object.
  4. Write the modified presentation as a PPTX file.

In the example given below, we have added a line to the first slide of the presentation.

// Instantiate a Presentation object that represents a presentation file
var pres = new aspose.slides.Presentation();
try {
    // Get the first slide
    var slide = pres.getSlides().get_Item(0);
    // Add an autoshape of type line
    slide.getShapes().addAutoShape(aspose.slides.ShapeType.Line, 50, 150, 300, 0);
    pres.save("NewPresentation_out.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
    if (pres != null) {
        pres.dispose();
    }
}