-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Placeholder: Support content placeholders #333
Comments
For what it's worth, I got this working in my fork of python-pptx located here adding this code. I'm not familiar enough with python-pptx or the pptx format in general to be able to write the necessary documentation or test cases to validate this. If any one is up for helping, I'd love to be able to integrate this capability into python-pptx. |
@mcdevitts how far did you get with this functionality? |
I implemented it in my fork. It's rather simple and seems to work quite well (for images at least). I haven't submitted a pull request because I don't have the necessary documentation or test cases that @scanny requires. I also don't really know how to get started with that. If anyone wants to help, I'd love to get this into the main branch of python-pptx. For my own usage, I just always monkey patch python-pptx (example). |
The monkey patch works nicely for me, and I would like to see it integrated into the code base, so that I won't have to maintain a duplicate portion of code, |
@bersbersbers I'd love to integrate it. However, the last time I looked into this, I was intimidated by the necessary unittests and requisite knowledge of the underlying powerpoint format. I would need substantial help to do this. |
I probably won't be able to help with that. Maybe, though, it helps to know that I was able to boil it down to this, and it seems to be working in my project:
So at least there is no need to duplicate code, and maybe less need to unit-test things when using a similar approach in the code base directly. |
@mcdevitts are you still interested in doing this? My current workaround is manually instantiating the type of Placeholder I want from the SlidePlaceholder object. I have only it for tables.
|
Ran into this by another utility that uses this library, pptx2md Is there a way to 'hack' the source slide to remove the content placholders? Is it related to the slide master? Error: |
Place holders must be in the slide master. I don't see how you can remove them in python-pptx. I'm guessing you want to know how to remove them from any export you might do. |
While placeholders can live in the slide master, they are predominantly found in a slide-layout. Each slide layout can "inherit" certain placeholders from the slide master (at slide-layout creation time), I think the title and footer placeholders, and perhaps usually a single body placeholder. But in general the diversity of placeholders in slide layouts is much higher. The placeholders in a slide layout are "prototypes" in the sense that they are copied to the slide when a slide is created from a layout. Any change of position made to the placeholder in the slide layout will not cause corresponding placeholders in existing slides to change and vice versa. I do believe certain other characteristics are inherited though, if not explicitly changed on the slide placeholder, font maybe, paragraph properties, etc. but it's been a long time. I expect the design documentation has some useful insight into that. In any case, this means there are three kinds of "deleting a placeholder":
In general, our design assumption was that 2 and 3 would be done by hand using PowerPoint (or whatever, LibreOffice etc.). We justify this by saying that programmatically creating PPTX templates is not a target use-case for Anyway, bottom line is that if you want to delete a placeholder of type 1 then just delete the shape and your done. You have to do that yourself because there is no |
Use case I am looking at is converting slides from PPTX (Best effort) to export formats that could go into more developer friendly / maintainable doco (PPTX --> best effort of making a Markdown, Asciidoc with extracted images) Project that uses the library: Was seeing if there is a way to workaround this error by editing the source PPT to get past it or if this error can be 'ignored' if not material to reading the rest of the slide deck. |
@npiper okay, I looked a little further to the error message I think you're getting. So some part of the
It seems like this is an attempt to identify I haven't traced through your code to see why you're checking for the attribute but you should instead test on Also, this is unrelated to the original post for this issue so in future please start a new one :) |
PowerPoint has a Content placeholder that allows a user to insert pictures, charts, etc. Currently, python-pptx does not seem to recognize these placeholders and just uses the generic SlidePlaceholder. This SlidePlaceholder does not support the insertion of pictures, charts, etc.
A cursory glance and trial looks like simply adding the methods from ChartPlaceholder, PicturePlaceholder, and TablePlaceholder to SlidePlaceholder enables the desired functionality on Content placeholders.
The text was updated successfully, but these errors were encountered: