Skip to content

Repository files navigation

pptx-automizer: A Powerful .pptx Modifier for Node.js

npm version CI License: MIT

pptx-automizer is a Node.js-based PowerPoint (.pptx) generator that automates the manipulation of existing .pptx files. With pptx-automizer, you can import your library of .pptx templates, merge templates, and customize slide content. pptx-automizer will edit and merge existing pptx files. 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 require to create elements from scratch, pptx-automizer wraps around PptxGenJS. Use the powerful syntax of 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.

Documentation

The full documentation lives at singerla.github.io/pptx-automizer — guides for every feature area plus the generated API reference:

AI assistants consuming this library should read AI-INSTRUCTOR.md, a condensed, self-contained guide that is also shipped in the npm package.

Installation

$ yarn add pptx-automizer

or

$ npm install pptx-automizer

To explore the library from a clone instead, see Getting started.

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.

Take a look into the __tests__-directory to see a lot of examples for several use cases. You will also find the example .pptx-files there.

Ecosystem and Support

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. Whether you're a seasoned pro or just starting out, your contributions are invaluable. Get started

Special Thanks

This project was inspired by:

About

A template based pptx generator for Node.js

Topics

Resources

Stars

234 stars

Watchers

6 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages