How to position text?
rajatkhare619 opened this issue · comments
I'm trying to figure out how to position the text using the x and y values
await pres.getSlide('slide3')
.addText(text => {
text.value('val')
.x(10)
.y(50)
})
Is there a way by which I can know exactly what values to pass for x and y? For example, by opening an existing ppt and getting the position of a similar element and then passing those values in the function.
Or do I have to do this by trial and error?
@rajatkhare619: The x and y coordinates are in pixels. Unfortunately, there's no programmatic way of getting the x/y pixel coords of objects that come from an externally loaded pptx file. You can however calculate it manually - when viewing the properties of any widget in PowerPoint, take the left/top position values in inches, and simply multiply by 72 to get pixels. For example, a widget at:
Left: 1.5"
Top: 2"
Will be the following in pixels:
X = 1.5 * 72 = 108px
Y = 2 * 72 = 144px
Hope this helps!
Thanks @gregdolley!, I'll try that.