@microscope-js/renderer-pptx
v0.1.5
Published
PPTX (PowerPoint) renderer for microscope-js (JSZip + DOMPurify)
Readme
@microscope-js/renderer-pptx
PowerPoint
.pptxrenderer for microscope-js. Reads the OOXML archive with JSZip, extracts the text runs from eachslide*.xml, and renders them as paginated slides. Lightweight text view — no full OOXML layout engine.
Install
pnpm add @microscope-js/renderer-pptxUse
import { createRegistry, mount } from '@microscope-js/core';
import { pptxRenderer } from '@microscope-js/renderer-pptx';
const registry = createRegistry([pptxRenderer]);
const handle = await mount({ source: file, container, registry });
const cap = handle.capabilities as { slideCount: number; goToSlide(n: number): void };
console.log(cap.slideCount);
cap.goToSlide(3);Options
| Option | Default | Description |
| ------------------- | --------------------- | ----------------------------------------------------------------- |
| maxBytes | 128 * 1024 * 1024 | Reject .pptx files larger than this |
| maxUncompressed | 512 * 1024 * 1024 | Total uncompressed cap — zip-bomb defense |
Capabilities exposed on the RenderHandle
interface PptxHandle extends RenderHandle {
readonly capabilities: {
slideCount: number;
goToSlide(n: number): void;
};
}Why "text view, not pixel-perfect"
Rendering OOXML pixel-perfect requires a complete shape + layout + font + image engine — usually ~2 MB of code and a long maintenance tail. This package goes the other way: it keeps the bundle tiny, leans on the browser for typography, and surfaces the content users actually want to read. If you need exact visual fidelity, pair this with a server-side preview pipeline (LibreOffice, OnlyOffice, etc.) for that one workflow.
Pixel-perfect rendering is on the roadmap as an opt-in package.
Security model
- Every archive entry path is run through
assertSafeZipEntry()before extraction —..segments and absolute paths are rejected (CWE-22, zip-slip). ByteBudgetcaps total uncompressed bytes — defends against zip bombs (a 1 KB zip that expands to 4 GB).- Slide HTML is passed through
sanitizeHtmlbefore being inserted. - All rendering is in-browser. The deck never leaves the tab.
See also
@microscope-js/renderer-docx·@microscope-js/renderer-xlsx@microscope-js/react— React adapter- Repository · Live demo · API docs
