Convert PDF to DOC (Python/Bash)

后端 未结 4 723
傲寒
傲寒 2020-12-01 05:46

I\'ve saw some pages that allow user to upload PDF and returns a DOC file, like PdfToWord

Is there any way to convert a P

4条回答
  •  囚心锁ツ
    2020-12-01 06:35

    If you have LibreOffice installed

    lowriter --invisible --convert-to doc '/your/file.pdf'
    

    If you want to use Python for this:

    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)
    

提交回复
热议问题