Replies: 1 comment
-
I strongly suggest different solutions: First use Browsershot as headlessAdd headless option from browsershot: ->withBrowsershot(function (Browsershot $browsershot) {
$browsershot->newHeadless();
}) Your code should look like this: $pdf = Browsershot::html($html)
->format('A4')
->waitUntilNetworkIdle()
->timeout(120)
->withBrowsershot(function (Browsershot $browsershot) {
$browsershot->newHeadless();
})
->save($output_path); Second approach Operate Browsershot without sandboxingUsing ->withBrowsershot(function (Browsershot $browsershot) {
// Ensure Browsershot works without node command recognition issues
$browsershot->noNodeInstallation()->noSandbox()->scale(0.5);
}) Note: This solution is particularly effective on Windows where sandboxing configurations may differ from Unix-based systems. 3 Adding custom paths for every environmentProbably running something like this would work: $pdf = Browsershot::html($html)
->format('A4')
->waitUntilNetworkIdle()
->timeout(120)
->save($output_path);
if (app()->isLocal()) {
return $pdf->setNodeBinary('C:\Program Files\nodejs\node.exe')
->setNpmBinary('C:\Program Files\nodejs\npm.cmd')
->setChromePath('C:\Program Files\Google\Chrome\Application\chrome.exe');
}
return $pdf->setNodeBinary('path-in-your-server-to/node.exe')
->setNpmBinary('/path-in-your-server-to/npm.cmd')
->setChromePath('path-in-your-server-to/chrome.exe'); Please let me know if some of this solution works and what is the solution that works for you (if works 😄 ). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
In live server I can't generating my pdf without follwing paths that I've described bleow and I've also installed browsershot version ( 4.1.1 ) .
$pdf = Browsershot::html($html)
->format('A4')
->waitUntilNetworkIdle()
->setNodeBinary('C:\Program Files\nodejs\node.exe')
->setNpmBinary('C:\Program Files\nodejs\npm.cmd')
->setChromePath('C:\Program Files\Google\Chrome\Application\chrome.exe')
->timeout(120)
->save($output_path);
How to reproduce the bug
it's woks on locally but when I live the project it's not working because locally I've set location of follwing path
->setNodeBinary('C:\Program Files\nodejs\node.exe')
->setNpmBinary('C:\Program Files\nodejs\npm.cmd')
->setChromePath('C:\Program Files\Google\Chrome\Application\chrome.exe') but In live I couldn't
Package Version
1.5.1
PHP Version
8.2.12
Laravel Version
11
Which operating systems does with happen with?
No response
Notes
No response
Beta Was this translation helpful? Give feedback.
All reactions