-
Notifications
You must be signed in to change notification settings - Fork 6
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
How to remove slides #10
Comments
Hello, At the moment there are no elegant way to do that. However what I think should work is to proceed like below: <?php
$basePPTX = new PPTX(__DIR__.'/base.pptx');
$emptyPPTX = new PPTX(__DIR__.'/empty.pptx');
$slides = $basePPTX->getSlides();
// Assuming you want to remove the slide N°2
unset($slides[1]);
$emptyPPTX->addSlides($slides);
// Overwrite the source PPTX
$emptyPPTX->saveAs(__DIR__.'/base.pptx'); But if you want, you can try to implement a |
Hello,
thanks for the sample script, where you basically propose to add a subset of the slides from base pptx to the empty pptx.
Would I then not still have at least the first slide of the empty pptx in the result plus the subset that I want to have, as I can not an empty pptx which is really empty and has not slides at all?
Regards. Alex.
On 9. Nov 2020, at 13:40, Thibault <notifications@github.com<mailto:notifications@github.com>> wrote:
Hello,
At the moment there are no elegant way to do that.
However what I think should work is to proceed like below:
<?php
$basePPTX = new PPTX(__DIR__.'/base.pptx');
$emptyPPTX = new PPTX(__DIR__.'/empty.pptx');
$slides = $basePPTX->getSlides();
// Assuming you want to remove the slide N°2
unset($slides[1]);
$emptyPPTX->addSlides($slides);
// Overwrite the source PPTX
$emptyPPTX->saveAs(__DIR__.'/base.pptx');
But if you want, you can try to implement a PPTX::removeSlide(Slide $slide) method and send us a PR :)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#10 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AADWQFFOZ27YRF2LFVGG7CTSO7PNDANCNFSM4TOUPHDQ>.
|
Does "empty.pptx" represent an empty PowerPoint file and how does that look like? |
With Powerpoint you can create empty PPTX which has no slides in it just by removing every slides. I think with a file like that, my example should work (I did not test so let me know if it doesn't). |
The issue is that the addResource() method throws an error, because the p:sldIdLst node does not exist. It also assumes that there are current slides available already to determine the Ids for the new slides. |
This part of the code causes the error. |
I tried to manually add an empty <p:sldIdLst> node to the presentation.xml in the emty.pptx (by unzipping it, adding the node, and zipping again). And changed the code to
which almost works. The resulting document can be opened and looks fine, but still the following warning appears when opening it in PowerPoint: _PowerPoint found a problem with content in Test.pptx. If you trust the source of this presentation, click Repair._ Any idea of what the issue might be? |
PowerPoint is a little capricious when you try to modify these files by hand ... It is also complicated to debug this kind of errors. I don't have a lot of time at the moment to look into the problem but if you find a suitable solution, don't hesitate to share it with us! Otherwise, we'll have to wait until we got time to search for a solution. (Maybe it is easier to implement the deleteSlide instead of trying to load an empty pptx as base). |
Hi @TZK- yes, working with those PowerPoint appears messy. Do you think you could implement that? Regards |
Hi @TZK- , @alexfibr, Did you manage to figure out a solution for this problem? Thanks! |
Hello @wtrv, We haven't solved the requirement with this library; we could not remove or extract individual slides. The commercial phpdocx library (phpdocx.com) includes some .pptx functionality for removing slides. We were able to solve some of our requirements with that. |
No worries, I managed to solve my problem using a custom implementation specific for my needs. Thanks for the reply! |
Hello,
I have the usecase that I want to remove a slide. Would this be possible and how?
The text was updated successfully, but these errors were encountered: