Converting docx to pdf with pure python (on linux, without libreoffice)

前端 未结 2 1734
醉酒成梦
醉酒成梦 2020-12-15 20:27

I\'m dealing with a problem trying to develop a web-app, part of which converts uploaded docx files to pdf files (after some processing). With python-docx and o

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 21:33

    The PythonAnywhere help pages offer information on working with PDF files here: https://help.pythonanywhere.com/pages/PDF

    Summary: PythonAnywhere has a number of Python packages for PDF manipulation installed, and one of them may do what you want. However, shelling out to abiword seems easiest to me. The shell command abiword --to=pdf filetoconvert.docx will convert the docx file to a PDF and produce a file named filetoconvert.pdf in the same directory as the docx. Note that this command will output an error message to the standard error stream complaining about XDG_RUNTIME_DIR (or at least it did for me), but it still works, and the error message can be ignored.

提交回复
热议问题