【发布时间】:2018-02-14 09:40:27
【问题描述】:
我尝试用Libreoffice将pdf转为docx,我使用Convert PDF to DOC (Python/Bash) 提供的这个方法,代码如下:
import os
import subprocess
for top, dirs, files in os.walk('/my/pdf/folder'):
for filename in files:
if filename.endswith('.pdf'):
abspath = os.path.join(top, filename)
subprocess.call('lowriter --invisible --convert-to doc "{}"'
.format(abspath), shell=True)
但是,当我调试它时,我得到一个错误:
Error: source file could not be loaded
Error: no export filter for C:\Users\owner\desktop\docx\my.docx found, aborting.
Error: no export filter
我已经使用谷歌搜索了一段时间,但是没有任何适合我的问题的答案。所以我在这里寻求帮助。 非常感谢!
【问题讨论】:
-
代码上写着
--convert-to doc,但您正在转换为docx?看起来您没有发布实际使用的代码。另外,当您从命令行运行单个 lowriter 命令时是否会出现问题?也发布单个命令。 -
谢谢!实际上我已经尝试过
--convert-to doc和'--convert-to docx',我一定已经发布了'doc'的代码和'docx'的错误消息。我的错误!我可以确定不是这个问题。正如你所建议的,我尝试在命令行中运行“lowriter”命令。发生同样的错误!
标签: python pdf docx libreoffice