Skip to main content

pptx-automizer

pptx-automizer is a Node.js-based PowerPoint (.pptx) generator that automates the manipulation of existing .pptx files. Import your library of .pptx templates, merge templates, and customize slide content. You can style template slides within PowerPoint, and these templates will be seamlessly integrated into the output presentation. Most of the content can be modified by using callbacks with xmldom.

If you need to create elements from scratch, pptx-automizer wraps around PptxGenJS to add dynamic content to your existing .pptx template files.

pptx-automizer is particularly well-suited for users who aim to manage their own library of .pptx template files, making it an ideal choice for those who work with intricate, well-designed customized layouts. With this tool, any existing slide or even a single element can serve as a data-driven template for generating output .pptx files.

Quick example

import Automizer, { modify } from 'pptx-automizer';

const automizer = new Automizer({
// where your template pptx files are coming from:
templateDir: 'my/pptx/templates',
// where to write the final pptx output files:
outputDir: 'my/pptx/output',
// truncate the root presentation and start with zero slides:
removeExistingSlides: true,
});

const pres = automizer
.loadRoot('RootTemplate.pptx')
.load('SlideWithGraph.pptx', 'graph')
.load('SlideWithShapes.pptx', 'shapes');

pres
.addSlide('graph', 1)
.addSlide('shapes', 1, (slide) => {
slide.modifyElement('Drum', [modify.setText('Hello world!')]);
});

// Nothing has happened yet: all calls above only queue work.
// write() executes the whole queue and produces the output file.
const summary = await pres.write('myPresentation.pptx');
console.log(summary);

The single most important concept: calls like addSlide() and modifyElement() only queue work — including every modification callback you pass. Nothing is applied until await pres.write(...) (or .stream() / .getJSZip()) executes the whole queue in order. Read more in Concepts.

Where to go next

Ecosystem

This project is accompanied by automizer-data. You can use automizer-data to import, browse and transform .xlsx- or .sav-data into perfectly fitting graph or table data.

Thanks to all contributors! You are always welcome to share code, tipps and ideas. We appreciate all levels of expertise and encourage everyone to get involved. Get started