Coder Social home page Coder Social logo

Comments (4)

guotingchao avatar guotingchao commented on August 15, 2024
const { join } = require("path");
const { Automizer, ModifyTextHelper } = require("pptx-automizer");

const generatorPowerPoint = async () => {
  const templatePath = join(process.cwd(), "/template");
  const outputPath = join(process.cwd(), "/output");
  const automizer = new Automizer({
    templateDir: templatePath,
    outputDir: outputPath,
    autoImportSlideMasters: true,
    removeExistingSlides: true,
  });
  automizer
    .loadRoot("Template-01.pptx")
    .load("Template-01.pptx", "master")
    .load("RootTemplate.pptx", "template");

  automizer.addSlide("template", 1, (slide) => slide.useSlideLayout());
  automizer.addMaster("master", 1);

  automizer.write(`test.pptx`);
};

from pptx-automizer.

guotingchao avatar guotingchao commented on August 15, 2024

RootTemplate.pptx and Template-01.pptx I've tried swapping use loadRoot and load

from pptx-automizer.

singerla avatar singerla commented on August 15, 2024

Hi! I am trying to reproduce this with templates from __tests__/pptx-templates directory of this repository. I was using a copy of SlidesWithAdditionalMaster.pptx as Template-01.pptx. It works as expected in all combinations...

If set to true, autoImportSlideMasters will make addMaster and useSlideLayout obsolete:

  // slide.useSlideLayout() is already executed by functionality behind autoImportSlideMasters
  automizer.addSlide("template", 1, (slide) => slide.useSlideLayout());

  // this will import first master & associated layouts from "Template-01.pptx"
  // again, so this makes a copy of a slideMaster within the root template.
  automizer.addMaster("master", 1);

Please notice: You won't need any slideMaster magic in case that all of your templates are using the same set of masters. If those are equal, you are not going to notice any difference in slide mode anyway :)

Please open slide master view in PowerPoint (as described e.g. here) and check if there are more slide masters and slide layouts as in original root template.

You could try this:

  automizer
    .loadRoot('RootTemplate.pptx')
    .load('RootTemplate.pptx', 'template')
    .load('SlidesWithAdditionalMaster.pptx', 'master');

  // will duplicate slideMaster #1 of 'RootTemplate.pptx'
  automizer.addSlide('template', 1);
  // will add slideMaster #2 of 'SlidesWithAdditionalMaster.pptx':
  automizer.addSlide('master', 1);

  await automizer.write(`test.pptx`);

This will output a three-master-presentation from our tests-files.

Happy mastering! :)

from pptx-automizer.

guotingchao avatar guotingchao commented on August 15, 2024

@singerla Thanks, this issue was caused by my biased understanding of the template and can be closed now.

from pptx-automizer.

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.