Page margins and footer-spacing seem to have no effect on production. Page margins work on our staging environment. Staging environment is
very different. Dunno how to get the Linux version there -- but whatever
it is, it's very old and very crusty (like PHP still v5.4 etc. old).
Weird that it works on old crust and not shiny new? And we use Git so what is on staging is exactly what ends up on production.
Also worthy to note: I didn't install or configure wkhtmltopdf. A senior dev who actually knows server stuff did, they're gone now.
Questions:
- What are some potential reasons that both page margins and footer-spacing would not work when using wkhtmltopdf in a certain environment?
- Is there configuration in wkhtmltopdf that will prevent margins? How can I check said configuration? Again I did not configure this so maybe there is something really dumb that I can check real quick.
- Other suggested workarounds? Anything you can give me would be appreciated! I've tried most I can think of and I'm at about ~5 hours on a dang page margin, aha.
Versions:
- Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-112-generic x86_64)
- wkhtmltopdf 0.12.2.4
How we run wkhtmltopdf:
The user clicks on a link, which is the same URL but with ?print=pdf and ?attorney=name appended. That brings up a different HTML template. I can provide the HTML template being used if needed but I skipped it because I'd have to strip a lot of stuff out. wkhtmltopdf is run via:
if (isset($_GET['target']))
{
$atty = $_GET['attorney'];
$target = $_GET['target'];
$destFile = tempnam(sys_get_temp_dir(), 'client-') . '.pdf';
$cmd = exec(
'xvfb-run --server-args="-screen 0 1280x1024x24" /usr/bin/wkhtmltopdf --orientation Portrait --page-size Letter ' .
$target . ' ' . $destFile,
$out,
$result
);
$file = file_get_contents($destFile);
// set the pdf data as download content:
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . 'client-' . $atty . '.pdf"');
echo($file);
}
Troubleshooting:Thank you!