Documentation Overview

Architectural Overview & Templating Paradigm

`node-pptx-templater` bridges the gap between high-fidelity visual design in Microsoft PowerPoint and programmatic serverless report automation in pure JavaScript.

The Two PowerPoint Paradigms

✕

Canvas From Scratch (Legacy Approach)

Coding every box coordinate, color hex, font hierarchy, and margin manually in JavaScript code (`pptx.addShape()`, `pptx.addText()`). Designers cannot review decks without git pull requests and developers spend days adjusting pixel coordinates.

✓

Template-Driven Mutation (Our Paradigm)

Designers create gorgeous templates directly inside Microsoft PowerPoint with corporate slide masters, fonts, themes, and layouts. Developers simply inject dynamic data into placeholders, charts, and tables in memory.

Under 15 Lines of Code

Load a presentation, substitute text across fragmented XML runs, update native charts with Excel sheet dual-sync, and export cleanly:

report-generator.mjs
import { PPTXTemplater } from 'node-pptx-templater';

// 1. Load an existing PowerPoint template with design, layout & masters
const ppt = await PPTXTemplater.load('./templates/quarterly-report.pptx');

// 2. Safely substitute text variables with AST run-fragment healing
ppt.useSlide(1).replaceText({
  '{{COMPANY_NAME}}': 'Acme Global AI',
  '{{REPORT_DATE}}': 'October 2026',
  '{{REVENUE_TOTAL}}': '$48.5M'
});

// 3. Update native charts with automated Excel workbook dual-sync
ppt.useSlide(2);
await ppt.updateChart('ARRChart', {
  categories: ['Q1', 'Q2', 'Q3', 'Q4 (Proj)'],
  series: [{ name: 'ARR ($M)', values: [24.5, 31.2, 39.8, 48.5] }]
});

// 4. Export directly without Microsoft PowerPoint repair warnings
await ppt.saveToFile('./output/Quarterly_Report_2026.pptx');

Core Engine Subsystems

In-Memory Virtual File System

Extracts OPC PKZip archives directly into an in-memory `Map<string, Uint8Array>`. Zero temporary disk file writes, sub-15ms cold boot, perfect for AWS Lambda and Cloudflare Workers.

Run Fragment Healing Engine

When humans type tokens like {{NAME}}, PowerPoint splits them into disjoint XML run nodes. Our AST scanner coalesces text runs transparently.

Chart Excel Dual-Sync

PowerPoint charts store data in both DrawingML and embedded Excel workbooks. Updating both parts synchronously eliminates the infamous "PowerPoint found a problem with content" repair prompt.

Dynamic Table Auto-Pagination

Recursively slices overflowing rows across cloned slides against calculated vertical margins while repeating headers and preserving summary rows on the final slide.

Ready to install?

Jump to Installation Guides

Installation Guide