Unable to write to destination on Linux — tmp dir should be a file
vinyll opened this issue · comments
When running the following:
async def show(request, response):
response.body = await pydf.AsyncPydf().generate_pdf(
my_html, print_media_type=True
)
it works well on MacOSX, but getting the following error on Linux:
Loading pages (1/6)
QPainter::begin(): Returned false============================] 100%
Error: Unable to write to destination
Exit with code 1, due to unknown error.
Note that this is probably due to the following difference of behavior:
wkhtmltopdf http://google.com /tmp/pydf_cache
works well on MacOSX and returns the arror above on Linux.
To solve this with wkhtmltopdf:
wkhtmltopdf http://google.com /tmp/pydf_cache/myfile
I suppose that pydf
should create a temporary file instead of writing to the tmp folder for cross platform.
Is there any option I missed?
works fine for us on linux, both inside and outside docker, but happy to accept a PR to fix this for you.
Thanks for replying so promptly!
Investigation so far.
It seems like the error is linked with wkhtmltopdf itself and the system.
A freshly installed Ubuntu 18.10 with just the install of the latest wkhtmltopdf throws the following:
root@ubuntu-1810:~# mkdir /tmp/py_cache
root@ubuntu-1810:~# wkhtmltopdf https://google.com /tmp/py_cache
Loading pages (1/6)
QPainter::begin(): Returned false============================] 100%
Error: Unable to write to destination
Exit with code 1, due to unknown error.
While the same command works on another CentOS server.
I noticed that the version I have does not offer the --cache-dir
option in the help section though.
Issue on wkhtmltopdf is related to this issue here.
I'm wondering how portable pydf is aimed to be beyond Docker and Heroku though
--cache-dir
should be possible, like all options.
This looks like an issue with wkhtmltopdf, flexibility is really limited to that.
You can however your own wkhtmltopdf binary if that helps.
same problem. @vinyll did u find any solution?