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

@fefeding/ppt-parser

v1.0.0

Published

PPTX文件解析与序列化核心库,纯TS编写,支持解析PPTX为JSON结构、JSON序列化为标准PPTX文件,无框架依赖

Readme

PPT-Parser

一个轻量级的 PPTX 解析与序列化库,让处理 PowerPoint 文件变得简单。

特性

  • 📦 简单易用 - 几行代码即可完成 PPTX 文件的解析和生成
  • 🔧 纯 TypeScript - 完整的类型定义,优秀的开发体验
  • 🎯 零框架依赖 - 可在任何 JavaScript/TypeScript 项目中使用
  • 📱 双向支持 - 支持 PPTX 文件 → JSON、JSON → PPTX 双向转换
  • 🎨 支持多种元素 - 文本、形状、表格、图片等常见元素
  • 🔄 智能转换 - 自动处理 EMU ↔ PX 单位转换
  • 📦 双格式输出 - 同时支持 ESM 和 CommonJS 模块

安装

npm install @fefeding/ppt-parser

或者直接下载 dist 目录下的文件使用。

快速开始

解析 PPTX 文件

import PptParserCore from '@fefeding/ppt-parser';

// 上传并解析 PPTX 文件
const fileInput = document.querySelector('#ppt-upload') as HTMLInputElement;

fileInput.addEventListener('change', async (e) => {
  const file = (e.target as HTMLInputElement).files?.[0];
  if (!file) return;

  const pptJson = await PptParserCore.parse(file);
  console.log(pptJson);
});

导出 PPTX 文件

import PptParserCore from '@fefeding/ppt-parser';

async function exportPptx(pptJson) {
  const pptBlob = await PptParserCore.serialize(pptJson);
  
  const url = URL.createObjectURL(pptBlob);
  const a = document.createElement('a');
  a.href = url;
  a.download = `${pptJson.title || 'presentation'}.pptx`;
  a.click();
  URL.revokeObjectURL(url);
}

使用工具函数

import PptParserCore from '@fefeding/ppt-parser';

const { utils } = PptParserCore;

// 像素转 EMU
const emu = utils.px2emu(100);

// EMU 转像素
const px = utils.emu2px(914400);

// 生成唯一 ID
const id = utils.generateId('slide');

数据结构

解析后的数据结构如下:

// 完整文档
{
  id: string;
  title: string;
  slides: Array<{
    id: string;
    title: string;
    bgColor: string;
    elements: Array<{
      id: string;
      type: 'text' | 'image' | 'shape' | 'table' | 'chart' | 'container' | 'media';
      rect: { x, y, width, height };
      style: { fontSize, color, textAlign, ... };
      content: any;
      props: object;
    }>;
  }>;
  props: { width, height, ratio };
}

使用场景

  • 📊 在线 PPT 编辑器
  • 📑 PPT 文件内容提取
  • 🔄 PPT 格式转换
  • 📤 PPT 报表导出
  • 🎨 PPT 模板生成

浏览器兼容性

  • Chrome ≥ 80
  • Firefox ≥ 75
  • Edge ≥ 80
  • Safari ≥ 14

Node.js 支持

const PptParserCore = require('@fefeding/ppt-parser');

// 解析本地文件
const fs = require('fs');
const pptJson = await PptParserCore.parse(fs.readFileSync('presentation.pptx'));

开发

# 克隆项目
git clone https://github.com/fefeding/pptx-parser.git

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建
npm run build

# 运行测试
npm test

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT License


Made with ❤️ for developers