Shapes, Images, and Geometry
Shapes live under slide.shapes, slide.layout.shapes, slide.slideMaster.shapes, or group shape collections.
Add shapes
const slide = context.presentation.slides.getItemAt(0);
slide.shapes.addTextBox("Status", {
left: 60,
top: 60,
width: 260,
height: 48
});
slide.shapes.addGeometricShape(PowerPoint.GeometricShapeType.roundRectangle, {
left: 60,
top: 130,
width: 260,
height: 90
});
Common geometry APIs cover text boxes, preset geometric shapes, lines, pictures, tables, charts, and groups.
Pictures
Use --input-file to pass local images as data URIs:
witan pptx exec deck.pptx --save --input-file logo=@./logo.png --stdin <<'JS'
return await PowerPoint.run(async context => {
const slide = context.presentation.slides.getItemAt(0);
slide.shapes.addPicture(input.logo, {
left: 54,
top: 42,
width: 120,
height: 60
});
await context.sync();
return true;
});
JS
Witan accepts PNG, JPEG, and SVG image data where the Office.js surface accepts pictures or image fills.
Formatting
Shapes expose fill, line, rotation, visibility, alt text, decorative flags, and z-order:
const shape = slide.shapes.getItem("Status Box");
shape.fill.setSolidColor("#E8F2FF");
shape.lineFormat.color = "#1F5DA8";
shape.lineFormat.weight = 1.5;
shape.rotation = 0;
shape.setZOrder(PowerPoint.ShapeZOrder.bringToFront);
Groups
Use addGroup or ShapeScopedCollection.group() to group shapes. Group transforms are reflected in rendering and can be undone with group.ungroup().
SVG conversion
Witan can expose unknown SVG graphic frames through shape.getGraphicOrNullObject() and convert supported SVG graphic content into editable shapes with graphic.convertToShape(). Unsupported SVG features report Office.js-style errors.