【前端】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树状目录展示

相关推荐
kyriewen116 小时前
你点的“刷新”是假刷新?前端路由的瞒天过海术
开发语言·前端·javascript·ecmascript·html5
skywalk81638 小时前
Kotti Next的tinyfrontend前端模仿Kotti 首页布局还是不太好看,感觉比Kotti差一点
前端
RopenYuan10 小时前
FastAPI -API Router的应用
前端·网络·python
走粥10 小时前
clsx和twMerge解决CSS类名冲突问题
前端·css
Purgatory00111 小时前
layui select重新渲染
前端·layui
weixin1997010801611 小时前
《中国供应商商品详情页前端性能优化实战》
前端·性能优化
赵孝正13 小时前
学习的本质是一个工程闭环:从模仿到内化的四阶段方法论(附风电实战案例)
前端·数据库·学习
Panzer_Jack15 小时前
easy-live2d v0.4.0 — 全面进化的 Live2D Web 开发体验
前端