I am working with the Background Styles functionality of PowerPoint where you can set the background of a Master to be based on Light1/Light2/Dark2/Dark1. In the PowerPoint user interface this will automatically flip the text to be opposite of the background. So Light text on Dark background or vice versa.
When I look at the OOXML for a PowerPoint document it is done with this ColorMap class: ColorMap Class (DocumentFormat.OpenXml.Presentation) | Microsoft Learn
Here’s an example of Dark text on Light background:
<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
And here’s an example of how it implements Light text on Dark Background:
<p:clrMap bg1="dk1" tx1="lt1" bg2="dk2" tx2="lt2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
When I change the Background style and run a diff on the OOXML this appears to be the only material change. I’ve been looking through the Aspose.Slides (python.net) classes but haven’t found any ColorMap functionality. Am I missing it?
Thank you for contacting support.
Could you please show in more detail the functionality with examples on screenshots from PowerPoint that you are interested in?
Yes certainly. Attached are screenshots of using the PowerPoint Slide Master UI to switch the Background Style from Light1 to Dark2, along with screenshots of my git repo where the unpacked .pptx file ColorMap OOXML is changed in SlideMaster1.xml and the preview image.
The effect this one ColorMap change has is to change the background color to Dark2 and text color to Light1.
I understand there are probably ways to do workarounds involving setting a Slide Background format and then looping each Portion and setting the font color, but I don’t want that. I want to do this elegantly with the ColorMap the way the PowerPoint UI does in one change.
ppt_ui.png (77.8 KB)
ppt_image.png (86.4 KB)
ppt_ooxml.png (398.5 KB)
Thank you for the details. I am working on the question and will get back to you as soon as possible.
You can change a background style in a PowerPoint presentation like this:
presentation.masters.background.style_index = 3
You can also find out the number of predefined background styles as shown below:
style_count = len(presentation.master_theme.format_scheme.background_fill_styles)
print("The number of background fill styles for the theme is", style_count)
Documents: Presentation Theme