@s8fy/pptx-renderer
v3.17.0
Published
Framework-free DOM/SVG PowerPoint (PPTX) renderer and viewer controller for browsers
Maintainers
Readme
@s8fy/pptx-renderer
Package guide · Viewer documentation · Commercial licensing · Report an issue
High-fidelity PPTX rendering with a framework-free DOM/SVG/CSS engine.
Render parsed PowerPoint presentations with authored slide geometry, font-driven text layout, vector graphics, tables, charts, and supported DrawingML effects. The package includes an imperative viewer controller for navigation, playback, export, and resource cleanup.
Key Features
| Feature area | Rendering depth | | --------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Classic charts | Column/bar, line, area, pie/doughnut, scatter, bubble, radar, and stock charts, with supported stacking, point/series styling, labels, legends, and axis formatting. Selected 2D combinations preserve multiple groups and secondary axes. | | 3D charts | Column/bar solids, line ribbons, area solids, extruded pies, and surface meshes. Supported scene settings control camera rotation, perspective, depth, wall/floor styling, and face ordering. Surfaces support value bands and wireframes; 2D contours use a separate path. Lighting includes approximations; Office rendering is not reproduced in every detail. | | Modern Office charts | Waterfall, Funnel, Histogram, Treemap, Sunburst, and Box & Whisker have dedicated rendering paths, including supported subtotal, binning, hierarchy, and statistical metadata. | | Chart details | Supported paths consume authored number formats, axis bounds/crossings, log scales, major/minor gridlines, error bars, trendlines, missing data, and deleted labels. Coverage varies by chart family; the presence of parsed metadata alone does not imply it is painted. | | Text and typography | Font measurement, mixed runs, indentation, bullets/numbering, tabs, character spacing, kerning thresholds, line-break controls, autofit, overflow/clipping, and font-ready reflow preserve supported DrawingML layout semantics. | | Shapes, images, and tables | Preset/custom vector geometry, grouped transforms, fills, outlines, arrow endpoints, image crops and opacity, and styled table cells are rendered from the normalized model. | | Equations and legacy graphics | KaTeX typesets supported Office math converted by the parser; SVG resources carry supported EMF/WMF fallback drawings into browser output. | | SmartArt | Cached drawings take precedence. Selected uncached linear-process and organization-hierarchy layouts retain native shapes, text fitting, and supported node animation identities. | | DrawingML effects | Glyph outlines, glow and reflections; shape inner shadows and reflections; selected camera/bevel/material profiles for shapes; and solid 3D text. Effect budgets and browser capabilities determine available fallbacks. | | Object animations | Supported entrance/exit/emphasis effects, grow/shrink, spin, repeat, auto-reverse, timing, and Box/dissolve masks. Subtargets cover selected 2D column/bar series/categories/points, line/area series, and SmartArt nodes. Combination layers and charts with trendlines/error bars do not expose chart subtargets. | | Transitions and Morph | Basic and selected P14 profiles; Morph matches drawing identities and forced names, with supported object, word, and grapheme-preserving character interpolation. Incompatible content crossfades. | | Viewer controller | Navigation, hidden-slide skipping, authored slide links, fullscreen, presenter mode, looping autoplay, PDF/original-file download controls, and owned-resource cleanup. |
Use this package for a browser renderer or an imperative viewer controller. It consumes normalized Core models; it does not parse raw OOXML itself. The controller composes parsing and export through Core. Standalone rendering requires prepared fonts and a browser DOM. Playback defaults to fullscreen/presenter mode; inline playback is configurable. PDF export uses a separate static engine and requires original file bytes. Font availability and supported feature profiles determine fidelity; complete Office or cross-browser pixel parity is not guaranteed.
When to use this package
Use @s8fy/pptx-renderer to render normalized Core models into a browser DOM, or to build around its imperative viewer controller. Standalone render functions require the caller to prepare fonts and own resource cleanup; controller methods provide the composed viewer lifecycle.
For the public browser SDK, Web Component, and framework adapters, start with Viewer. For PDF/Markdown conversion without a viewer, use Converter with its own API and license.
Install
pnpm add @s8fy/pptx-rendererImport the stylesheet once in the browser entry. It includes package-relative, cacheable KaTeX WOFF2 assets for formula rendering.
Usage
import { createPptxViewer } from '@s8fy/pptx-renderer'
import '@s8fy/pptx-renderer/style.css'
export async function mountPresentation(container: HTMLElement, file: File) {
const viewer = createPptxViewer(container)
try {
await viewer.load(await file.arrayBuffer(), file.name)
return viewer
} catch (error) {
viewer.destroy()
throw error
}
}Call viewer.destroy() when the host view is removed. It releases owned media/font resources and event listeners. load() accepts an ArrayBuffer and resolves after authorization, parsing, font preparation (with fallback/timeout), and the first DOM commit.
The controller defaults to the WASM parser/unzip engine, a 960 px viewer width, enabled PDF export and presenter mode, and disabled PPTX download. It also accepts source: { kind: 'file', file, fileName? } or source: { kind: 'presentation', presentation }. Omit source for an empty viewer; top-level file / fileName / presentation options are rejected.
Rendering support
The renderer paints supported glyph glow/reflections, shape reflections and inner shadows, and solid 3D text, alongside existing fills, outlines, tables, charts, and formulas. Shape 3D camera, bevel, contour, and effect composition cover selected profiles. These effects can require connected DOM layout, usable fonts, and canvas/SVG support; unsupported or over-budget branches retain foreground fallbacks rather than promising complete Office parity.
Supported native SmartArt layouts use shared font fitting that can update after fonts become ready. Cached drawings take precedence, and unsupported uncached layouts keep their fallback. Authored audio posters remain visible; hovering or focusing playable audio exposes native controls, and playback still requires user interaction and browser media support. The controller pauses media and releases positioning observers during slide/viewer cleanup.
Animation and Morph playback
Animations and slide transitions run in fullscreen or presenter mode by default. Set animationScope: 'always' for embedded playback. animationScope: 'never', animationMode: 'static', or animate: false disables playback; reduced-motion preferences are respected unless animate: true is explicit. Thumbnails stay static.
The runtime plays relative grow/shrink and signed spin, including zero and multiple turns, finite repeat, auto-reverse, and click/with-previous/after-previous timing. Authored acceleration/deceleration fractions control each forward and reverse leg. Consecutive emphasis preserves the preceding held transform. Native fly enters or exits at the specified slide edge; legacy slide(...) filters keep their object-local clipping.
Supported chart series/category/point and SmartArt node targets can animate independently. Box effects use a rectangular iris mask, and dissolve transitions use a bounded cell mask. These are selected web playback profiles, not support for every PowerPoint build/effect combination.
Slide drawing groups retain one appearance-animation target across their flattened descendants, including nested groups. Checkerboard (across/down) and blinds (horizontal/vertical) entrance/exit effects use a shared group mask, preserving click order and authored stacking. Group-level motion/scale/spin remains unsupported. Pattern edges approximate PowerPoint painting; chart and SmartArt sub-builds do not gain these effects. Static views and PDF exports show the fully built slide.
Morph connects consecutive rendered slides using drawing identity and exact !! names. Visually unchanged text can also stay matched across different ordinary drawing names; this does not infer movement from matching words alone. byObject moves matched objects and groups, while byWord and byChar move matching text units between text boxes. Character mode keeps Unicode graphemes intact. Position, size, rotation, compatible vector paths and paint interpolate; replaced or incompatible visual content crossfades. Duplicate forced names remain unmatched, charts/tables/media crossfade, and unknown Morph modes use a slide fade. Text stays in its original drawing when the host cannot measure or segment it. Paragraphs containing inline math or media also stay intact so their non-text graphics are preserved.
During controlled slide transitions, next() or nextAnimation() finishes the transition before advancing page animations. completeAnimations() also completes destination animations; resetAnimations(), navigation, resize and destruction cancel the current transition. Destination animation initial states are prepared before the transition, keeping click entrances hidden; automatic animations and timed slide advance start after it completes. Reset restores page animation initial states and stops automatic animations and timed advance, including across asynchronous preparation and rerenders. Manual animation commands remain available; navigating to another slide or accepting a new source resumes automatic playback. GSAP and its optional geometry/path plugins load on demand.
The Viewer plays limited variants of 8 of the 19 P14 types:
| P14 effect | Web profile |
| ----------------- | ------------------------------------------------------------ |
| flash | No effect parameters; empirical brightness curve |
| reveal | Left/right; throughBlack true or false |
| flip | Left/right |
| prism | Left/right/up/down; isContent=false and isInverted=false |
| doors, window | Horizontal/vertical |
| pan | Left/right/up/down |
| wheel-reverse | Integer spokes from 1 through 16 |
The ECMA wheel effect also plays 1–16 spokes. Geometric profiles require a
previous visible slide; DOM/SVG content and the profile's CSS features must be
available. Live canvas, media and embedded documents use a basic/static fallback.
A recognized P14 profile uses its source timing, including when an unsupported
variant or unavailable visual capability selects a basic fallback. Unenabled or
uninterpretable P14 effects use the MC-selected branch and its timing. Zero
duration and playback policy can settle the page immediately; advClick is
preserved but does not restrict public navigation commands.
Parsing can retain more transition metadata than these Web playback profiles support. These Web profiles approximate selected macOS PowerPoint samples. Parameter tests and Chromium composition checks do not certify Office pixel parity or cross-browser visual equivalence.
Controller methods
| API | Behavior |
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| slide, total | Current zero-based index and slide count |
| setSlide(index), next(), prev() | Navigate; next() may first advance an animation segment |
| viewMode, setViewMode(mode, { lazy? }) | Read or switch the 'single'/'continuous' ordinary layout without reparsing |
| load(buffer, fileName?), setData(model) | Async document replacement; setData removes original-file export capability |
| toPdf(options?) | Return PDF bytes without downloading |
| downloadPdf(options?), downloadPptx(fileName?) | Async conversion/download initiation; require a successfully loaded original file |
| enterFullscreen() | Promise<void> after the native fullscreen request succeeds |
| enterPresenterMode(), exitPresenterMode(), togglePresenterMode() | Presenter controls |
| startCustomShow(id) | Start a standalone named show by its PptxPresentation.customShows ID |
| nextAnimation(), completeAnimations(), resetAnimations() | Control supported slide animations |
| play(options?), pause(), playing | Interactive slideshow playback (interval, loop); state via onPlaybackChange |
| destroy() | Dispose the controller |
createPptxViewer returns PptxViewerController (extending ViewerController and Viewer) with startCustomShow(id) required. Custom implementations and test doubles should implement Viewer or ViewerController, where startCustomShow is optional.
Use onLoad, onSlideChange, onPlaybackChange, onLicenseStateChange, and onError callbacks for notifications. play() advances using authored slide timing or a 3000ms fallback, plays click builds in order, skips hidden slides, and stops after the last dwell unless loop: true; a later play() restarts from the first visible slide. See the viewer README for the full playback lifecycle. Source changes reject pending document operations with ViewerOperationError; fullscreen requests survive source changes and are canceled by destruction. Always handle returned promises. Non-cancellation failures notify onError once, without consuming the rejection. enablePdfExport and enablePptxDownload control UI availability, not license entitlements.
setSlide(index), initialSlide, and slide-change callbacks use physical zero-based indexes, including hidden slides. next(), prev(), Home/End, and timed advance skip slides marked hidden; next() first finishes an active transition or advances an animation build when enabled. Next remains available for pending builds on the last slide. Hidden slides remain available through explicit selection, authored direct links, and static export.
When animation playback is enabled, a click on an authored trigger shape runs its own sequence. A drawing group trigger responds to clicks on its members. The member's own trigger has priority, followed by the nearest bound group. In fullscreen and Presenter View, a click on the canvas or an unbound shape advances the ordinary build when clickToAdvanceAnimation is enabled. Next and nextAnimation() use the ordinary build sequence. Host play() runs the ordinary sequence followed by the shape-triggered sequences in their source order.
viewMode: 'continuous' stacks every slide vertically at the ordinary scale. With lazy (default true) each slide renders when it approaches the viewport within lazyRootMargin (default '100% 0px'); lazy: false or a missing IntersectionObserver renders all slides. The page scrolls by default; when the host constrains the viewer height, the slides scroll inside the viewer and visibility is measured against that scroller. The most visible slide becomes current, hidden slides are shown and stepped through physically, and fullscreen, Presenter View and play() keep the single-slide stage. See the viewer README for the full behavior.
Authored internal links resolve through Slide.sourcePart, independently of filenames or presentation order. Last Slide Viewed returns to the previously visited slide; unavailable targets are inert. For model sources, retain part identities for authored links, or use one-based numeric slide targets for explicit SDK links. Models that omit hidden treat every slide as visible.
Animation model since 3.2
The public animation model follows Core. AnimationDegraded requires a kind discriminator; read fromGranularity / toGranularity only for text-granularity, and fromFill / toFill for timing-fill. Version 3.2 removed the effect-fallback variant and its fromEffect / toEffect fields, as well as AnimationEffect.previewFallback. These incompatible type changes intentionally shipped in a minor version while the SDK had no external consumers. Add the discriminator to application-created text diagnostics and reparse original PPTX bytes when migrating persisted animation models. Replace interface extension or declaration merging against the former diagnostic interface with application-owned types.
Supported dissolve entrance/exit element animations use deterministic scattered-cell masking with finite repeat and autoReverse. The mask composes with authored opacity, clipping and masks, covers visible overflow, and preserves stopped paint for slide transitions. Reset reuses the same bounded particle field. Static rendering remains complete. Object and slide dissolve share the field generator, with separate lifecycles; the seed and grain are not an Office frame-equivalence guarantee.
Upgrading to 3.0
The fullscreen() alias has been removed, and enterFullscreen() now returns Promise<void>. Invoke it directly from a user interaction and handle rejection; an unavailable browser API rejects with DOMException name NotSupportedError, and denied requests also reject. onError does not consume that rejection.
ViewerBinding is no longer a root export. Applications should create controllers with createPptxViewer; the /internal lifecycle bridge is reserved for SDK integrations.
Render a slide without the controller
renderSlide(slide, { width, height, scale?, watermarks?, onSlideLink?, animate?, onShape3DReport? }) returns an HTMLElement. renderElement(element, scale?, onSlideLink?, onShape3DReport?) returns a Node. Both consume normalized core model types, not the raw parser result.
onSlideLink(target, source?) receives the internal link target string. An
element-level action supplies the rendered element wrapper as source. Links
inside text runs pass only the target. The wrapper's data-s8fy-element-id
identifies the normalized slide element that owns the action.
SVG paint and clipping resources receive fresh DOM IDs on each render, so pages or viewers can share model element IDs without sharing SVG definitions. Model IDs and animation target IDs stay unchanged.
For a prepared Slide, a minimal static host can use:
import { renderSlide } from '@s8fy/pptx-renderer'
import type { RenderOptions } from '@s8fy/pptx-renderer'
import type { Slide } from '@s8fy/pptx-core'
import '@s8fy/pptx-renderer/style.css'
export function mountSlide(host: HTMLElement, slide: Slide, options: RenderOptions) {
const node = renderSlide(slide, options)
host.append(node)
return () => node.remove()
}Install @s8fy/pptx-core directly if your application imports its model types. Set width/height to the presentation's unscaled pixel dimensions; scale defaults to 1.
Optional onShape3DReport(report, element) receives diagnostics about the generated Shape3D/Text3D paint branch. Glyph-volume reports arrive after connected layout and can repeat after font/layout refresh; treat the latest report as replacing the previous observation. Detached elements have no completed volume report. Reports describe selected paint/fallback behavior, not Office visual certification.
These low-level functions do not parse files, resolve authorization, load fonts, own media cleanup, or install the controller's animation/navigation runtime. The caller supplies resolved watermark layers and owns those responsibilities. Prefer createPptxViewer for a complete viewer.
Runtime
Rendering requires a browser DOM. ESM/CJS module imports are SSR-safe; create the viewer after client mount. The package declares Node.js 22.12+, ships both ESM/CJS TypeScript declarations, and exports ./style.css. WASM/Worker/font assets must remain accessible in the deployed application; browser PDF export requires Web Workers.
Framework adapters import the @s8fy/pptx-viewer facade, which delegates to this renderer, instead of maintaining separate rendering implementations.
Repository checks (maintainers)
The following commands require a checkout of the monorepo, not only an installed npm package.
pnpm --filter @s8fy/pptx-renderer test runs the renderer/controller regressions without compiling the WASM engines.
pnpm --filter @s8fy/pptx-renderer test:integration additionally requires the WASM build toolchain and the workspace dependencies.
It builds the generator and parser incrementally in the workspace build directory, then tests generated PPTX
through the JS parser, source-built WASM, bundled WASM, core model, and actual controller CSS.
CI requires both suites; missing build tools fail the integration suite.
pnpm smoke:transitions <fresh-output-dir> runs Chromium composition and lifecycle
checks, including CSS/Viewer equivalence for all seven legacy basic effects and
overlapping-content midpoint frames for both window orientations. It writes PNGs
and a report to the new directory; CI retains these artifacts for 15 days.
pnpm --filter @s8fy/pptx-renderer test:transitions runs the focused transition/Morph
regressions. pnpm smoke:transition-composition <fresh-output-dir> checks two-page
composition and interrupted snapshots for 28 effect/direction pairs in Chromium,
plus root opacity and natural GSAP completion. It compares actual pixels against
independent endpoint colors and captured frames, rather than the old CSS behavior.
Install Chromium with pnpm exec playwright install chromium before running locally.
The separate Visual CI workflow (.github/workflows/visual-ci.yml) owns browser,
DOM and rendering checks, using Node 24 and Nushell. Its Ubuntu job runs type checks,
focused DOM tests and composition pixels without compiling the WASM engines, retaining evidence for
seven days. Its parallel macOS job runs release:visual and smoke:transitions,
preserving the existing snapshot platform and retaining frames/traces for 15 days.
That job builds source parser/authorization WASM without the native CLI or PDFium.
Relevant source, dependency, fixture and baseline changes trigger it on pushes and
PRs; superseded runs are cancelled. The main CI retains general SDK/engine tests.
License
This package is licensed under the Structurify Commercial & Evaluation License (see LICENSE). Free for local development, testing, POC evaluation, and noncommercial use; commercial production use requires a commercial license.
