Reference
Node.js API
Typed ESM functions for parsing, rendering, previewing, exporting, and validating presentations.
Functions
Import from ./dist/index.js after building the repository.
| Function | Purpose |
|---|---|
| parsePresentation | Validate input and return typed data, or throw |
| renderPresentation | Return a complete HTML document |
| previewPresentation | Start a loopback Vite server for a JSON file |
| exportPresentation | Export JSON, HTML, or a URL to PPTX and return layout issues |
| validateLayout ยท validatePptx | Browser layout checks and offline PPTX structure checks |
Example
Save this as example.mjs in the repository root and run node example.mjs.
import { readFile } from 'node:fs/promises';
import { exportPresentation, validatePptx } from './dist/index.js';
const issues = await exportPresentation('examples/basic/presentation.json', {
output: 'presentation.pptx',
});
console.log(issues);
const report = validatePptx(await readFile('presentation.pptx'));
if (!report.valid) process.exitCode = 1;
Export options
Options for exportPresentation(input, options). Failures throw; returned issues are layout diagnostics.
| Option | Default | Meaning |
|---|---|---|
| output | Required | Output PPTX path |
| selector | [data-pptx="slide"], .slide | Slide elements in document order |
| metadata | From the document | title, author, subject, and lang overrides |
| validate | true | Layout errors block export; false still collects issues |
| timeout | 60000 | Playwright timeout in milliseconds |
| textSlack | { ratio: 0.06, min: 91440, max: 457200 } | Extra text box width in EMU; false keeps converter sizes |
| eastAsianFont | Microsoft JhengHei | PowerPoint East Asian font for CJK text |