Open thewruck opened 2 weeks ago
Same issue here.
I stumbled on a 'fix', but i still do not know what is the proper way to deal with this.
Down in the <project_path>/vendor/spatie/browsershot/src
is Browsershot.php
. It contains a bunch of properties. I just set $noSandbox
to true. I am sure that there is a better way to pass this in, but I did not see it in any of the documentation.
class Browsershot
{
...
protected string $html = '';
protected bool $noSandbox = true;
protected string $proxyServer = '';
...
What the hell, did you modify the vendor?
@thewruck Here is the documentation that describes how to customize the Browsershot instance: https://spatie.be/docs/laravel-pdf/v1/advanced-usage/customizing-browsershot
In your case, to disable the sandbox:
return Pdf::view('reports.attendance_sheets', ['course_instances' => $course_instances])
->format('letter')
->withBrowsershot(function (Browsershot $browsershot) {
$browsershot->noSandbox();
})
->name('attendance-sheets.pdf');
What happened?
I am new to laravel and laravel-pdf. Working on saving my first PDF, but got hit with this error. But this seems to be a security feature into Ubuntu 24.04 and not a bug. I am seeing many ways to just turn AppArmor off, but I am looking for instructions on how to correctly give permissions for the AppArmor to stay on, but allowances made for laravel-pdf to run. Seems like the documentation needs to be updated as I am sure to be the first of many who get hit with this "feature"
How to reproduce the bug
Running this code...
...generates this error
Package Version
1.5.2
PHP Version
8.2.23
Laravel Version
11.31
Which operating systems does with happen with?
Linux
Notes
No response