Comments (4)
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.
RootTemplate.pptx and Template-01.pptx I've tried swapping use loadRoot and load
from pptx-automizer.
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.
@singerla Thanks, this issue was caused by my biased understanding of the template and can be closed now.
from pptx-automizer.
Related Issues (20)
- Bulleted Lists HOT 4
- Support for charts getting data from embedded excel sheets (rather than 'standard' charts) HOT 7
- How to get "custom tag" values for a shape via a relationship? HOT 3
- [Help Needed] Can't copy slideMasters with themeOverride HOT 10
- Can you add video / audio files to powerpoints? HOT 3
- I am having an odd error while essentially following the library HOT 2
- Read files from memory instead of from a directory?
- question: reading/writting ppt with charts HOT 6
- Pres/Slide Dimensions HOT 5
- "replaceText" not working HOT 6
- [Question] Getting element's text. HOT 3
- [Feat?] make slide masters/layouts editable. HOT 2
- Modify slide backgrounds HOT 5
- Swap element in slide master? HOT 5
- Reorder and delete slide masters? HOT 2
- Not all text replaced: modify.replaceText HOT 2
- Output yields a file as large as my template, however, it should be removing slides, and just a resave yields a fraction of the size. HOT 7
- Copy slide master related background images on autoImportSlideMaster doesn't work HOT 4
- Updating Chart Title and formatCode HOT 4
- Set formatCode for chart datalabels HOT 3
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 pptx-automizer.