pptx-template-engine
v0.4.3
Published
Generate PPTX files from templates using semantic text and image placeholders.
Maintainers
Readme
📦 pptx-template-engine
Generate PowerPoint (PPTX) reports dynamically using templates with semantic text and image placeholders.
🔍 Keywords (npm search)
powerpoint, pptx, pptx-generator, powerpoint-generator, pptx-template, report-generator, automated-reports, office-open-xml, ooxml, node-pptx, browser-pptx
✨ Overview
pptx-template-engine is a lightweight JavaScript/TypeScript library for automated PowerPoint report generation.
It works with a pre-designed PPTX template and replaces:
- 📝 Text placeholders like
{company_name} - 🖼️ Image placeholders defined using Alt Text like
chart:sales_chart
Unlike index-based approaches, this library uses semantic keys, making templates stable even when slides or layouts change.
🚀 Features
- 📝 Text replacement using
{placeholder}syntax - 🖼️ Image replacement using Alt Text (
chart:key) - 🧠 Semantic placeholders (no slide/image indexes)
- ⚙️ Works in Node.js and Browsers
- 🖥️ CLI support (
pptx-generate,pptx-lint) - 🧪 Template validation via manifest
- 🔄 Stable binary handling (
Uint8Array) - 📦 JavaScript & TypeScript support
📥 Installation
npm install pptx-template-engine🧠 How It Works
- Design a PowerPoint (.pptx) template
- Add text placeholders like
{report_month} - Add image placeholders using Alt Text (e.g.
chart:sales_chart) - Generate the final PPTX using code or CLI
🧩 Creating a PPTX Template
Text placeholders
Use placeholders directly in PowerPoint text boxes:
{company_name}
{report_month}
{total_sales}Image placeholders (IMPORTANT)
- Insert a placeholder image (PNG or JPG)
- Right-click → Edit Alt Text
- Set the description to:
chart:sales_chartSupported formats:
- ✅ PNG
- ✅ JPG
- ❌ EMF / WMF (vector images not supported)
🧪 Node.js Example
const fs = require("fs");
const { generatePPT } = require("pptx-template-engine");
(async () => {
const template = fs.readFileSync("./template.pptx");
const chart = fs.readFileSync("./sales-chart.png");
const pptx = await generatePPT({
template,
text: {
company_name: "Acme Corporation",
report_month: "December 2025",
total_sales: "$1.2M"
},
images: {
sales_chart: chart
}
});
fs.writeFileSync("sales-report.pptx", Buffer.from(pptx));
})();🌐 Browser Example
import { generatePPT } from "pptx-template-engine";
const pptx = await generatePPT({
template: templateArrayBuffer,
text: {
company_name: "Acme Corporation",
report_month: "December 2025"
},
images: {
sales_chart: chartBlob
}
});
const blob = new Blob([pptx], {
type: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
});🖥️ Node Convenience API
const { generatePPTFromFile } = require("pptx-template-engine/node");
await generatePPTFromFile({
templatePath: "./template.pptx",
outputPath: "./report.pptx",
text: require("./text.json"),
images: require("./images.json"),
strict: true
});🧾 CLI Usage
pptx-generate --template template.pptx --out report.pptx --text text.json --images images.json --strictpptx-lint --template template.pptx --manifest template.manifest.json📄 Template Manifest Example
{
"text": ["company_name", "report_month", "total_sales"],
"images": ["sales_chart"]
}⚙️ API Reference
generatePPT(options): Promise<Uint8Array>📄 License
MIT
