Skip to content
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

Merging Specific slides from pre-existing powerpoints #134

Open
Jcoumarb opened this issue Jul 8, 2024 · 1 comment
Open

Merging Specific slides from pre-existing powerpoints #134

Jcoumarb opened this issue Jul 8, 2024 · 1 comment

Comments

@Jcoumarb
Copy link

Jcoumarb commented Jul 8, 2024

I saw that it has been answered as to whether or not it is possible to achieve this with node-pptx but I have not seen any documentation with an example. I have attached my attempt at this solution and I get errors:

const pptx2 = require('nodejs-pptx');

async function merge () {
    let dynamic = new pptx2.Composer();
    await dynamic.load(`./ui/resources/generated.pptx`);

    let static = new pptx2.Composer();
    await static.load('./ui/resources/generated.pptx');

    let output = new pptx2.Composer();

    await output.compose(async pres => {
        pres.addSlide(dynamic.getSlide('slide1')); 
    });

    await pptx.save(`./ui/resources/completed.pptx`);
}

merge();

this is the error that I receive attached below. lines 294 and 295 of index.js correspond to 'await output.compose' and the line that follows:

C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\nodejs-pptx\lib\presentation.js:114
        await config(this.powerPointFactory.addSlide(layoutName || this.defaultSlideLayout));
              ^

TypeError: config is not a function
    at Presentation.addSlide (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\nodejs-pptx\lib\presentation.js:114:15)
    at C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\ui\index.js:295:14
    at Composer.compose (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\node_modules\nodejs-pptx\lib\composer.js:20:15)
    at merge (C:\Users\coumarbj\work\pptxGen\job-soms-dashboard-presentation\ui\index.js:294:18)

Node.js v22.2.0

I would also be satisfied if I could not select specific slides and I could load the entirety of the two source files and parse through with delete and re-order

@Donny-H
Copy link

Donny-H commented Oct 31, 2024

Did you end up with a solution? This is my exact use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants