PowerPoint.ShapeGetImageFormatType enum
Represents the format of an image.
Remarks
[ API set: PowerPointApi 1.10 ]
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/powerpoint/shapes/get-shape-as-image.yaml
// Gets an image of the first selected shape with all options specified:
// a fixed width, height, and explicit PNG format.
await PowerPoint.run(async (context) => {
const shapes: PowerPoint.ShapeScopedCollection = context.presentation.getSelectedShapes();
const shapeCount = shapes.getCount();
await context.sync();
if (shapeCount.value === 0) {
console.warn("No shapes are selected. Please select a shape and try again.");
return;
}
const shape: PowerPoint.Shape = shapes.getItemAt(0);
const options: PowerPoint.ShapeGetImageOptions = {
format: PowerPoint.ShapeGetImageFormatType.png,
width: 300,
height: 150,
// Both width and height are specified, so the image is scaled to fit within
// 300x150 pixels. The image may not fill both dimensions if the aspect ratios differ.
};
const imageResult: OfficeExtension.ClientResult<string> = shape.getImageAsBase64(options);
await context.sync();
displayImage(imageResult.value, "PNG, 300x150px");
});
Fields
| png = "Png" | The picture is in PNG format. |