Skip to content

@wity/scene-to-pptx

Server-side presentation renderer. Snapshots a wity-scene document at one or more timestamps and produces a PowerPoint (.pptx) file using node-canvas and pptxgenjs. Node.js / Lambda only, not browser-compatible.

The output is directly importable into PowerPoint, Keynote, and Google Slides.

Entry point: Call witySceneRender with outputFormat: "pptx" — do not invoke this Lambda directly. See the Deployment guide.

Install

bash
npm install @wity/scene-to-pptx
# peer deps:
npm install @wity/scene-core @xmldom/xmldom

render(sceneXml, fontManifest, options)

Render scene snapshots to a PowerPoint file on disk.

ts
render(
  sceneXml:     string,
  fontManifest: Record<string, string>,
  options: {
    ts?:         number,
    timestamps?: number[],
  }
): Promise<{ pptxPath: string, cleanup: () => Promise<void> }>
ArgumentTypeDescription
sceneXmlstringRaw <wity-scene> XML
fontManifestRecord<string, string>Font family name → URL. Pass {} if no custom fonts.
options.tsnumber (default 0)Scene time in seconds to snapshot. Ignored when timestamps is provided.
options.timestampsnumber[]Array of scene times — each produces one slide.

Returns:

FieldDescription
pptxPathAbsolute path of the rendered .pptx in /tmp
cleanupCall after upload to remove temp files
js
import { render } from '@wity/scene-to-pptx';

// Single slide at t=0
const { pptxPath, cleanup } = await render(sceneXml, {}, { ts: 0 });
// upload pptxPath to storage...
await cleanup();
js
// Multi-slide deck: one slide per timestamp
const { pptxPath, cleanup } = await render(sceneXml, fontManifest, {
  timestamps: [0, 5.0, 10.0, 15.0],
});

Slide layout

The presentation layout is set to the scene's pixel dimensions interpreted at 96 DPI (standard screen PPI), preserving the exact aspect ratio:

  • 1920 × 1080 scene → 20" × 11.25" slides (widescreen 16:9)
  • 1080 × 1920 scene → 11.25" × 20" slides (portrait / reels)

Each slide contains the rendered scene frame as a full-bleed pixel-perfect PNG image.


What is rendered

Element typeRendered?
ws-rectYes — filled rectangles, stroke, border-radius
ws-textYes — font, color, animation state at ts
ws-imageYes — image with fit modes
ws-videoNo — skipped silently (graphics snapshot only)
ws-audioNo — skipped silently

Animation and keyframe state is fully resolved at each tsevaluate(scene, ts) produces the exact visual frame per slide.


Lambda deployment

The witySceneToPptx Lambda wraps this package.

Input:

json
{
  "sceneXml":    "<wity-scene>...</wity-scene>",
  "fontManifest": {},
  "timestamps":  [0, 5.0, 10.0]
}

Response:

json
{ "url": "https://...", "fileSize": 456789, "slides": 3 }
ConfigValue
Function namewitySceneToPptx
Memory1024 MB
Timeout120 s
Ephemeral storage1024 MB
RuntimeNode.js 20
FFmpeg layerNot required