pptxgenjs vs docx-templates vs officegen
Document and Presentation Generation
pptxgenjsdocx-templatesofficegenSimilar Packages:

Document and Presentation Generation

Document and Presentation Generation libraries in Node.js allow developers to create and manipulate various types of files programmatically. These libraries provide APIs to generate documents (like Word, PDF, or Excel) and presentations (like PowerPoint) dynamically, which is useful for applications that need to automate report generation, create templates, or handle file uploads and downloads. They often support features like styling, embedding images, adding tables, and more, enabling developers to produce professional-quality files directly from their applications. docx-templates focuses on generating Word documents from templates, officegen supports creating multiple Office file types (Word, Excel, PowerPoint), and pptxgenjs specializes in generating PowerPoint presentations with rich features.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
pptxgenjs695,2794,7892.61 MB2659 months agoMIT
docx-templates25,2601,0671.24 MB804 months agoMIT
officegen02,7142.73 MB200-MIT

Feature Comparison: pptxgenjs vs docx-templates vs officegen

Template Support

  • pptxgenjs:

    pptxgenjs does not support templates directly but allows for programmatic creation of slides with rich content. Users can create complex layouts by defining them in code, which offers flexibility but lacks the simplicity of using pre-defined templates.

  • docx-templates:

    docx-templates allows for complex template structures, including tables, images, and conditional content. It supports advanced features like loops and conditional rendering, making it highly flexible for generating dynamic content within Word documents.

  • officegen:

    officegen does not use templates; instead, it generates documents programmatically. This approach provides flexibility but requires more code to create complex layouts, as there is no built-in support for pre-defined structures.

File Type Support

  • pptxgenjs:

    pptxgenjs focuses exclusively on generating PPTX files (PowerPoint presentations). It is specialized for presentation creation, offering advanced features for slide design and animation.

  • docx-templates:

    docx-templates specializes in generating DOCX files (Word documents). It does not support other file types, making it a focused solution for Word document generation.

  • officegen:

    officegen supports multiple file types, including DOCX (Word), XLSX (Excel), and PPTX (PowerPoint). This versatility makes it a good choice for applications that need to generate different types of Office documents.

Ease of Use

  • pptxgenjs:

    pptxgenjs provides an intuitive API for creating presentations, especially for developers who are comfortable with programmatic design. Its documentation and examples make it easy to get started.

  • docx-templates:

    docx-templates is user-friendly for those familiar with template engines. It requires creating a Word document template with placeholders, which is straightforward for generating dynamic content.

  • officegen:

    officegen has a simple API for creating documents programmatically, but it may require more effort to achieve complex layouts since it does not use templates.

Customization and Styling

  • pptxgenjs:

    pptxgenjs offers rich customization options for PowerPoint presentations, including detailed control over slide layouts, animations, and transitions. It supports advanced features like embedding videos, setting slide backgrounds, and more, making it highly flexible for creative presentations.

  • docx-templates:

    docx-templates allows for extensive styling and customization of Word documents, including fonts, colors, and layouts. It supports inline styling and CSS-like customization, making it versatile for professional document design.

  • officegen:

    officegen provides basic styling capabilities for all supported document types, but it is limited compared to dedicated design tools. Users can set fonts, colors, and basic layouts, but advanced styling may require additional work.

Code Examples

  • pptxgenjs:

    Example of pptxgenjs:

    const PptxGenJS = require('pptxgenjs');
    
    const pptx = new PptxGenJS();
    const slide = pptx.addSlide();
    
    slide.addText('Hello, World!', { x: 1, y: 1, fontSize: 24 });
    
    pptx.writeFile('presentation.pptx').then(() => {
      console.log('Presentation created: presentation.pptx');
    });
    
  • docx-templates:

    Example of docx-templates:

    const { createReport } = require('docx-templates');
    const fs = require('fs');
    
    const template = fs.readFileSync('template.docx');
    const data = {
      title: 'Annual Report',
      date: new Date().toLocaleDateString(),
      items: [
        { name: 'Revenue', value: '$100,000' },
        { name: 'Expenses', value: '$70,000' },
        { name: 'Profit', value: '$30,000' },
      ],
    };
    
    createReport({ template, data })
      .then((buffer) => fs.writeFileSync('report.docx', buffer))
      .catch((error) => console.error('Error generating report:', error));
    
  • officegen:

    Example of officegen:

    const officegen = require('officegen');
    const fs = require('fs');
    
    // Create a new PowerPoint presentation
    const pptx = officegen('pptx');
    
    // Add a slide
    const slide = pptx.makeSlide();
    slide.addText('Hello, World!', { x: 0.5, y: 0.5, fontSize: 24 });
    
    // Save the presentation
    const out = fs.createWriteStream('presentation.pptx');
    pptx.generate(out);
    
    out.on('close', () => {
      console.log('Presentation created: presentation.pptx');
    });
    

How to Choose: pptxgenjs vs docx-templates vs officegen

  • pptxgenjs:

    Choose pptxgenjs if your primary focus is on creating PowerPoint presentations programmatically. It offers extensive features for designing slides, adding animations, and customizing presentations, making it ideal for applications that need to generate dynamic and visually appealing slides.

  • docx-templates:

    Choose docx-templates if you need to generate Word documents from pre-defined templates with dynamic data. It is ideal for applications that require high-quality document generation with complex layouts, such as invoices, contracts, or reports.

  • officegen:

    Choose officegen if you need a versatile library that can create multiple types of Office documents (Word, Excel, PowerPoint) from scratch. It is suitable for applications that require generating different file types without relying on external templates.

README for pptxgenjs

PptxGenJS

PptxGenJS Sample Slides

jsdelivr downloads NPM Downloads GitHub Repo stars GitHub License TypeScript defs

🚀 Features

PptxGenJS lets you generate professional PowerPoint presentations in JavaScript - directly from Node, React, Vite, Electron, or even the browser. The library outputs standards-compliant Open Office XML (OOXML) files compatible with:

  • ✅ Microsoft PowerPoint
  • ✅ Apple Keynote
  • ✅ LibreOffice Impress
  • ✅ Google Slides (via import)

Design custom slides, charts, images, tables, and templates programmatically - no PowerPoint install or license required.

Works Everywhere

  • Supports every major modern browser - desktop and mobile
  • Seamlessly integrates with Node.js, React, Angular, Vite, and Electron
  • Compatible with PowerPoint, Keynote, LibreOffice, and other OOXML apps

Full-Featured

  • Create all major slide objects: text, tables, shapes, images, charts, and more
  • Define custom Slide Masters for consistent academic or corporate branding
  • Supports SVGs, animated GIFs, YouTube embeds, RTL text, and Asian fonts

Simple & Powerful

  • Ridiculously easy to use - create a presentation in 4 lines of code
  • Full TypeScript definitions for autocomplete and inline documentation
  • Includes 75+ demo slides covering every feature and usage pattern

Export Your Way

  • Instantly download .pptx files from the browser with proper MIME handling
  • Export as base64, Blob, Buffer, or Node stream
  • Supports compression and advanced output options for production use

HTML to PowerPoint Magic

🌐 Live Demos

Try PptxGenJS right in your browser - no setup required.

Perfect for testing compatibility or learning by example - all demos run 100% in the browser.

📦 Installation

Choose your preferred method to install PptxGenJS:

Quick Install (Node-based)

npm install pptxgenjs
yarn add pptxgenjs

CDN (Browser Usage)

Use the bundled or minified version via jsDelivr:

<script src="https://cdn.jsdelivr.net/gh/gitbrent/pptxgenjs/dist/pptxgen.bundle.js"></script>

Includes the sole dependency (JSZip) in one file.

📁 Advanced: Separate Files, Direct Download

Download from GitHub: Latest Release

<script src="PptxGenJS/libs/jszip.min.js"></script>
<script src="PptxGenJS/dist/pptxgen.min.js"></script>

🚀 Universal Compatibility

PptxGenJS works seamlessly in modern web and Node environments, thanks to dual ESM and CJS builds and zero runtime dependencies. Whether you're building a CLI tool, an Electron app, or a web-based presentation builder, the library adapts automatically to your stack.

Supported Platforms

  • Node.js – generate presentations in backend scripts, APIs, or CLI tools
  • React / Angular / Vite / Webpack – just import and go, no config required
  • Electron – build native apps with full filesystem access and PowerPoint output
  • Browser (Vanilla JS) – embed in web apps with direct download support
  • Serverless / Edge Functions – use in AWS Lambda, Vercel, Cloudflare Workers, etc.

Vite, Webpack, and modern bundlers automatically select the right build via the exports field in package.json.

Builds Provided

📖 Documentation

Quick Start Guide

PptxGenJS PowerPoint presentations are created via JavaScript by following 4 basic steps:

Angular/React, ES6, TypeScript

import pptxgen from "pptxgenjs";

// 1. Create a new Presentation
let pres = new pptxgen();

// 2. Add a Slide
let slide = pres.addSlide();

// 3. Add one or more objects (Tables, Shapes, Images, Text and Media) to the Slide
let textboxText = "Hello World from PptxGenJS!";
let textboxOpts = { x: 1, y: 1, color: "363636" };
slide.addText(textboxText, textboxOpts);

// 4. Save the Presentation
pres.writeFile();

Script/Web Browser

// 1. Create a new Presentation
let pres = new PptxGenJS();

// 2. Add a Slide
let slide = pres.addSlide();

// 3. Add one or more objects (Tables, Shapes, Images, Text and Media) to the Slide
let textboxText = "Hello World from PptxGenJS!";
let textboxOpts = { x: 1, y: 1, color: "363636" };
slide.addText(textboxText, textboxOpts);

// 4. Save the Presentation
pres.writeFile();

That's really all there is to it!

💥 HTML-to-PowerPoint Magic

Convert any HTML <table> into fully formatted PowerPoint slides - automatically and effortlessly.

let pptx = new pptxgen();
pptx.tableToSlides("tableElementId");
pptx.writeFile({ fileName: "html2pptx-demo.pptx" });

Perfect for transforming:

  • Dynamic dashboards and data reports
  • Exportable grids in web apps
  • Tabular content from CMS or BI tools

View Full Docs & Live Demo

📚 Full Documentation

Complete API reference, tutorials, and integration guides are available on the official docs site: https://gitbrent.github.io/PptxGenJS

🛠️ Issues / Suggestions

Please file issues or suggestions on the issues page on github, or even better, submit a pull request. Feedback is always welcome!

When reporting issues, please include a code snippet or a link demonstrating the problem. Here is a small jsFiddle that is already configured and uses the latest PptxGenJS code.

🆘 Need Help?

Sometimes implementing a new library can be a difficult task and the slightest mistake will keep something from working. We've all been there!

If you are having issues getting a presentation to generate, check out the code in the demos directory. There are demos for browser, node and, react that contain working examples of every available library feature.

🙏 Contributors

Thank you to everyone for the contributions and suggestions! ❤️

Special Thanks:

PowerPoint shape definitions and some XML code via Officegen Project

🌟 Support the Open Source Community

If you find this library useful, consider contributing to open-source projects, or sharing your knowledge on the open social web. Together, we can build free tools and resources that empower everyone.

@gitbrent@fosstodon.org

📜 License

Copyright © 2015-present Brent Ely

MIT