【前端】ikun-pptx编辑器前瞻问题三: pptx的图片如何提取,并在前端渲染。

文章目录

pptx中的图片提取的一般步骤

以第一页幻灯片为例,需要下列步骤:

  1. 在slide1.xml中找到图片ID
  2. 在 slide1.xml.rels 中找到第一页幻灯片的所有映射关系(rid -> 文件)
  3. 整理出映射集合 map<rid: 文件路径>。
  4. 根据id读取文件流, 转换为base64编码
  5. 在<img标签中通过base64渲染出图片。

可以看出这个步骤其实挺复杂了,cursor已经乱写代码导致图片提取不正确, 所以自己慢慢修正吧。

rel 映射关系例子

xml 复制代码
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout1.xml"/>
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image3.png"/>
<Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image4.png"/>
<Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/image2.png"/>
</Relationships>

图片在幻灯片中的引用形式

pptx树状目录展示

相关推荐
云水一下6 小时前
TypeScript 从零基础到精通(五):高级类型与泛型
前端·javascript·typescript
counterxing6 小时前
vibe coding 之后,我更不想打字了
前端·agent·ai编程
copyer_xyf6 小时前
Python 模块与包的导入导出
前端·后端·python
研☆香6 小时前
es6新特性功能介绍(四)
前端·ecmascript·es6
微扬嘴角7 小时前
React篇1--JSX语法规则、组件、组件实例的3大特性
前端·react.js·前端框架
copyer_xyf7 小时前
Python venv 虚拟环境
前端·后端·python
无聊的老谢7 小时前
Vue 3 + TypeScript 构建大型电信运维平台的前端架构设计
前端·vue.js·typescript
xiaofeichaichai7 小时前
Map / Set / WeakMap / WeakSet
前端·javascript
李可以量化7 小时前
成交量的终极量化策略:价量共振指标完整实现(下篇)
前端·数据库·人工智能
copyer_xyf8 小时前
Python 如何同时做很多事:进程、线程、协程
前端·后端·python