MartinPacker / md2pptx

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

How to customize the background image of each ppt page? #147

Closed Bruce337f closed 8 months ago

Bruce337f commented 8 months ago

And how to achieve the coexistence of images and text, such as text contain images?

MartinPacker commented 8 months ago

While you can't wrap text round images in md2pptx they can certainly co-exist, at least 2 ways:

  1. The slide can have a title - which would be text.

  2. You can have text blocks next to or above / below graphics. Look at contentSplit and contentSplitDirection metadata items (which can be dynamic). If the manual doesn't describe them well enough please open another issue.

There are some limitations with this - which it might be possible to relax. But definitely you can mix text and graphics (and tables) up to a point.

I'm using both the methods above in my work-related presentations (of which there are many).

MartinPacker commented 8 months ago

So I'll research if backgrounds - in Powerpoint - can be one per page. If so I'll probably add a metadata item (and also make a dynamic counterpart).

If Powerpoint doesn't allow this then it'll have to be an image injected underneath all the other shapes. I would also preserve the aspect ratio of the image - which might make it not fill the space. (At this point all md2pptx image handling aims to preserve aspect ratios.)

MartinPacker commented 8 months ago

It looks like a different background for each slide is doable in Powerpoint itself - as I just did it. 😀 I saved the .pptx and will examine its XML later. I don't know, though, if it will be feasible to do it in Python.

(I can't rush this - over the next few days.)

MartinPacker commented 8 months ago

Looks like python-pptx can set a slide background colour / pattern - but not a background image.

So the solution will have to be adding a picture at the back.

Candidate syntax for static metadata:

backgroundImage: myfile.png

Candidate syntax for static metadata:

<!--md2pptx: backgroundImage: thisSlidesBackground.png -->

and there would be special values, as so often is the case of pres, default, prev.

MartinPacker commented 8 months ago

On the question of contentSplit and contentSplitDirection I've added Issue 149 to hopefully improve that aspect of the documentation with some example graphics.

MartinPacker commented 8 months ago

branch backgroundImage created.

Bruce337f commented 8 months ago

Thanks for your reply and update!

Here, the creation of pptx through code customization has been further deepened. Now the appearance of ppt can be more beautiful.

This is a good project! !

MartinPacker commented 8 months ago

I've reopened as I haven't actually written the code yet. This is an enhancement that - if successful - people will like.

MartinPacker commented 8 months ago

Delivered in v4.2.

MartinPacker commented 8 months ago

I figured out the XML to create real PowerPoint slide background images so I released v4.2.1 with this in.