将pdf转换为docx,而无需更改python3.x中的字体大小,粗体等

时间:2019-10-17 11:47:14

标签: pdf python-3.6 doc

我想在ubuntu16.x中使用python3.x将PDF转换为docx。我经历了下面给出的代码:

for top, dirs, files in os.walk(pdfdir):
  for filename in files:
    if filename.endswith('.pdf'):
        i = i + 1
        abspath_pdf = os.path.normpath(os.path.join(top, filename))

        print 'Converting {0} into .doc format..'.format(abspath_pdf)
        subprocess.call('{0} --invisible --convert-to doc{1} --outdir "{2}" "{3}"'
                        .format(lowriter, outfilter, docdir, abspath_pdf), shell=True)

但是它对我不起作用。有人可以帮忙吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用Aspose.Words Cloud将PDF转换为MS Word格式 https://products.aspose.cloud/words/python 您还应该注意,PDF格式是固定页面格式,MS Word格式是流格式。这使得从PDF到MS Word的转换非常困难。 Aspose.Words Cloud可以识别PDF中的元素,因此输出可以在MS Word中编辑。请参阅以下链接,以了解有关将PDF转换为Word https://docs.aspose.cloud/display/wordscloud/Convert+PDF+Document+to+Word

的更多信息