Coder Social home page Coder Social logo

Comments (8)

gregdolley avatar gregdolley commented on May 24, 2024 1

@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.

gregdolley avatar gregdolley commented on May 24, 2024 1

@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.

heavysixer avatar heavysixer commented on May 24, 2024

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.

harishankar0301 avatar harishankar0301 commented on May 24, 2024

Is what I have done the proper way to remove slide and save the modified presentation.

from node-pptx.

harishankar0301 avatar harishankar0301 commented on May 24, 2024

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.

harishankar0301 avatar harishankar0301 commented on May 24, 2024

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.

heavysixer avatar heavysixer commented on May 24, 2024

@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.

heavysixer avatar heavysixer commented on May 24, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.