Support for getting Powerpoint slide dimensions dynamically

Support for getting Powerpoint slide dimensions dynamically



 Oct 26 2023

Similar to this post, having a support to get Powerpoint slide dimensions dynamically would be very beneficial for us to calculate position and dimension of an image or shape that is going to be imported.


Use case: 

We are currently developing a Powerpoint taskpane add-in, that imports images selected by user. Currently, we use 960x540 px dimensions as default slide width and height as it seems to be dimensions of a default slide for 16:9 aspect ratio, in order to fit the imported image within slide and calculate its position to center it. However, if user changes the slide dimensions manually, this calculation will mean nothing.


In order to support this, we need Powerpoint JS Api to return current slide's width and height dimensions. Something like below;


(await (powerPointContext) => powerPointContext)).presentation.width;

(await (powerPointContext) => powerPointContext)).presentation.height;


(await (powerPointContext) => powerPointContext)).presentation.slides[0].width;

(await (powerPointContext) => powerPointContext)).presentation.slides[0].height;