I'm using WKHTMLTOPDF to generate PDFs. It's been working fine but we've recently changed server and it's now only giving us back 0 byte files from our PHP admin panel.
Strangely, if I run the below from ssh, it generates just fine. I guess it's perhaps an issue with permissions of www-data but I can't figure it out :(
WKHTMLTOPDF is at /usr/local/bin/wkhmtltopdf and we're using httpd and centos.
If more info is needed I'm happy to try provide it. I can't seem to find any log for wkhtmltopdf either, it doesn't go into the httpd log.
Appreciate the help! Pulling my hair out :p
EDIT: here's the code I'm using to generate the PDF - it has worked on the old server
PDF::setOutputMode('F'); // force to file
PDF::setPageSize('a0');
$gen = PDF::html('pdf.print.web', [
'products' => $catalogue,
'name' => $master->name
], storage_path()."/pdf/gen-".$master->url);
return Response::download(storage_path()."/pdf/gen-".$master->url.'.pdf');
A had a similar issue using wkhtmltopdf CLI (not PHP). It ended up being a permission issue.
When I did:
wkhtmltopdf http://google.com google.pdf
The operation would succeed but generate a 0-byte pdf. No errors thrown.
When I did:
sudo wkhtmltopdf http://google.com google.pdf
The pdf has content. So ensure the relevant user(s) have r/w/e permission to the command itself and to the location where you want to write the file. Also make sure they have permission to make the outbound web request if relevant, and the server is config'd to allow this. You won't actually have to sudo once the permissions are fixed.
Hope this helps.