eozturk
Oct 26, 2023Brass Contributor
Status:
New
Support for getting Powerpoint slide dimensions dynamically
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 window.PowerPoint.run(async (powerPointContext) => powerPointContext)).presentation.width;
(await window.PowerPoint.run(async (powerPointContext) => powerPointContext)).presentation.height;
or,
(await window.PowerPoint.run(async (powerPointContext) => powerPointContext)).presentation.slides[0].width;
(await window.PowerPoint.run(async (powerPointContext) => powerPointContext)).presentation.slides[0].height;
No CommentsBe the first to comment