Save PDF from webpage with Browsershot

91 Views Asked by At

I'm attempting to save one page on my Laravel website using Browsershot, but I consistently encounter the following error message. Why does my node always show a "Permission denied" error?

The command "PATH=$PATH:/usr/local/bin:/opt/homebrew/bin 
NODE_PATH=`/home/quanph/.nvm/versions/node/v18.19.0/bin/node 
/home/quanph/.nvm/versions/node/v18.19.0/bin/npm root -g` 
/home/quanph/.nvm/versions/node/v18.19.0/bin/node '/var/www/html/api-
service/vendor/spatie/browsershot/src/../bin/browser.cjs' '{"url":"file:\/\/\/tmp\/1184929759-
0777396001705702182\/index.html","action":"pdf","options":{"path":"invoice.pdf","args":
[],"viewport":{"width":800,"height":600},"displayHeaderFooter":false,"format":"a4","printBackground":true}}'" 
failed. Exit Code: 126(Invoked command cannot execute) Working directory: /var/www/html/api-
service/public Output: ================ Error Output: ================ sh: 1: 
/home/quanph/.nvm/versions/node/v18.19.0/bin/node: Permission denied sh: 1: 
/home/quanph/.nvm/versions/node/v18.19.0/bin/node: Permission denied

This is my example code

Route::get('/test', function () {
    \Spatie\Browsershot\Browsershot::url('http://api.imta.edu/')
        ->setIncludePath('/home/quanph/.nvm/versions/node/v18.19.0/bin')
        ->save('invoice.pdf');
});
0

There are 0 best solutions below