@paperjsx/json-to-pptx-pro
v0.0.4
Published
PaperJSX Pro PPTX engine — templates, HarfBuzz, ChartEx, SmartArt, canvas preview
Maintainers
Readme
@paperjsx/json-to-pptx-pro
Commercial PowerPoint generation engine. Renders production-grade .pptx from JSON or TypeScript with the full PaperJSX rendering surface — 140+ shapes, 15 chart types, HarfBuzz text shaping, .potx template ingestion, canvas previews, and a commercial self-hosting license.
npm install @paperjsx/json-to-pptx-proRequires Node.js >=18 and a valid PAPERJSX_LICENSE_KEY. ESM only.
Quick Start
import { createEngine } from "@paperjsx/json-to-pptx-pro";
import { writeFileSync } from "node:fs";
const pptx = createEngine({
licenseKey: process.env.PAPERJSX_LICENSE_KEY,
});
const buffer = await pptx.render({
type: "Document",
meta: { title: "Board Review" },
slides: [
{
type: "Slide",
style: { padding: 40 },
children: [
{
type: "Text",
content: "Board Review",
style: { fontSize: 30, fontWeight: "bold", color: "#0F172A" },
},
{
type: "Text",
content: "ARR is up 41% year over year.",
style: { marginTop: 12, fontSize: 18, color: "#334155" },
},
],
},
],
});
writeFileSync("board-review.pptx", buffer);Fonts and Layout Drift
Embed your fonts or accept metric drift.
Text measurement controls wrapping, pagination, and chart-label fit. If the render host measures one font and the recipient opens the deck with a substituted font, layout can drift. The safest production path is to load or embed the exact fonts you expect viewers to use.
import { createEngine, loadFont } from "@paperjsx/json-to-pptx-pro";
import { readFileSync, writeFileSync } from "node:fs";
loadFont("Inter", readFileSync("./fonts/Inter-Regular.ttf"));
const pptx = createEngine({
licenseKey: process.env.PAPERJSX_LICENSE_KEY,
});
const doc = {
type: "Document",
meta: { title: "Font-safe board review" },
slides: [
{
type: "Slide",
children: [
{
type: "Text",
content: "Measured with Inter",
style: { fontFamily: "Inter", fontSize: 28, color: "#0F172A" },
},
],
},
],
};
const buffer = await pptx.render(doc);
writeFileSync("font-safe-board-review.pptx", buffer);If you need a safe no-embed default for Linux/LibreOffice-heavy environments, prefer Liberation Sans or DejaVu Sans.
What's in Pro
Everything in the free @paperjsx/json-to-pptx plus:
- 140+ shapes — full DrawingML preset library, custom geometry, connectors with rooted endpoints.
- 15 chart types — including waterfall, funnel, sunburst, treemap, boxplot, combo, radar, bubble, stock. All editable in PowerPoint with embedded Excel data.
- HarfBuzz text shaping — complex scripts (Arabic, Hebrew, Devanagari, Thai), RTL, OpenType features, emoji, full ligature support.
- Template ingestion — load
.potxfiles, extract slide masters/layouts, mutate placeholders, and preserve corporate theming end-to-end. - Canvas preview rendering — generate PNG thumbnails for every slide without opening PowerPoint.
- Font subsetting — embed only the glyphs used, cutting payload size by 80–95%.
- Quality reporting — structural validation, accessibility hints, compatibility analysis, repair helpers.
- Commercial license — production use, self-hosting, redistribution in proprietary products.
See paperjsx.com/pricing for tiers and hosted-runtime options.
Architecture
Multi-stage render pipeline with per-request isolation:
validate (Zod) → layout (Yoga flex) → typography (fontkit + HarfBuzz)
→ OOXML serialize (DrawingML, chart XML, embedded workbooks)
→ ZIP assemble (jszip)Every render runs inside an AsyncLocalStorage-scoped RenderContext, so concurrent renders never share mutable state. SSRF protection covers IPv4/IPv6 private ranges, DNS rebinding, and scheme allowlisting before any remote asset is fetched. Resource ceilings (MAX_TOTAL_NODES=50,000, MAX_NESTING_DEPTH=20, data-URL size cap 50MB) bound any single render.
Public API
// Engine
createEngine({ licenseKey })
PaperEngine.render(doc, options?)
RenderContext, withContext
// Validation
PaperDocumentSchema, PaperSlideSchema, PaperNodeSchema
AgentDocumentSchema, AgentSlideSchema
// Templates (pro)
loadTemplate(buffer)
mutateTemplate(template, mutations)
// Preview (pro)
renderSlidePreview(slide, { width, height, format: "png" | "jpeg" })
// Quality (pro)
runQualityReport(buffer)
repairPresentation(buffer)
// Layout & typography
runLayout(node, containerSize)
calculateTextMetrics(text, style)
shapeText(runs, { script, direction })
// Semantic compiler
compileAgentDocument(agentDoc, options?)
compileAgentSlide(agentSlide)
validateAgentDocumentLayout(paperDoc)
// Determinism
setDeterministicMode(true)The agent compiler now accepts top-level coupled controls in designTokens (scale, density, shape) plus compileAgentDocument(..., { layoutValidation: "warn" | "error" | "off" }) for a synchronous pre-render sanity pass. Built-in presets now include the modern preset family: midnight, terminal, and editorial-wide.
Full type surface in dist-pro/index.d.ts.
License Validation
const pptx = createEngine({
licenseKey: process.env.PAPERJSX_LICENSE_KEY,
});The key is validated against the embedded public key on first render. Invalid, expired, or missing keys throw PaperJSXLicenseError with a remediation message. Self-hosted deployments can pin to a specific offline key; hosted deployments rotate automatically.
Keys are provisioned at paperjsx.com/dashboard. Do not commit PAPERJSX_LICENSE_KEY to source control — load it from your secret store.
Package Choice
| Package | License | Production use |
| -------------------------------- | ---------- | -------------------------------------- |
| @paperjsx/json-to-pptx | Apache-2.0 | Free / evaluation / open-source apps |
| @paperjsx/json-to-pptx-pro | Commercial | Production, self-hosted, closed-source |
The APIs are identical. Migrating is a one-line import change once you have a license key.
Determinism
import { setDeterministicMode } from "@paperjsx/json-to-pptx-pro";
setDeterministicMode(true);Freezes timestamps, relationship IDs, and cache seeds so the same document produces byte-identical output. Use for snapshot tests, content-addressable storage, and reproducible builds.
Error Handling
import {
PaperError,
PaperJSXFeatureError,
PaperJSXLicenseError,
} from "@paperjsx/json-to-pptx-pro";
try {
await pptx.render(doc);
} catch (err) {
if (err instanceof PaperJSXLicenseError) { /* invalid/expired key */ }
else if (err instanceof PaperJSXFeatureError) { /* feature not in tier */ }
else if (err instanceof PaperError) {
console.error(err.code, err.phase, err.message);
}
throw err;
}Links
- Docs: paperjsx.com/docs
- Playground: paperjsx.com/playground
- Pricing & licensing: paperjsx.com/pricing
- Dashboard: paperjsx.com/dashboard
License
Commercial. See the packaged LICENSE file. A valid PAPERJSX_LICENSE_KEY is required for production use.
