Issue
Today I tried deploying a webapp on a debian apache 2 server and wasted half a day trying to get pdfkit to work.
The app is suposed to render a standard html template using jinja2 and then turn that rendered template into a pdf file the end user is suposed to download. The entire functionality works fine on Win10 but when I try to do this on the server pdfkit refuses to work and simply returns OS Error: Command failed.
. The worst part is I can't check wkhtmltopdf output regardless of whether i add the --quiet flag or not. Pdfkit just keeps suggesting removing that flag regardless of if that flag is there.
Here's the python code:
html = template.render(args) #this returns a template the win10 version can understand just fine
#save the rendered html string into a pdf file
options = {
'encoding': "UTF-8"
}
name = 'podsumowania/order' + ID + '.pdf'
#config = pdfkit.configuration(wkhtmltopdf='/usr/bin/wkhtmltopdf')
pdfkit.from_string(html, name, options=options) #error happens here
and yes i tried locating the wkhtmltopdf executable. Displays the help message just fine.
There must be something I missed but I'm at a loss. Please help
Solution
I fixed the issue by installing wkhtmltox instead of wkhtmltopdf that turns out to be limited. They work the same way and I ain't got a clue as to why is there a limited version of wkhtmltopdf even out there. Installing wkhtmltox either fixed an additional issue or simply gave feedback that led me to fixing the real issue(which was a simple permission conflict). Either way just install wkhtmltox when working on linux to save yourself the headache.
Answered By - TCA 166 Answer Checked By - Mildred Charles (WPSolving Admin)