@diceui/pptx-core

中文文档
0.4.0发布于 2026/11/06Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 9.9万

PPTX engine for parsing, rendering, editing, and saving PowerPoint presentations in the browser.

原始使用文档
文档目录8 节
  1. Documentation
  2. Install
  3. Render a slide
  4. Full viewer
  5. Edit and save
  6. Embedded fonts
  7. OOXML support
  8. License

@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-core

Render 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.open(arrayBuffer);
await viewer.goToSlide(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:

  • Text: setTextRun, setTextBody, setTextStyle, and setParagraphStyle
  • Shapes: setNodeTransform, setSolidFill, setOutline, deleteNode, duplicateNode, reorderNode, addTextBox, addShape, addImage, and pasteNodes (with copyNodes())
  • Slides: addSlide, moveSlide, duplicateSlide, deleteSlide, and setSlideBackground
  • batch: multiple operations as one undoable step

Edits that create slides or shapes report their ids in result.createdSlideId and result.createdNodeIds. For pickers, getPresentationFonts() lists the deck's fonts and getPresetShapePath() draws a preset shape as SVG path data.

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).

版本与发布记录

@diceui/pptx-core 共发布 9 个版本,首次发布于 2026/09/01;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.0latest2026/11/066 天前
0.3.02026/11/056 天前
0.2.12026/09/261 个月前
0.2.02026/09/102 个月前
0.1.42026/09/092 个月前
0.1.32026/09/032 个月前

关于 @diceui/pptx-core 的常见问题

@diceui/pptx-core 是什么?

PPTX engine for parsing, rendering, editing, and saving PowerPoint presentations in the browser.

如何安装 @diceui/pptx-core?

在项目目录运行 npm install @diceui/pptx-core,或使用 pnpm add / yarn add / bun add。

@diceui/pptx-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@diceui/pptx-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@diceui/pptx-core 可以商用吗?

@diceui/pptx-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@diceui/pptx-core 的下载量有多少?

根据 npm 官方下载统计,@diceui/pptx-core 在 2026/10/12 – 2026/11/10 这 30 天内被下载 99,285 次,日均约 3,310 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@diceui/pptx-core 还在维护吗?

最新版本 0.4.0 发布于 2026/11/06(6 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/09/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。