0
votes

I have a Python Flask project that uses the pdfkit module (and by extension wkhtmltopdf) to convert a locally stored HTML file into a .pdf file.

I have the whole thing working perfectly when it is hosted locally on my windows computer.

However after uploading my project folder to a Heroku instance and testing it - I received two errors (one of which I solved) when running through the program.

Note that I included wkhtmltopdf into my build pack before creating the Heroku instance with the following commands in Git (These were taken from Method 2 in: https://razorjack.net/wkhtmltopdf-on-heroku-evaluating-different-installation-options/):

I'll display them here as well:

heroku buildpacks:add https://github.com/dscout/wkhtmltopdf-buildpack.git heroku config:set WKHTMLTOPDF_VERSION="0.12.4"

The first error that I solved involved pdfkit not being able to find the wkhtmltopdf binary in the Herkou instance. I eventually found it placed in the bin folder of my project - I added this to the pdfkit configuration path in my python file.

The problem that I'm now having is that the wkhtmltopdf/ pdfkit says it has created the .pdf file (I can see this from the output of the log tail on Git) but when I check the directory in the project folder on Heroku using the Heroku Terminal the .pdf doesn't appear to exist.

Interestingly when I try to 'touch' or create a new file in the /app folder in the instance nothing appears. But when I do the same in the /tmp folder it does. I have tried to point the wkhtmltopdf file.pdf creation to the /tmp folder but once again nothing appears to have been created.

If anybody could give me any helpful insight or a solution to why I might be having this problem I would be very grateful.

Thanks.

1

1 Answers

0
votes

The problems you are facing may be caused by Heroku's ephemeral file system. Maybe this page of docs will help you find the solution.