PptxGenJS is a comprehensive JavaScript library designed for programmatically generating professional PowerPoint presentations (PPTX files) directly from various JavaScript environments, including Node.js, React, Angular, Vite, Electron, and modern web browsers. The library is currently at version 4.0.1 and maintains a fairly active release cadence, with minor and patch versions released every few weeks to months. It differentiates itself by allowing the creation of complex slides with text, tables, shapes, images, and charts without requiring a Microsoft PowerPoint installation or license. Key features include defining custom Slide Masters, supporting SVGs, animated GIFs, YouTube embeds, RTL text, and Asian fonts. It also offers a unique HTML to PowerPoint conversion for tables and provides full TypeScript definitions, ensuring a robust development experience. Presentations created are standards-compliant Open Office XML (OOXML) files compatible with major office suites like Microsoft PowerPoint, Apple Keynote, and LibreOffice Impress.
npm install pptxgenjsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to instantiate PptxGenJS, define a slide master for branding, add a new slide using that master, then insert text and a basic table. Finally, it shows how to trigger a file download in a browser or logs a message for Node.js environments.
For projects requiring IE11 compatibility, consider using PptxGenJS v3.5.0 or earlier, or thoroughly test with polyfills (e.g., core-js) to ensure desired functionality.
Replace direct `fill` and `border` properties in chart options with the `plotArea` object, which accepts `fill` and `border` as its own properties. Example: `chart: { plotArea: { fill: 'FFFFFF', border: { pt: 1, color: '000000' } } }`.Upgrade to PptxGenJS version 4.0.1 or newer. This issue has been explicitly fixed in version 4.0.1.
Upgrade to PptxGenJS version 4.0.0 or newer, where this issue was addressed. If upgrading is not an option, ensure that any configuration objects passed to `defineSlideMaster()` are unique or are deep-cloned before reuse to prevent shared state issues.
First, ensure you are on the latest stable version of PptxGenJS (currently 4.0.1 or higher). Review your code for common pitfalls like incorrect data types for properties (e.g., `border` expecting a number `pt` property). If the issue persists, simplify the slide content to isolate the problematic element.
For Node.js, ensure your `package.json` specifies `"type": "module"` for ESM, or use `const PptxGenJS = require('pptxgenjs');` for CommonJS. For browser environments, if not using a bundler, load `pptxgen.bundle.js` via a `<script>` tag, which exposes `PptxGenJS` globally.Ensure you are awaiting the `writeFile` call in an `async` function (`await pptx.writeFile({ fileName: 'MyPresentation.pptx' });`). Additionally, confirm you are in a Node.js context if expecting server-side file saving, and provide a valid file path. For browser, ensure it's called from a user interaction context to trigger download.