{"id":20291612,"url":"https://github.com/pipipi-pikachu/pptxtojson","last_synced_at":"2025-05-15T14:04:08.069Z","repository":{"id":52273765,"uuid":"479422604","full_name":"pipipi-pikachu/pptxtojson","owner":"pipipi-pikachu","description":"Office PowerPoint(.pptx) file to JSON | 将 PPTX 文件转为可读的 JSON 数据","archived":false,"fork":false,"pushed_at":"2025-04-12T12:06:05.000Z","size":12220,"stargazers_count":267,"open_issues_count":11,"forks_count":67,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-15T07:22:42.505Z","etag":null,"topics":["json","parse","parser","powerpoint","ppt","ppt2json","ppttojson","pptx","pptx2json","pptxtojson"],"latest_commit_sha":null,"homepage":"https://pipipi-pikachu.github.io/pptxtojson/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pipipi-pikachu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-08T14:28:10.000Z","updated_at":"2025-05-14T06:14:35.000Z","dependencies_parsed_at":"2024-02-22T14:30:21.790Z","dependency_job_id":"b814c689-7666-4a29-8a89-667c0c4f1715","html_url":"https://github.com/pipipi-pikachu/pptxtojson","commit_stats":null,"previous_names":["pipipi-pikachu/pptxtojson"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pipipi-pikachu%2Fpptxtojson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pipipi-pikachu%2Fpptxtojson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pipipi-pikachu%2Fpptxtojson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pipipi-pikachu%2Fpptxtojson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pipipi-pikachu","download_url":"https://codeload.github.com/pipipi-pikachu/pptxtojson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254355333,"owners_count":22057354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","parse","parser","powerpoint","ppt","ppt2json","ppttojson","pptx","pptx2json","pptxtojson"],"created_at":"2024-11-14T15:13:09.999Z","updated_at":"2025-05-15T14:04:08.062Z","avatar_url":"https://github.com/pipipi-pikachu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎨 pptxtojson\n一个运行在浏览器中，可以将 .pptx 文件转为可读的 JSON 数据的 JavaScript 库。\n\n\u003e 与其他的pptx文件解析工具的最大区别在于：\n\u003e 1. 直接运行在浏览器端；\n\u003e 2. 解析结果是**可读**的 JSON 数据，而不仅仅是把 XML 文件内容原样翻译成难以理解的 JSON。\n\n在线DEMO：https://pipipi-pikachu.github.io/pptxtojson/\n\n# 🎯 注意事项\n### ⚒️ 使用场景\n本仓库诞生于项目 [PPTist](https://github.com/pipipi-pikachu/PPTist) ，希望为其“导入 .pptx 文件功能”提供一个参考示例。不过就目前来说，解析出来的PPT信息与源文件在样式上还是存在差距，还不足以直接运用到生产环境中。\n\n但如果你只是需要提取PPT文件的文本内容、媒体资源信息、结构信息等，对排版/样式精准度没有特别高的要求，那么 pptxtojson 可能会对你有帮助。\n\n### 📏 长度值单位\n输出的JSON中，所有数值长度值单位都为`pt`（point）\n\u003e 注意：在0.x版本中，所有输出的长度值单位都是px（像素）\n\n# 🔨安装\n```\nnpm install pptxtojson\n```\n\n# 💿用法\n```html\n\u003cinput type=\"file\" accept=\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"/\u003e\n```\n\n```javascript\nimport { parse } from 'pptxtojson'\n\ndocument.querySelector('input').addEventListener('change', evt =\u003e {\n\tconst file = evt.target.files[0]\n\t\n\tconst reader = new FileReader()\n\treader.onload = async e =\u003e {\n\t\tconst json = await parse(e.target.result)\n\t\tconsole.log(json)\n\t}\n\treader.readAsArrayBuffer(file)\n})\n```\n\n```javascript\n// 输出示例\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\": \"\u003cp style=\\\"text-align: center;\\\"\u003e\u003cspan style=\\\"font-size: 18pt;font-family: Calibri;\\\"\u003eTEST\u003c/span\u003e\u003c/p\u003e\",\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# 📕 完整功能支持\n\n### 幻灯片主题色 `themeColors`\n\n### 幻灯片尺寸 `size`\n- 幻灯片宽度 `width`\n- 幻灯片高度 `height`\n\n### 幻灯片页面 `slides`\n#### 页面背景填充（颜色、图片、渐变） `fill`\n\n#### 页面备注 `note`\n\n#### 页面内元素 `elements` / 母版元素 `layoutElements`\n##### 文字\n- 类型 `type='text'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 边框颜色 `borderColor`\n- 边框宽度 `borderWidth`\n- 边框类型（实线、点线、虚线） `borderType`\n- 非实线边框样式 `borderStrokeDasharray`\n- 阴影 `shadow`\n- 填充（颜色、图片、渐变） `fill`\n- 内容文字（HTML富文本） `content`\n- 垂直翻转 `isFlipV`\n- 水平翻转 `isFlipH`\n- 旋转角度 `rotate`\n- 垂直对齐方向 `vAlign`\n- 是否为竖向文本 `isVertical`\n- 元素名 `name`\n\n##### 图片\n- 类型 `type='image'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 边框颜色 `borderColor`\n- 边框宽度 `borderWidth`\n- 边框类型（实线、点线、虚线） `borderType`\n- 非实线边框样式 `borderStrokeDasharray`\n- 裁剪形状 `geom`\n- 裁剪范围 `rect`\n- 图片地址（base64） `src`\n- 旋转角度 `rotate`\n\n##### 形状\n- 类型 `type='shape'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 边框颜色 `borderColor`\n- 边框宽度 `borderWidth`\n- 边框类型（实线、点线、虚线） `borderType`\n- 非实线边框样式 `borderStrokeDasharray`\n- 阴影 `shadow`\n- 填充（颜色、图片、渐变） `fill`\n- 内容文字（HTML富文本） `content`\n- 垂直翻转 `isFlipV`\n- 水平翻转 `isFlipH`\n- 旋转角度 `rotate`\n- 形状类型 `shapType`\n- 垂直对齐方向 `vAlign`\n- 路径（自定义形状） `path`\n- 元素名 `name`\n\n##### 表格\n- 类型 `type='table'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 边框（4边） `borders`\n- 表格数据 `data`\n- 行高 `rowHeights`\n- 列宽 `colWidths`\n\n##### 图表\n- 类型 `type='chart'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 图表数据 `data`\n- 图表主题色 `colors`\n- 图表类型 `chartType`\n- 柱状图方向 `barDir`\n- 是否带数据标记 `marker`\n- 环形图尺寸 `holeSize`\n- 分组模式 `grouping`\n- 图表样式 `style`\n\n##### 视频\n- 类型 `type='video'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 视频blob `blob`\n- 视频src `src`\n\n##### 音频\n- 类型 `type='audio'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 音频blob `blob`\n\n##### 公式\n- 类型 `type='math'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 公式图片 `picBase64`\n- LaTeX表达式（仅支持常见结构） `latex`\n\n##### Smart图\n- 类型 `type='diagram'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 子元素集合 `elements`\n\n##### 多元素组合\n- 类型 `type='group'`\n- 水平坐标 `left`\n- 垂直坐标 `top`\n- 宽度 `width`\n- 高度 `height`\n- 子元素集合 `elements`\n\n### 更多类型请参考 👇\n[https://github.com/pipipi-pikachu/pptxtojson/blob/master/dist/index.d.ts](https://github.com/pipipi-pikachu/pptxtojson/blob/master/dist/index.d.ts)\n\n# 🙏 感谢\n本仓库大量参考了 [PPTX2HTML](https://github.com/g21589/PPTX2HTML) 和 [PPTXjs](https://github.com/meshesha/PPTXjs) 的实现。\n\u003e 与它们不同的是：PPTX2HTML 和 PPTXjs 是将PPT文件转换为能够运行的 HTML 页面，而 pptxtojson 做的是将PPT文件转换为干净的 JSON 数据，且在原有基础上进行了大量优化（包括代码质量和提取信息准确度）。\n\n# 📄 开源协议\nMIT License | Copyright © 2020-PRESENT [pipipi-pikachu](https://github.com/pipipi-pikachu)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpipipi-pikachu%2Fpptxtojson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpipipi-pikachu%2Fpptxtojson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpipipi-pikachu%2Fpptxtojson/lists"}