{"_id":"@agilehub/agile-pptxtojson","name":"@agilehub/agile-pptxtojson","dist-tags":{"latest":"2.0.3"},"versions":{"2.0.3":{"name":"@agilehub/agile-pptxtojson","version":"2.0.3","description":"A javascript tool for parsing .pptx file","type":"module","main":"./dist/index.umd.js","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean:dist":"rimraf dist","dev":"rollup -c -w","lint":"eslint src --ext .js,.jsx,.ts,.tsx"},"author":{"name":"lytdev@outlook.com"},"repository":{"type":"git","url":"https://cnb.cool/p4u/agilehub.com/agile-pptxtojson"},"keywords":["ppt","pptx","json"],"homepage":"https://cnb.cool/p4u/agilehub.com/agile-pptxtojson","license":"MIT","publishConfig":{"access":"public","registry":"https://registry.npmjs.org"},"dependencies":{"jszip":"^3.10.1","tinycolor2":"1.6.0","txml":"^5.1.1"},"devDependencies":{"@babel/core":"^7.20.2","@babel/plugin-transform-runtime":"^7.19.6","@babel/preset-env":"^7.20.2","@babel/runtime":"^7.20.1","@rollup/plugin-babel":"^6.0.2","@rollup/plugin-commonjs":"^23.0.2","@rollup/plugin-eslint":"^9.0.1","@rollup/plugin-node-resolve":"^15.0.1","@rollup/plugin-terser":"^0.1.0","eslint":"^8.27.0","rollup":"^3.3.0","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-node-globals":"^1.4.0"},"gitHead":"bcca07ae2285c52dfe79b80046df5236656b9921","_id":"@agilehub/agile-pptxtojson@2.0.3","_nodeVersion":"24.11.1","_npmVersion":"11.6.4","dist":{"integrity":"sha512-sb8obB9TPsWvEw+Ju8kJIqPDHFSeBZv1en6jpuXr0cW6dx4w8gQhkpxeYoo1m+FSKuuM4UlMOPfDdLv38M3zmA==","shasum":"a3b692cc7b1ac499ec6974a923d87141a2ecc11b","tarball":"https://registry.npmjs.org/@agilehub/agile-pptxtojson/-/agile-pptxtojson-2.0.3.tgz","fileCount":12,"unpackedSize":6520993,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCkXjt0evyAnAHp1IPzPuP9YVfQQ4MvSw54SZa1CE4z4wIgSsTVuNj1a84G3HUWa31gfDEddOOua1bX7sD3QI6nefM="}]},"_npmUser":{"name":"liuyuantao","email":"lytdev@outlook.com"},"directories":{},"maintainers":[{"name":"liuyuantao","email":"lytdev@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/agile-pptxtojson_2.0.3_1779863254931_0.4697414181921411"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-27T06:27:34.751Z","2.0.3":"2026-05-27T06:27:35.191Z","modified":"2026-05-27T06:27:35.387Z"},"maintainers":[{"name":"liuyuantao","email":"lytdev@outlook.com"}],"description":"A javascript tool for parsing .pptx file","homepage":"https://cnb.cool/p4u/agilehub.com/agile-pptxtojson","keywords":["ppt","pptx","json"],"repository":{"type":"git","url":"https://cnb.cool/p4u/agilehub.com/agile-pptxtojson"},"author":{"name":"lytdev@outlook.com"},"license":"MIT","readme":"﻿# 🎨 agile-pptxtojson\n\n\n一个运行在浏览器中，可以将 .pptx 文件转为可读的 JSON 数据的 JavaScript 库。\n\n> 与其他的pptx文件解析工具的最大区别在于：\n> 1. 直接运行在浏览器端；\n> 2. 解析结果是**可读**的 JSON 数据，而不仅仅是把 XML 文件内容原样翻译成难以理解的 JSON。\n\n\n> 国内镜像（定期同步）：[Gitee](https://gitee.com/pptist/pptxtojson)、[GitCode](https://gitcode.com/pipipi-pikachu/pptxtojson)\n\n# 🎯 注意事项\n### ⚒️ 使用场景\n本仓库诞生于项目 [pipipi-pikachu](https://www.github.com/pipipi-pikachu/pptxtojson) ，再次基础上进行了优化和完善。\n\n最新同步于[Commits on May 22, 2026 600879b4fa720da64d32c57f6d0986addb56854b](https://github.com/pipipi-pikachu/pptxtojson/commit/600879b4fa720da64d32c57f6d0986addb56854b)\n\n但如果你只是需要提取PPT文件的文本内容、媒体资源信息、结构信息等，或者对排版/样式精准度没有特别高的要求，那么 pptxtojson 可能会对你有帮助。\n\n### 📏 长度值单位\n输出的JSON中，所有数值长度值单位都为`pt`（point）\n\n# 🔨安装\n```\nnpm install pptxtojson\n```\n\n# 💿用法\n```javascript\nparse(file, options = {})\n```\n\n### 浏览器示例\n```html\n<input type=\"file\" accept=\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"/>\n```\n\n```javascript\nimport { parse } from 'pptxtojson'\n\ndocument.querySelector('input').addEventListener('change', evt => {\n\tconst file = evt.target.files[0]\n\t\n\tconst reader = new FileReader()\n\treader.onload = async e => {\n\t\tconst json = await parse(e.target.result, {\n\t\t\timageMode: 'base64',\n\t\t\tvideoMode: 'none',\n\t\t\taudioMode: 'none',\n\t\t})\n\t\tconsole.log(json)\n\t}\n\treader.readAsArrayBuffer(file)\n})\n```\n\n### Node.js 示例（实验性，1.5.0以上版本）\n```javascript\nconst pptxtojson = require('pptxtojson/dist/index.cjs')\nconst fs = require('fs')\n\nconst uploadToOss = (fileBlob, videoFileExt) => {\n\treturn new Promise((resolve, reject) => {\n\tresolve({\n\t\turl: 'https://a.b.c/pptx2json/test.' + videoFileExt,\n\t\tfileSize: fileBlob.size\n\t})\n\t})\n}\n\nasync function func() {\n  const buffer = fs.readFileSync('test.pptx')\n\n  const json = await pptxtojson.parse(buffer.buffer, {\n    imageMode: 'upload',\n    videoMode: 'none',\n    audioMode: 'none',\n    uploadFun: uploadToOss,\n  })\n  console.log(json)\n}\n\nfunc()\n```\n\n### 输出示例\n```javascript\n{\n\t\"slides\": [\n\t\t{\n\t\t\t\"fill\": {\n\t\t\t\t\"type\": \"color\",\n\t\t\t\t\"value\": \"#FF0000\"\n\t\t\t},\n\t\t\t\"elements\": [\n\t\t\t\t{\n\t\t\t\t\t\"left\":\t0,\n\t\t\t\t\t\"top\": 0,\n\t\t\t\t\t\"width\": 72,\n\t\t\t\t\t\"height\":\t72,\n\t\t\t\t\t\"borderColor\": \"#1F4E79\",\n\t\t\t\t\t\"borderWidth\": 1,\n\t\t\t\t\t\"borderType\": \"solid\",\n\t\t\t\t\t\"borderStrokeDasharray\": 0,\n\t\t\t\t\t\"fill\": {\n\t\t\t\t\t\t\"type\": \"color\",\n\t\t\t\t\t\t\"value\": \"#FF0000\"\n\t\t\t\t\t},\n\t\t\t\t\t\"content\": \"<p style=\\\"text-align: center;\\\"><span style=\\\"font-size: 18pt;font-family: Calibri;\\\">TEST</span></p>\",\n\t\t\t\t\t\"isFlipV\": false,\n\t\t\t\t\t\"isFlipH\": false,\n\t\t\t\t\t\"rotate\": 0,\n\t\t\t\t\t\"vAlign\": \"mid\",\n\t\t\t\t\t\"name\": \"矩形 1\",\n\t\t\t\t\t\"type\": \"shape\",\n\t\t\t\t\t\"shapType\": \"rect\"\n\t\t\t\t},\n\t\t\t\t// more...\n\t\t\t],\n\t\t\t\"layoutElements\": [\n\t\t\t\t// more...\n\t\t\t],\n\t\t\t\"note\": \"演讲者备注内容...\"\n\t\t},\n\t\t// more...\n\t],\n\t\"themeColors\": ['#4472C4', '#ED7D31', '#A5A5A5', '#FFC000', '#5B9BD5', '#70AD47'],\n\t\"size\": {\n\t\t\"width\": 960,\n\t\t\"height\": 540\n\t}\n}\n```\n\n# 🎲 Options 配置说明\n> options 为可选参数，不传时使用默认配置。\n\n- `imageMode`：控制图片资源的解析方式，可选值为 `base64`、`blob`、`both`、`none`、`upload`，默认值为 `base64`。如果使用`upload`，需要传入`uploadFun`回调函数。\n\t- `base64` 表示仅解析 `base64`。\n\t- `blob` 表示仅解析 `blob`。\n\t- `both` 表示同时解析 `base64` 和 `blob`。\n\t- `none` 表示不解析图片内容。\n\t- `upload` 表示图片按照指定的方法进行上传。\n\n- `videoMode`：控制视频资源的解析方式，可选值为 `blob`、`none`、`upload`，默认值为 `none`。如果使用`upload`，需要传入`uploadFun`回调函数。\n  - `blob` 表示解析视频 `blob`。\n  - `none` 表示不解析视频内容。\n  - `upload` 表示视频按照指定的方法进行上传。\n\n- `audioMode`：控制音频资源的解析方式，可选值为 `blob`、`none`、`upload`，默认值为 `none`。如果使用`upload`，需要传入`uploadFun`回调函数。\n  - `blob` 表示解析音频 `blob`。\n  - `none` 表示不解析音频内容。\n  - `upload` 表示音频按照指定的方法进行上传。\n\n# 🕰️ 旧版本说明\n- 在0.x版本中，所有输出的长度值单位都是px（像素）\n- 在1.x及以下版本：\n\t- 图片元素使用 `src` 字段返回 base64 数据；\n\t- 图片填充仅返回 `picBase64`；\n\t- 视频元素可能返回 `blob` 或 `src`；\n\t- 音频元素仅返回 `blob`；\n\t- 公式图片仅返回 `picBase64`；\n\n# 📕 解析属性\n\n- 幻灯片主题色 `themeColors`\n\n- 内置字体清单 `usedFonts`\n\n- 幻灯片尺寸 `size`\n\t- 宽度 `width`\n\t- 高度 `height`\n\n- 幻灯片页面 `slides`\n\n\t- 页面备注 `note`\n\n\t- 页面背景填充（颜色、图片、渐变、图案） `fill`\n\t\t- 纯色填充 `type='color'`\n\t\t- 图片填充 `type='image'`\n\t\t- 渐变填充 `type='gradient'`\n\t\t- 图案填充 `type='pattern'`\n\n\t- 页面切换动画 `transition`\n\t\t- 类型 `type`\n\t\t- 持续时间 `duration`\n\t\t- 方向 `direction`\n\n\t- 页面内元素 `elements` / 母版元素 `layoutElements`\n\t\t- 文字\n\t\t\t- 类型 `type='text'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 边框颜色 `borderColor`\n\t\t\t- 边框宽度 `borderWidth`\n\t\t\t- 边框类型（实线、点线、虚线） `borderType`\n\t\t\t- 非实线边框样式 `borderStrokeDasharray`\n\t\t\t- 阴影 `shadow`\n\t\t\t- 填充（颜色、图片、渐变、图案） `fill`\n\t\t\t- 内容文字（HTML富文本） `content`：\n\t\t\t\t- 行内样式/结构：字体、字号、颜色、渐变、下划线、删除线、斜体、加粗、字间距、阴影、角标、超链接\n\t\t\t\t- 块级样式/结构：水平对齐、行距、段间距、缩进、首行缩进、项目符号、编号列表\n\t\t\t- 垂直翻转 `isFlipV`\n\t\t\t- 水平翻转 `isFlipH`\n\t\t\t- 旋转角度 `rotate`\n\t\t\t- 垂直对齐方向 `vAlign`\n\t\t\t- 是否为竖向文本 `isVertical`\n\t\t\t- 元素名 `name`\n\t\t\t- 自动调整大小 `autoFit`\n\t\t\t\t- 类型 `type`\n\t\t\t\t\t- `shape`：文本框高度会根据文本内容自动调整\n\t\t\t\t\t- `text`：文本框大小固定，字号会自动缩放以适应文本框（注：autoFit不存在时，也会固定文本框大小，但字号不会缩放）\n\t\t\t\t- 字体缩放比例（type='text'专有，默认为1） `fontScale`\n\t\t\t- 文本内边距（4边） `textInset`\n\t\t\t- 超链接 `link`\n\n\t\t- 图片\n\t\t\t- 类型 `type='image'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 边框颜色 `borderColor`\n\t\t\t- 边框宽度 `borderWidth`\n\t\t\t- 边框类型（实线、点线、虚线） `borderType`\n\t\t\t- 非实线边框样式 `borderStrokeDasharray`\n\t\t\t- 裁剪形状 `geom`\n\t\t\t- 裁剪范围 `rect`\n\t\t\t- 资源引用路径 `ref`\n\t\t\t- 图片base64 `base64`\n\t\t\t- 图片blob `blob`\n\t\t\t- 旋转角度 `rotate`\n\t\t\t- 滤镜 `filters`\n\t\t\t- 超链接 `link`\n\n\t\t- 形状\n\t\t\t- 类型 `type='shape'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 边框颜色 `borderColor`\n\t\t\t- 边框宽度 `borderWidth`\n\t\t\t- 边框类型（实线、点线、虚线） `borderType`\n\t\t\t- 非实线边框样式 `borderStrokeDasharray`\n\t\t\t- 阴影 `shadow`\n\t\t\t- 填充（颜色、图片、渐变、图案） `fill`\n\t\t\t- 内容文字（HTML富文本，与文字元素一致） `content`\n\t\t\t- 垂直翻转 `isFlipV`\n\t\t\t- 水平翻转 `isFlipH`\n\t\t\t- 旋转角度 `rotate`\n\t\t\t- 形状类型 `shapType`\n\t\t\t- 垂直对齐方向 `vAlign`\n\t\t\t- 形状路径 `path`\n\t\t\t- 形状调整参数 `keypoints`\n\t\t\t- 元素名 `name`\n\t\t\t- 自动调整大小 `autoFit`\n\t\t\t- 文本内边距（4边） `textInset`\n\t\t\t- 超链接 `link`\n\n\t\t- 表格\n\t\t\t- 类型 `type='table'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 边框（4边） `borders`\n\t\t\t- 单元格样式与数据 `data`\n\t\t\t- 行高 `rowHeights`\n\t\t\t- 列宽 `colWidths`\n\n\t\t- 图表\n\t\t\t- 类型 `type='chart'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 图表数据 `data`\n\t\t\t- 图表主题色 `colors`\n\t\t\t- 图表类型 `chartType`\n\t\t\t- 柱状图方向 `barDir`\n\t\t\t- 是否带数据标记 `marker`\n\t\t\t- 环形图尺寸 `holeSize`\n\t\t\t- 分组模式 `grouping`\n\t\t\t- 图表样式 `style`\n\n\t\t- 视频\n\t\t\t- 类型 `type='video'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 资源引用路径 `ref`\n\t\t\t- 视频blob `blob`\n\n\t\t- 音频\n\t\t\t- 类型 `type='audio'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 资源引用路径 `ref`\n\t\t\t- 音频blob `blob`\n\n\t\t- 公式\n\t\t\t- 类型 `type='math'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 公式图片引用路径 `picRef`\n\t\t\t- 公式图片base64 `picBase64`\n\t\t\t- 公式图片blob `picBlob`\n\t\t\t- LaTeX表达式（仅支持常见结构） `latex`\n\t\t\t- 文本（文本和公式混排时存在） `text`\n\n\t\t- Smart图\n\t\t\t- 类型 `type='diagram'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 子元素集合 `elements`\n\t\t\t- 文本列表（Smart图中的文字内容清单） `textList`\n\n\t\t- 多元素组合\n\t\t\t- 类型 `type='group'`\n\t\t\t- 水平坐标 `left`\n\t\t\t- 垂直坐标 `top`\n\t\t\t- 宽度 `width`\n\t\t\t- 高度 `height`\n\t\t\t- 子元素集合 `elements`\n\n### 更详细类型请参考 👇\n[https://github.com/pipipi-pikachu/pptxtojson/blob/master/dist/index.d.ts](https://cnb.cool/p4u/agilehub.com/agile-pptxtojson/-/blob/master/dist/index.d.ts)\n\n# 🙏 感谢\n本仓库大量参考了 [PPTX2HTML](https://github.com/g21589/PPTX2HTML) 和 [PPTXjs](https://github.com/meshesha/PPTXjs) 的实现。\n> 与它们不同的是：pptxtojson 不是将PPT文件转换为 HTML 页面，而是转换为干净、易读的 JSON 数据，且在原有基础上进行了大量优化补充，大幅提升了提取信息的完整度和准确度。\n\n# 📄 开源协议\nMIT License | Copyright © 2026-PRESENT [agile-pptxtojson](https://cnb.cool/p4u/agilehub.com/agile-pptxtojson)\n","readmeFilename":"README.md","_rev":"1-6daca4d7f4facd0840e3517e0a211cba"}