Comments (8)
@heavysixer @harishankar0301 - the removing slide code looks fine. That is indeed strange behavior. I'll take a look at it today.
As for your other question regarding moving a slide to a different pptx - unfortunately no, that way won't work. The source and destination pptx must be the same.
from node-pptx.
@harishankar0301 @heavysixer Yup, sorry I forgot to update the status on this. It is due to the unused media not getting removed when slides which reference that media are removed. I've confirmed this in my debugging/testing. I'm adding this to our TODO list.
from node-pptx.
Interesting @harishankar0301 you are right i would expect the size of the file to drop. Wonder if we're hanging onto the deleted slides in memory somewhere. @gregdolley what do you think?
from node-pptx.
Is what I have done the proper way to remove slide and save the modified presentation.
from node-pptx.
When I followed the logic I've said before to remove slides, the size of the created presentations doesn't decrease. But the interesting part is when I open the presentation that is created from the program in MS Powerpoint and then do a simple 'Save As' it saves a presentation with reduced size.
The previous logic:
const PPTX = require('node-pptx');
let pptx = new PPTX.Composer();
await pptx.load('./sample.pptx')
await pptx.compose(async pres => {
pres.removeSlide(pres.getSlide('slide1'));
});
await pptx.save('./test.pptx');
FYI after running this code, we have a new presentation test.pptx without slide1 but the size isn't reduced. When I open test.pptx in MS Powerpoint and do a simple Save As within powerpoint, the size got reduced to the correct size expected. Any thoughts on this?
I also tried to somehow make the process as a program , just load it and then save it but that didn't work, still the size didn't reduce. The only way was to manually open it in MS powerpoint and then do a save within powerpoint.
await pptx.load(`./test.pptx`);
await pptx.save(`./test_reduced.pptx`);
Any thoughts on how to achieve this reduction in size within the program itself eliminating the manual process.
Regards,
from node-pptx.
I think its not removing unused media parts when removing slides.
Is there a way to programatically compact pptx files and remove unreferenced media parts. I believe the issue is; the media used by the slide is not getting removed when we do
pres.removeSlide(pres.getSlide('slide1'));
Is there a way to keep only the media need for the slides present.
Thanks in advance.
from node-pptx.
@harishankar0301 thank you for the sleuthing! I think we probably need a better way to prune the meta data when a slide (or other object) is removed from the document graph.
from node-pptx.
@gregdolley would this be as simple as iterating over the elements array with an slide?
I know that we specify bidirectional relationships per the spec but it's unclear in reading if there is a clear parent child relationship in those linkages. It would be bad for example to loop over the relationships array and delete the associated entities because you could delete a slide layout for example.
from node-pptx.
Related Issues (20)
- Extract presenter notes?
- Project status HOT 2
- Is it possible to center an image? HOT 1
- Is it possible to duplicate a slide?
- Is it possible to merge two pptx files? HOT 2
- Is there any way to get Slide from one pptx and add it to the current pptx?
- TypeScript definitions? HOT 4
- Would you accept a PR to allow loading pptx from buffer OR file path? HOT 2
- Is it possible to edit an existing Text Box? HOT 2
- Problems calling the library front next.js HOT 1
- Bug when trying to load existing présentation
- with PPT file it's not working. How can i do that?
- TypeError: zip.files.hasOwnProperty is not a function HOT 4
- multi lines was saved as 1 line HOT 2
- Slide Transition & Advance slide
- Find/Replace text, Get list of slides containing some text
- Make text bold
- Slide number shown by default change styling HOT 1
- npm package not updated? HOT 2
- issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-pptx.