singerla / pptx-automizer

A template based pptx generator for Node.js
MIT License
63 stars 11 forks source link

Pres/Slide Dimensions #81

Closed MP70 closed 8 months ago

MP70 commented 9 months ago

Hi,

Hope, you're well. I was thinking of adding a method to get dimensions of a slide, right now I've popped it on the slide.getDimensions() but maybe this can go inside getInfo().slidenumber > .info eventually?

Would you like it in your lib?

If yes: Does this feel like the right order of precedence for what dimensions override each-other? My memory says yes but I'd need to read the spec to confirm. What do you want to see in a PR? Is this fine (with tidy up obviously, and initing the source archive in the function) more or less as is or?

https://github.com/MP70/pptx-automizer/commit/d0e028c3d486376885e399b648a4c0ca6aea64a8

singerla commented 9 months ago

Hi Matt,

that looks great, thank you very much! I was having issues with slide dimensions too in the past, so this is very welcome. I was playing around with your code and moved it to src/helper/xml-slide-helper.ts. It can reuse some things from there (e.g. slideXml) and some code could be reused later, too (e.g. get related master and layout).

Have a great week! :)

Thomas

singerla commented 9 months ago

And feel free to add modifications directly to this repository in the future :smiley: I have created a new branch for this feature.

MP70 commented 9 months ago

Hi Thomas,

That is the obvious home for it, thanks! Sorry, I was just focusing on getting it working first :)

I'll get this branch into a more mergable state when I have a moment, thanks for access.

It's a super useful feature in my eyes as it means we can layout things on the slide, (e.g center an element) as well as enabling some hygiene features such as detecting elements that are outside of the canvas, glad you're happy to include it.

MP70 commented 8 months ago

Hi Thomas,

I'm just refreshing myself on this one. I think that in practice 99.9% of the time the only thing that practically matters is the dimensions at the template level, rather than side level. Although the pptx spec supports different slide sizes in the same file in practice the major presentation packages, generally, do not, including powerpoint.

So, I'm a bit torn on if we should just put a simpler version in at the template level e.g

 let template = pres.getTemplate('output')
 template.getDimensions()

and cut out the complexity, or leave it at the slide level (or do both).

Whats your view?

singerla commented 8 months ago

Hi Matt,

I was already wondering how to set different dimensions, and I completely agree that we can cut out complexity here. See also MS docs.

Thanks a lot again for your contribution! :smiley: