Not working: Running php $pdf = new ChromePdf($pathToChrome);, opens a chrome browser
Closed this issue · 4 comments
XAMPP, php 8.1, windows 11, Google Chome v120.
$pathToChrome = 'C:\Program Files\Google\Chrome\Application\chrome.exe';
$pdf = new ChromePdf($pathToChrome);
When calling this via ajax from browser js, opens a new chrome browser window.
Hi, at this moment I'm using https://github.com/spatie/browsershot
I recommend to use it instead of my package. They have a good support and regular updates.
Unfortunately I don't really want to add node.js to the stack for this one library..
Per docs at spatie browsershot:
If you're not able to install Node and Puppeteer, take a look at v2 of browsershot, which uses Chrome headless CLI to take a screenshot. v2 is not maintained anymore, but should work pretty well.
Cheers
I don't really want to add node.js
Ohhh, I understand. In that case, feel free to fork this repo and use the code. It seems that Chrome has a new headless mode, so maybe there are new command flags https://developer.chrome.com/docs/chromium/new-headless?hl=en
Cool, is it just the one file, at the following line:
$command = sprintf(
'%s --no-sandbox --headless --disable-gpu --print-to-pdf=%s %s 2>&1',
escapeshellarg($this->binary),
escapeshellarg($this->output),
escapeshellarg($url)
);