Logo node-pptx-templater
Getting Started API Reference Manual (95 Methods) → Showcase & Demos Templates & Data Feature Catalog Troubleshooting Contributing
GitHub npm
node-pptx-templater logo node-pptx-templater
Zero Native Dependencies • Dual ESM/CJS • Non-Corrupting Engine

High-Performance OpenXML PowerPoint Template Engine

The low-level PPTX manipulation library for Node.js. Dynamically replace text, update charts with synchronized Excel workbook caches, format tables, reorder layers, and manipulate slides without PowerPoint repair warnings or heavy Office dependencies.

$ npm install node-pptx-templater
Quick Start Guide → Explore Showcase
Quick Start Example
const { PPTXTemplater } = require('node-pptx-templater');

async function generateDeck() {
  // 1. Load an existing template presentation
  const ppt = await PPTXTemplater.load('./templates/report.pptx');
  ppt.useAllSlides();

  // 2. Dynamic text replacement across runs
  ppt.replaceMultiple({
    '{{title}}': 'Q3 Performance Review',
    '{{author}}': 'Engineering Operations',
    '{{arr_growth}}': '+38.2%'
  });

  // 3. Update charts with automatic internal Excel cache sync
  ppt.useSlide(1);
  ppt.updateChart('RevenueChart', {
    categories: ['Q1', 'Q2', 'Q3', 'Q4'],
    series: [{ name: 'Cloud ARR', values: [18.4, 22.1, 26.8, 31.5] }]
  });

  // 4. Append table rows with alternating striping
  ppt.useSlide(2);
  ppt.addTableRow('InitiativesTable', ['Platform Migration', 'Sarah Jenkins', 'Completed']);
  ppt.stripeRows('InitiativesTable', { oddColor: 'F8FAFC', evenColor: 'EDF2F7' });

  // 5. Save generated PPTX or export as Buffer for Lambda/Cloud
  await ppt.save('./output/executive-report.pptx');
  console.log('✓ Report created successfully!');
}

generateDeck();

Getting Started

Everything you need to integrate node-pptx-templater into your Node.js backend, microservice, or serverless functions.

Requirements & Runtimes

Verified against Node 20, 22, and 24

  • ✓ Node.js: >= 20.12.0
  • ✓ Dual Modules: CommonJS (require) and ESM (import)
  • ✓ Zero Native Binaries: No Python, LibreOffice, or Java installation required
  • ✓ Serverless-Ready: Works natively in AWS Lambda, Google Cloud Functions, and Docker

Installation

Add to your project via your package manager

npm install node-pptx-templater
pnpm add node-pptx-templater
yarn add node-pptx-templater

Running the Consolidated Showcase Suite

All 12 production scenarios are demonstrated in a single self-contained file showcase/examples.js with all JSON data embedded. You can run all demonstrations with one command:

npm run examples

Outputs are automatically written to showcase/output/ without overwriting template fixtures.

API Reference

Complete, source-verified documentation of the PPTXTemplater public API.

Dedicated Reference Portal Available

Full Production API Reference Manual

Access all 95 public methods across 10 categorized modules with a sticky/collapsible sidebar, real-time client-side method search, complete parameter tables with default values, DrawingML/PresentationML OpenXML mutation specifications, and 1-click copyable code snippets.

Open API Reference

Interactive Showcase

All 12 supported demonstrations from showcase/examples.js. Run npm run examples to execute every demo deterministically.

DEMO 01 Verified

Text Replacement & 16:9

Configures slide dimensions to widescreen 16:9 and replaces placeholders across fragmented XML text runs.

ppt.setSlideSize('16:9');
ppt.replaceMultiple(data);
DEMO 02 Verified

Chart Updates & Excel Sync

Updates multi-series chart data and syncs internal Excel cache worksheets to avoid repair dialogs.

ppt.updateChart('chart1', series);
ppt.updateDataLabels('chart1', {showVal:true});
DEMO 03 Verified

Tables, Striping & Pagination

Populates table rows, applies alternating row striping, custom borders, and pins summary rows during split.

ppt.stripeRows(tbl, {oddColor:'F8FAFC'});
ppt.splitTableOnOverflow(tbl, {summaryRows:1});
DEMO 04 Verified

Nested Tables & Cell Merging

Appends rows with nested rowspan arrays, automatic adjacent merging, and extracts structured JSON.

ppt.addTableRow(t, row, {mergeStrategy:'rowspan'});
const data = await ppt.getTableRows(t);
DEMO 05 Verified

Shapes, Alignment & Z-Order

Adds vector shapes, reorders stacking layers with bringToFront/sendToBack, and aligns shapes.

ppt.alignShapes(['A','B'], 'middle');
ppt.bringToFront('A');
DEMO 06 Verified

Dynamic Cell Shapes

Anchors status indicators, badges, and progress markers directly inside table cells.

ppt.addTableRow(tbl, [{type:'circle', fill:'#10B981'}, 'Complete']);
DEMO 07 Verified

Images: PNG, WebP & Base64

Inserts and replaces images with absolute dimensions, supporting WebP and Base64 data URIs.

ppt.addImage(base64Uri, {x, y, width, height});
ppt.replaceImage('logo', newPath);
DEMO 08 Verified

Slide Duplication & Import

Deep-clones slides, reorders presentation sequences, and imports slides across decks.

ppt.duplicateSlide(1);
await ppt.importSlideFrom(sourceDeck, 1);
DEMO 09 Verified

Hyperlinks & Navigation

Adds external web URLs and internal inter-slide navigation jumps, and inspects links.

ppt.addHyperlink({text:'Site', url:'...'});
ppt.addSlideLink({sourceSlide:1, targetSlide:3});
DEMO 10 Verified

Rich Typography & Runs

Injects styled text runs with custom weights, fonts, colors, and line spacing.

ppt.appendTextRun('Box', ' [Alert]', {style: {bold:true, color:'#DC2626'}});
DEMO 11 Verified

OpenXML Folder Workflow

Extracts PPTX to folder of XML files, edits in-place, and rebuilds back into binary presentation.

await PPTXTemplater.extractPptx(file, dir);
await PPTXTemplater.buildPptx(dir, out);
DEMO 12 Verified

Serverless Buffer Export

Generates presentations directly in-memory as a Buffer without touching disk I/O.

const buffer = await ppt.toBuffer();
// return { statusCode: 200, body: buffer }

Templates & Data Architecture

Design beautiful slides in PowerPoint, LibreOffice, or Google Slides — inject dynamic data in Node.js.

{{ }}

Text Placeholders

Use standard curly brackets like {{company}} anywhere in text shapes. The engine merges fragmented XML runs automatically.

Excel Cache Sync

When you update a chart, node-pptx-templater updates both the Chart XML and the embedded .xlsx workbook, ensuring zero corruption or repair prompts.

Selection Pane Naming

Name tables and shapes in PowerPoint via Home → Select → Selection Pane (e.g. "RevenueChart", "SummaryTable") to target them cleanly in your code.

Feature Status & Catalog

Evidence-based implementation status across the 86-feature catalog. 76 of 86 features (88.4%) are verified with 278 passing tests across 42 test suites.

Showing 76 verified features
Feature Subsystem API Method Status Verified Test
Load Presentation (Path / Buffer / Folder) Core PPTXTemplater.load() Supported PPTXTemplater.test.js
Save to File / Disk Serialization Core ppt.save() / saveToFile() Supported PPTXTemplater.test.js
In-Memory Buffer Export Core ppt.toBuffer() Supported PPTXTemplater.test.js
OpenXML Folder Unpack & Rebuild Core extractPptx() / buildPptx() Supported XmlFolderSupport.test.js
Slide Dimensions & Aspect Ratio (16:9 / 4:3) Slides setSlideSize() / getSlideDimensions() Supported SlideDimensions.test.js
Slide Deep Duplication & Cloning Slides duplicateSlide() / cloneSlide() Supported SlideDuplicationIndependence.test.js
Slide Reordering Permutation Slides reorderSlides() Supported SlideOperationsCompatibility.test.js
Cross-Deck Slide Import with Rel Mapping Slides importSlideFrom() Supported SlideImportAndHyperlink.test.js
Fragmented Text Run Replacement Text replaceTextByTag() / replaceMultiple() Supported TemplateEngine.test.js
Text Search & Shape Inspection Text findText() / getTextElements() Supported PPTXTemplater.test.js
Typography & Text Runs (Weights, Colors, Fonts) Text appendTextRun() / prependTextRun() Supported TypographyAndTextRuns.test.js
Table Updates & Dynamic Row Injection Tables updateTable() / addTableRow() Supported TableAddAndColumns.test.js
Cell Merging & Vertical Rowspan Strategy Tables mergeCells() / addTableRow(rowspan) Supported TableExtractionAndNesting.test.js
Row Striping & Custom Cell Borders Tables stripeRows() / updateCell(border) Supported TableAddAndColumns.test.js
Table Auto-Pagination & Summary Row Pinning Tables splitTableOnOverflow(summaryRows) Supported TableAutoPagination.test.js
Table Structured JSON Extraction Tables getTableRows({includeMetadata:true}) Supported TableExtractionAndNesting.test.js
Chart Updates with Automatic Excel Cache Sync Charts updateChart() / updateChartData() Supported ChartUpdate.test.js
Chart Data Labels Visibility & Options Charts updateDataLabels() Supported ChartDataLabels.test.js
Vector Shapes Creation & Styling Shapes addShape() / updateShape() Supported ShapeManagement.test.js
Z-Order Stacking (Bring to Front / Send to Back) Shapes bringToFront() / sendToBack() Supported ZOrder.test.js
Spatial Alignment & Distribution Shapes alignShapes() / distributeShapes() Supported SpatialAndDiscovery.test.js
Table Cell Shapes & Status Badges Shapes addTableRow([{type:'circle',...}]) Supported CellShapes.test.js
Multi-Format Media (PNG, JPEG, WebP, Base64, TIFF) Media addImage() / replaceImage() Supported ImagesAndMedia.test.js
External & Inter-Slide Hyperlinks Hyperlinks addHyperlink() / addSlideLink() Supported HyperlinkInspection.test.js
XXE & Billion Laughs XML Bomb Protection Security safeParseXml() / validateXml() Supported XMLSecurity.test.js

Troubleshooting & FAQ

Answers to frequent questions and common issues when generating PowerPoint decks.

Why did PowerPoint show "PowerPoint found a problem with content" in other libraries? ▼

PowerPoint caches chart data in two places: the Chart XML part and an embedded Excel workbook (ppt/embeddings/Microsoft_Excel_Worksheet.xlsx). If a template engine modifies the Chart XML without updating the embedded Excel part, PowerPoint flags the discrepancy and prompts the user to "Repair" the file. node-pptx-templater synchronizes both layers atomically, guaranteeing zero repair warnings.

How do I discover shape and table names in my presentation? ▼

In PowerPoint, open the Selection Pane (Home → Select → Selection Pane) to see and rename any shape, table, or chart. Programmatically, you can also inspect all elements using ppt.getTables(), ppt.getShapes(), and ppt.getImages().

Can I generate presentations in AWS Lambda or cloud functions? ▼

Yes! Because node-pptx-templater has zero native binaries or external C++ dependencies, it runs out of the box in serverless environments. Call const buffer = await ppt.toBuffer() to export directly to memory and return the buffer in your Lambda response or upload directly to S3.

Are slide numbers 1-based or 0-based? ▼

Slide numbers are 1-based to match the human-readable numbers shown in PowerPoint slide thumbnails (ppt.useSlide(1) targets the first slide).

Contributing & Local Development

Contributions are warmly welcome. Follow these steps to set up your local environment.

  1. 1. Clone the repository:
    git clone https://github.com/jsuyog2/node-pptx-templater.git
  2. 2. Install dependencies:
    npm install
  3. 3. Run the complete test suite:
    npm test
  4. 4. Run the showcase demonstrations:
    npm run examples