PowerPoint.ShapeCollection.addFromBase64( base64File, options )
This API closes a large gap in the surface area of creating content in PowerPoint.
There is already support for inserting new slides via the PowerPoint.insertSlidesFromBase64( base64File, options ) function. And, there's support for adding various geometric shapes and images via the PowerPoint.ShapeCollection.addGeometric/addLine/addTextBox methods. (Annoyingly, images need to be added with the generic setDataAsync method.)
The new API would work similar to the insertSlidesFromBase64, accepting a list of shapeId/drawingElementCreationId of the shapes to insert from the base64 encoded slide.xml, or inserting all of the shapes on that slide. Additional options like specifying where in the z-order of the existing shape collection to insert the new shapes would be useful, too. Add-in developers could get the relevant slide.xml from a pre-generated presentation and extracting it. Or, if simpler, a complete PPTX file that contains only a single slide could be base64 encoded as provided by the new PowerPoint.Slide.exportAsBase64 method.
Overall complexity of adding this new feature is fairly low. Use a parallel implementation structure as the insertSlidesFromBase64, but adding one extra depth traversal into the shape collection and then adding shapes to the current slide rather than slides to the current presentation.
3 Comments
- FrancoisBardBrass Contributor
This would be super useful. At the moment it's not possible to build library of shapes as a JS addin.
- ValTCopper Contributor
+1
- Tjerkdb345Copper Contributor
Would be great! Alternatively the toJSON and the implementation of a set method (as is present in some excel functions) could also work