@briank-dev/pptx-to-html
v2.1.0
Published
Convert PPTX slides to high-fidelity HTML in the browser — pure Rust/WASM, zero dependencies
Maintainers
Readme
English · 한국어
Convert PowerPoint decks to HTML entirely in the browser. The renderer is a from-scratch ECMA-376 implementation written in Rust and compiled to WebAssembly — no server round trip, no upload, no PowerPoint or LibreOffice install. The file never leaves the tab.
Anything the renderer cannot resolve exactly is reported as a coded diagnostic rather than silently dropped or replaced with a guess.
Try the live demo — drop a .pptx and watch it convert.
Install
npm install @briank-dev/pptx-to-htmlUsage
The convenience API initializes WASM on first use and accepts a browser File/Blob,
ArrayBuffer, or Uint8Array. Inputs larger than 64 MiB are rejected before conversion.
<iframe id="output" sandbox="allow-scripts" title="Converted slide output"></iframe>
<script type="module">
import { pptxToHtml } from '@briank-dev/pptx-to-html';
const html = await pptxToHtml(file);
document.getElementById('output').srcdoc = html;
</script>Security: converted output is active, untrusted HTML. Render it in a sandboxed iframe with
allow-scriptsand withoutallow-same-origin, as shown above.
<script type="module">
import init, {
convert,
convert_with_options,
convert_with_metadata,
convert_with_options_metadata,
get_presentation_info,
} from '@briank-dev/pptx-to-html';
await init();
const response = await fetch('/presentation.pptx');
const data = new Uint8Array(await response.arrayBuffer());
const html = convert(data);
const filtered = convert_with_options(
data,
true,
false,
new Uint32Array([1, 3]),
1.0,
);
const info = get_presentation_info(data);
console.log(info.slideCount, info.widthPx, info.heightPx, info.title);
const withMetadata = convert_with_metadata(data);
console.log(JSON.parse(withMetadata.diagnostics));
console.log(withMetadata.unresolvedElements);
const filteredWithMetadata = convert_with_options_metadata(
data,
true,
false,
new Uint32Array([1, 3]),
1.0,
);
</script>API
pptxToHtml(input, moduleOrPath?)— lazily initialize WASM and convert browser or byte input; concurrent calls share the first initialization attempt and its success or failure, while a later call retries after failureinit()— initialize the WASM moduleconvert(data)— convert PPTX bytes to HTMLconvert_with_options(data, embedImages, includeHidden, slideIndices, scale)convert_with_metadata(data)— convert and return canonical diagnostics JSON plus unresolved-element metadataconvert_with_options_metadata(data, embedImages, includeHidden, slideIndices, scale)get_presentation_info(data)— typed presentation metadataget_info(data)/get_slide_count(data)— backward-compatible helpers
Metadata results expose diagnostics (canonical ordered JSON), diagnosticsJson, and the
backward-compatible unresolvedElements JSON.
Slide indexing
convert_slides(data, slides)uses 0-based slide indices.convert_with_options(..., slideIndices)andconvert_with_options_metadata(..., slideIndices)use 1-based slide indices.
Slide scale
scaleis required; pass1.0for the original slide size.- Values like
2.0enlarge the whole slide canvas uniformly without recomputing coordinates or reflowing text. - The included browser demo displays ordered diagnostics, executes renderer-owned actions and timing in an opaque-origin frame, and initializes image-like zoom to the available width.
Scope
This npm package is the browser ESM/WASM distribution and converts PPTX only. The parent project additionally converts DOCX, DOC, XLSX, XLS, PPT, and PDF, but those formats require a native pipeline backed by installed LibreOffice and Poppler executables and are not available in browser WASM. See Universal document conversion.
@briank-dev/pptx2html-turbo is the legacy package name. It remains available with the same
API and release versions during migration.
Project
- Repository: https://github.com/brnyxx/pptx2html-turbo
- Issues: https://github.com/brnyxx/pptx2html-turbo/issues
- Demo: https://brnyxx.github.io/pptx2html-turbo/
- License: MIT
