https://github.com/spatie/browsershot
npm install puppeteer --global
composer require spatie/browsershot
use Spatie\Browsershot\Browsershot;
Browsershot::url('https://www.google.com/?hl=ja')
->setOption('args', ['--no-sandbox','--disable-web-security'])
->save('./test.pdf');
$file = file_get_contents( public_path('./test.pdf') );
return response($file, 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline; filename="' . './test.pdf' . '"');
use Spatie\Browsershot\Browsershot;
$html = "<h1>TEST</h1>";
Browsershot::html( $html )
->setOption('args', ['--no-sandbox','--disable-web-security'])
->save('./test.pdf');
$file = file_get_contents( public_path('./test.pdf') );
return response($file, 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline; filename="' . './test.pdf' . '"');