Poi PPT PPTX 处理 [生产环境使用]

2020-08-27 21:19:07 +08:00
 RedBeanIce

poi 在 PPT 转成图片的时候,PPT 会有很多复杂的东西,导致解析困难

如以下复杂结构:

1,文本框套文本框套文本框,嵌套文字

2,文本框嵌套图片

等等。。。。

求助各位大佬,如何解析复杂的结构,让我可以将一页 PPT 转成图片

1605 次点击
所在节点    Java
11 条回复
PopRain
2020-08-27 21:47:28 +08:00
方向错了吧,你要去自己渲染 PPT? 这个难度太高了,换个方法吧
iseki
2020-08-27 21:48:53 +08:00
自己渲染 PPT 意味着你要把 Office 的很大一部分内容自己做一遍(换个办法吧
PopRain
2020-08-27 21:59:42 +08:00
stackoverflow 搜索 PPT to PNG conversion with Apache POI

发链接要手机号验证。。。。
RedBeanIce
2020-08-27 22:04:54 +08:00
@PopRain
@iseki
#1
#2
只是将 PPT 转成图片,只是在转的时候,poi 解析复杂结构,解不了。
图片上不会显示,
PopRain
2020-08-27 22:11:40 +08:00
那是不是需要用 Spire 之类的商业 SDK 了,可以用试用版先试试
340244120w
2020-08-28 09:16:20 +08:00
推荐 aspose 系列
519718366
2020-08-28 10:23:54 +08:00
http://poi.apache.org/slideshow/how-to-shapes.html#Render

HSLF provides a way to export slides into images. You can capture slides into java.awt.Graphics2D object (or any other) and serialize it into a PNG or JPEG format. Please note, although HSLF attempts to render slides as close to PowerPoint as possible, the output may look differently from PowerPoint due to the following reasons:

- Java2D renders fonts differently vs PowerPoint. There are always some differences in the way the font glyphs are painted
- HSLF uses java.awt.font.LineBreakMeasurer to break text into lines. PowerPoint may do it in a different way.
- If a font from the presentation is not available, then the JDK default font will be used.

Current Limitations:
- Some types of shapes are not yet supported (WordArt, complex auto-shapes)
- Only Bitmap images (PNG, JPEG, DIB) can be rendered in Java

或许是真的不能支持这些复杂的妖魔鬼怪 PPT 吧。
DsuineGP
2020-08-28 10:31:01 +08:00
前几天还在调研 libreoffice 的 cli,一条命令就能转,还开源,强烈推荐。poi 不适合做 ppt 和 word 解析,因为渲染逻辑太复杂了。楼上说的 aspose 也还行。
RedBeanIce
2020-08-28 10:36:58 +08:00
@PopRain
我先去试试免费的,哭。
RedBeanIce
2020-08-28 10:38:22 +08:00
@340244120w #6
!!!我去试试,都可以试验!!
@519718366 #7
@DsuineGP #8
收到,,看来我只能尝试多种方案了,,一样样试过去,看哪种能够解决我这个问题。自己写不现实了。
RedBeanIce
2020-08-28 14:32:39 +08:00
@DsuineGP

#8 尝试了一下 LibreOffice_6.4.6_Win_x64 命令行,Windows 下 会出现字是横着的,但是变成了竖着的。尴尬

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/702029

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX