I have a PHP application that saves a webpage as a pdf file by wrapping some headless Chrome directives into a command line statement, and then running that with shell_exec().
$chrome = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
$location = "C:\\xampp\\htdocs\\myfolder\\files\\d-{$dispatch_id}.pdf";
$dispatch = site_url("dispatch/print_dispatch/{$dispatch_id}");
$params = '--headless --disable-gpu --print-to-pdf="$location"';
$command = '"'.$chrome.'"';
$command .= " --headless --disable-gpu --print-to-pdf=";
$command .= '"'.$location.'"';
$command .= ' "'.$dispatch.'"';
$output = shell_exec($command);
// echo $command returns:
//"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --headless --disable-gpu --print-to-pdf="C:\xampp\htdocs\myfolder\files\d-71.pdf" "http://website.com/dispatch/print_dispatch/71"
This works fine for me and does exactly what I need. However, the pdf file that is generated has the date and time in the header and footer, and the page url in the footer as well. I have tried using the --no-margins option to remove this superfluous text, but that didn't work, and my Goggle-Fu has failed me. Is there a way to remove the timestamp and url from a pdf created with Headless Chrome?
I have reviwed the following similar questions but have yet to find an answer: