MartinPacker / md2pptx

Markdown To PowerPoint converter
MIT License
206 stars 31 forks source link

Enhancement: Provide slide safe area for titles and contents with specific margins #153

Open tiktoor opened 8 months ago

tiktoor commented 8 months ago

Martin, thank you for your work, it's really awesome.

testing your script i stumbled upon a few things i would prefer if you would want to consider it.

  1. Specify the title Frame with top, left, right, bottom margins (ideally with the conversion of inch, cm, px and pt proovided by python-pptx) titleMarginTop: 2cm titleMarginLeft: 2in titleMarginRight: 20px titleMarginBottom: 20pt

  2. Specify the content Frame with top, left, right, bottom margins (as above) contentMarginTop: 2cm contentMarginLeft: 2in contentMarginRight: 20px contentMarginBottom: 20pt

  3. ideally Footer left/right as well (NumbersHeight somehow defines the Bottom Margin

  4. this could as well be combined on a slide level slideMarginTop: 2cm slideMarginLeft: 2in slideMarginRight: 20px slideMarginBottom: 20pt

What do you think?

MartinPacker commented 8 months ago

Thanks for your kind words. This comment of mine is not a "no". Indeed dynamic metadata versions of these - as well as the static - might have value.

This would be quite a lot of reworking the layout logic, of course.

I will comment that right now the expectation is you will have a decent template presentation - that sets the bounds of eg the title object. So, could you achieve what you want with a tweaked template presentation?

Again, this is not a "no"; I'm exploring the area.

MartinPacker commented 8 months ago

Also, I think the point about centimetres vs inches is valid.

tiktoor commented 8 months ago

Regarding the template, this was my first try. But perhaps it's just a user error. I was tweaking the original template to use the title elements in the master, but i was irritated that the template design was overwritten by the "adjusting titles" I was able to fix the titles with the metadata, but the content block was "ignored" as well.

This was the reason why i thought, as you do some magic with multiple colums etc. if it would make life easier if i would be able to define a "content area" whare the magic can happen.

And this lead to the same assumption for titles and footnotes.

I hope this clarifies my thoughts. Totally ok if you will not adapt. I was just thinking that this could be helpful for more people than just myself :-)

MartinPacker commented 8 months ago

In principle - having located the content shape (for example) - it's not much code to resize it. The wider issue will be updating the layout model.

I also think we need a syntax for "use the default" but that's not difficult.

This is not one I'm going to rush at, in the meantime. So I'd further encourage you to experiment with your own template file. (There is a section towards the end of the user guide that might help weigh this.)

The "units" question is probably more fiddly. And the reason for inches is that font sizes are relative to that (i.e. points). But cm should - one day - be doable.

tiktoor commented 8 months ago

Thank you, will test the template and i made a fork to experiment with the code. If I fine a short patch, i will push it to you. In the meantime thank you for your fast replies.

regarding units, afaik python-pptx ist using this EMU thing as a base and provides an util to convert everything to it.

https://python-pptx.readthedocs.io/en/latest/user/autoshapes.html

My proposal was to use the same util set to process different inputs

`>>> from pptx.util import Inches, Pt

length = Inches(1) length 914400 length.inches 1.0 length.cm 2.54 length.pt 72.0 length = Pt(72) length 914400`

MartinPacker commented 8 months ago

Thanks. It helps the effort more if you try to use the user guide to tweak your template. If there are shortcomings in the docs we can fix them. By the way mdpre is always run to create the user_guide.md file - so don't try editing it directly.

There is another very active code branch going on right now - so merging your code changes might be difficult.

MartinPacker commented 7 months ago

The other code branch got merged just now. But still it's most helpful to check if the documentation is good enough when it come to creating template presentations.

MartinPacker commented 7 months ago

And yet another branch got merged. (Not going to provide running commentary.)

tiktoor commented 7 months ago

Still trying to figure out what breaks my layout. Will get back to you with a reproducible test setup. Thank you for your efforts!

MartinPacker commented 2 months ago

@tiktoor did you ever figure out what broke your layout?