Reputation: 227
On my Django site I have a button that will create a word document and covert it into pdf file to show it to the user in a new window. Now this is done by reading a word document using docx
and then docx2pdf
to make the conversation.
My problem is that when I launch it on Heroku to make it live, because heroku runs on linux this means that my document wont be created because im trying to generate it with docx.
I think it may be possible to use pandoc
. However I am have trouble implementing it.
below is the word document generation and pdf generation without trying to implement pandoc
. how can I implement pandoc with the code below:
import docx
def making_a_doc_function(request):
doc = docx.Document()
doc.add_heading("hello")
doc.save('thisisdoc.docx')
convert("thisisdoc.docx", "output.pdf")
pdf = open('output.pdf', 'rb')
response = FileResponse(pdf)
return response
pandoc documentation: https://pypi.org/project/pyandoc/
Upvotes: 0
Views: 290
Reputation: 1
Heroku itself does not prevent you from creating docx files using python-docx, the only issue is storing the output files to external storage (python-docx does not work with remote locations for neither upload nor saving). I needed to write custom processors to make it work with AWS S3.
Upvotes: 0