scanny / python-pptx

Create Open XML PowerPoint documents in Python
MIT License
2.44k stars 528 forks source link

Embedding HTML objects #739

Closed elgisnail closed 3 years ago

elgisnail commented 3 years ago

Hello! This is a super awesome library with lots of cool features.

I have a program that generates a ton of plotly plots and I'd like to put them into a powerpoint to be able to show off the plots. Since these are interactive plots, they are .html files. I've figured out how to embed Word docs and Excel files, but I am struggling to imbed an HTML object in a similar fashion. Is there a specific prog_id I can use for this (I've tried so many and they all cause problems), or a different function I should use besides add_ole_object?

Any help appreciated, thanks!

scanny commented 3 years ago

In general a reliable approach is to start by doing such an embedding by hand, using the PowerPoint application. If you are unable to accomplish the desired embedding by hand, it's very unlikely that python-pptx will be able to do it. If you can accomplish it, then you can just inspect the XML that is generated to identify the specific parameters you need to feed into python-pptx for the embedding.

In general, my sense has been that Excel works, Word kind of works, and anything else is very iffy. There is some dependence on applications installed on the machine used to open the resulting PPTX and the OS of that machine definitely matters, which more OLE objects working on Windows than on Mac and I'm not sure whether any at all work on Linux. This makes some sense because OLE is very much a Windows concept, or at least that was the context in which it was designed.