DOCX zu PDF mit Pandoc in PythonPython

Python-Programme
Anonymous
 DOCX zu PDF mit Pandoc in Python

Post by Anonymous »

Ich bin also ein ziemlich neu in Python, also kann es eine alberne Frage sein, aber ich kann die Lösung nirgendwo finden. Ich möchte Pandoc dazu verwenden. Ich weiß, dass es andere Methoden wie Online -APIs oder die Python -Module wie "docx2pdf" gibt. Ich möchte jedoch aus Bereitstellungsgründen Pandoc verwenden.

Code: Select all

import pypandoc
import docx

def making_a_doc_function(request):
doc = docx.Document()
doc.add_heading("MY DOCUMENT")
doc.save('thisisdoc.docx')
pypandoc.convert_file('thisisdoc.docx', 'docx', outputfile="thisisdoc.pdf")
pdf = open('thisisdoc.pdf', 'rb')
response = FileResponse(pdf)
return response
Die Datei docx Erstellt kein Problem, aber es wurde nicht PDF erstellt. Ich erhalte einen Fehler mit der Aufschrift: < /p>

Code: Select all

Pandoc died with exitcode "4" during conversion: b'cannot produce pdf output from docx\n'

Hat jemand irgendwelche Ideen?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post