npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pptx-craft

v0.1.0

Published

Lightweight, type-safe library for creating PowerPoint (.pptx) files

Downloads

27

Readme

English | 中文

安装

npm install pptx-craft

快速开始

import { Presentation } from 'pptx-craft';

const pptx = new Presentation();
const slide = pptx.addSlide();

slide.addText('Hello World', {
  x: 1,
  y: 1,
  w: 8,
  h: 1.5,
  fontSize: 44,
  color: '003366',
  bold: true,
  align: 'center',
});

slide.addShape('rect', { x: 1, y: 3, w: 8, h: 0.05, fill: '4472C4' });

await pptx.toFile('output.pptx');

特性

  • 文本 — 字体、大小、颜色、粗体/斜体/下划线、对齐方式、行距
  • 图片 — 支持文件路径或 Buffer(PNG、JPEG 等)
  • 形状 — 矩形、椭圆、圆角矩形、菱形、三角形、心形、星形、箭头等
  • 表格 — 单元格级别格式化、边框、自定义列宽/行高
  • 图表 — 柱状图、条形图、折线图、饼图、面积图、散点图、环形图(原生 PowerPoint 图表)
  • 媒体 — 视频和音频嵌入
  • 母版与版式 — 自定义背景、基于占位符的版式布局
  • 主题 — 完整的配色方案和字体自定义
  • 演讲者备注 — 逐页添加备注
  • 插件 — 通过自定义元素类型进行扩展

预览

示例

表格

slide.addTable(
  [
    [
      { text: 'Name', options: { bold: true, fill: '4472C4', color: 'FFFFFF' } },
      { text: 'Score', options: { bold: true, fill: '4472C4', color: 'FFFFFF' } },
    ],
    [{ text: 'Alice' }, { text: '95' }],
    [{ text: 'Bob' }, { text: '87' }],
  ],
  { x: 1, y: 1, w: 6, h: 3, border: { color: 'CCCCCC', width: 1 } },
);

图表

slide.addChart(
  'col',
  {
    categories: ['Q1', 'Q2', 'Q3', 'Q4'],
    series: [
      { name: '2024', values: [120, 180, 150, 210], color: '4472C4' },
      { name: '2025', values: [140, 200, 190, 250], color: 'ED7D31' },
    ],
  },
  { x: 1, y: 1, w: 8, h: 5, title: 'Revenue', showLegend: true },
);

母版与版式

const pptx = new Presentation();
pptx.defineSlideMaster({ name: 'Corporate', background: '003366' });
pptx.defineLayout({
  name: 'Title Slide',
  type: 'titleAndContent',
  placeholders: [
    { type: 'title', placement: { x: 0.5, y: 0.5, w: 9, h: 1 }, idx: 0 },
    { type: 'body', placement: { x: 0.5, y: 2, w: 9, h: 5 }, idx: 1 },
  ],
});

const slide = pptx.addSlide('Title Slide');

插件

import type { IPlugin } from 'pptx-craft';

const myPlugin: IPlugin = {
  name: 'my-plugin',
  install(registry) {
    registry.registerElement('badge', badgeSerializer);
  },
};

pptx.use(myPlugin);

输出

// Buffer
const buffer = pptx.toBuffer();

// 文件
await pptx.toFile('presentation.pptx');

文档

完整文档请访问文档站点。本地运行:

npm run docs:dev

致谢

本项目基于 Brent Ely 的 PptxGenJS 衍生开发。

许可证

MIT — 详见 LICENSE