@diceui/pptx-core
v0.2.1
Published
PPTX engine for parsing, rendering, editing, and saving PowerPoint presentations in the browser.
Maintainers
Readme
@diceui/pptx-core
A PPTX engine for parsing, rendering, editing, and saving PowerPoint presentations in the browser.
Documentation
Visit pptx.diceui.com to view the full documentation.
Install
npm install @diceui/pptx-coreRender a slide
import { buildPresentation, readPptx, renderSlide } from "@diceui/pptx-core";
const files = await readPptx(arrayBuffer);
const presentation = buildPresentation(files);
const handle = renderSlide(presentation, presentation.slides[0]);
document.body.appendChild(handle.element);
// When done
handle.dispose();Full viewer
PptxViewer provides navigation, zoom, thumbnails, and text search out of the box:
import { PptxViewer } from "@diceui/pptx-core";
const viewer = new PptxViewer(container);
await viewer.load(arrayBuffer);
viewer.goTo(2);Edit and save
Load with keepSourcePackage: true to retain the source archive, then apply typed edit operations and write back a .pptx that round-trips everything the parser doesn't model (animations, comments, vendor extensions):
import { applyEdit, buildPresentation, readPptx, writePptx } from "@diceui/pptx-core";
const presentation = buildPresentation(await readPptx(buffer, { keepSourcePackage: true }));
const result = await applyEdit(presentation, {
type: "setTextRun",
slideId: presentation.slides[0].id,
nodeId: "2",
paragraphIndex: 0,
runIndex: 0,
text: "Hello",
});
// result.undo() restores the previous state
const bytes = await writePptx(presentation);Supported operations: setTextRun, setTextBody, setNodeTransform, setSolidFill, deleteNode, moveSlide, duplicateSlide, deleteSlide, and batch (multiple operations as one undoable step).
Embedded fonts
Font decoding (including MTX-compressed embedded fonts) lives in a separate entry point so it stays out of your bundle unless used:
import { decodeEmbeddedFont } from "@diceui/pptx-core/fonts";OOXML support
See OOXML-SUPPORT.md for a feature matrix against ECMA-376.
License
Apache-2.0. Portions derived from third-party projects; see NOTICE. Files under LICENSES/ carry their respective licenses (MPL-2.0 for the predefined table styles).
