I am trying to generate a pdf report and show it in to the user in the browser.
The method i used to do this was to generate the report using docx
and then use docx2pdf
in order to convert the generated report into pdf format.
My code works perfectly when i host it locally on my machine. However when i try to toast it online via heroku i get the following error:
docx2pdf is not implemented for linux as it requires Microsoft Word to be installed
The weird thing is that i am not using a linux machine. I have tried both safari and google chrome browsers and i get the same result. I find it strange because when i host the site locally, the pdf gets generated and shown in the browser exactly the way i want it. but when i upload to heroku i get the error.
The code that deals with th e conversion is:
def making_a_doc_function(request):
doc = docx.Document()
doc.add_heading("no text")
doc.save('thisisdoc.docx')
#converting the generated docx into a pdf file
convert("thisisdoc.docx", "output.pdf")
pdf = open('output.pdf', 'rb')
response = FileResponse(pdf)
return response