需求是这样的,转成有一定格式的 text (保留换行,空格等)
docx 转 text 基本搞定,因为 docx 其实是一个 zip,里面是文本格式的 xml,然后用了 html 转 text 的方式,转出来可以接受。
但是 doc 转 text 开始用的 antiword 但是有些文件转不了,想问下大家有什么好的方案吗?
需求是这样的,转成有一定格式的 text (保留换行,空格等)
docx 转 text 基本搞定,因为 docx 其实是一个 zip,里面是文本格式的 xml,然后用了 html 转 text 的方式,转出来可以接受。
但是 doc 转 text 开始用的 antiword 但是有些文件转不了,想问下大家有什么好的方案吗?
|
hinomoAug 11, 2018
1
doc 转 docx (逃
|
|
ghhardyAug 11, 2018 via Android
2
试试 python 第三方模块吧,我用过处理 excel 表格的,word 好像也有
|
|
hundanAug 11, 2018 via Android
3
直接另存为?
|
|
lihongjie0209Aug 11, 2018
4
Java 可以用 tika, Python 就不知道了. 从某种程度上来说, Java 的生态确实比 Python 好
|
|
dsp2138Aug 11, 2018
5
word:Ctrl+A
notebook:Ctrl+V 搞定,效率很高 |
|
7
@lihongjie0209 我先研究下,谢谢
|
|
8
@longyujin9 也是一种思路 :)
|
|
zjsxwcAug 11, 2018
9
这种东西 C#干起来很轻松,不知道 linux 下的 dotnet core 可不可以
|
|
zjsxwcAug 11, 2018
10
|
|
11
可以试试 pandoc
|
|
MonoLogueChiAug 11, 2018 via Android
12
修正一下,docx 是 rar 压缩包
|
|
lushilu001Aug 11, 2018 via iPhone
13
catdoc
|
|
hundanAug 11, 2018 via Android
14
@MonoLogueChi 再修正一下,是 zip。
rar 文件头以 Rar 开头 zip 为 pk,docx 文件头是 pk,这是其一,其二,rar 算法为私有。拓展名改为 rar 之后能打开是因为压缩软件自己识别了压缩算法,不能作为根据。建议你自己了解清楚再来修正别人。 |
|
drackzyAug 11, 2018
15
unoconv
|
|
cnkillerAug 11, 2018 via Android
16
我给楼主说一下吧。com 方式另存为 txt,效果最好
|
|
iwtbauhAug 11, 2018 via Android
18
soffice --headless --convert-to txt filename.doc
|
|
gnaggnoyilAug 12, 2018
19
|
|
gamecmtAug 12, 2018 via Android
20
windows 下可以用 pywin32com。
|
|
PythonAnswerAug 12, 2018 via iPhone
21
com 是个好东西。linux 下一班怎么玩?有类似的吗?
|
|
omphAug 12, 2018
22
Apache POI - the Java API for Microsoft Documents
|
|
shilyxAug 12, 2018
23
poi 读取-》另存为
不过更高级的方案是在 widnows 服务器上安装 office,然后 vc 中使用 activex 控制另存为,完美,绝对完美的 doc-》 docx |
|
ps1aniugeAug 12, 2018
24
安装 word。用 powershell 调用 com 方式另存为 txt,效果最好
|
|
gnaggnoyilAug 12, 2018
25
@PythonAnswer LibreOffice 据说有个叫 UNO 的东西和.COM 比较类似,具体怎么用不清楚,你可以自己查查看……
|
|
PythonAnswerAug 12, 2018 via iPhone
26
uno 是包装的 java,调用起来不太爽
|
|
DoodlisterAug 28, 2018 via Android
27
@longyujin9 纯文本的话。。 直接 OCR。。。比你这个还暴力 哈哈
|