Skip to content

Instantly share code, notes, and snippets.

@flayder
Created December 24, 2020 11:31
Show Gist options
  • Save flayder/8821201b3f02da20fa823e46bb842c90 to your computer and use it in GitHub Desktop.
Save flayder/8821201b3f02da20fa823e46bb842c90 to your computer and use it in GitHub Desktop.
$pdf_path = $_SERVER['DOCUMENT_ROOT'] . "/policies/{$number}.pdf";
$url = 'https://my.inapp.insure/certgen?policy='.$policy.'&number='.$number.'&address='.$address.'&policyholder='.$policyholder.'&phone='.$phone.'&email='.$email.'&date_of_birth='.$date_of_birth.'&validity='.$validity.'&cost='.$cost.'&comes_into_force='.$comes_into_force.'&valid_until='.$valid_until;
if (!file_exists($pdf_path)) {
$command = 'google-chrome --no-sandbox --headless --disable-gpu --print-to-pdf="' . $pdf_path . '" "'.$url.'"';
exec($command);
}
//return [$pdf_path, $url];
$content = file_get_contents($pdf_path);
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename='{$number}.pdf'");
readfile($_SERVER['DOCUMENT_ROOT'] . "/policies/{$number}.pdf");
unlink($pdf_path);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment