You can set the default options for every PDF, by using the default
method on the Pdf
facade.
Typically, you would do this in the boot
method of a service provider.
use Spatie\LaravelPdf\Facades\Pdf;
use Spatie\LaravelPdf\Enums\Format;
Pdf::default()
->headerView('pdf.header')
->paperFormat(Format::A3);
With this code, every PDF generated in your app will have the pdf.header
view as header and will be rendered in A3 format.
Of course, you can still override these defaults when generating a PDF.
Pdf::html('<h1>Hello world</h1>')
->save('my-a3-pdf.pdf')
Pdf::html('<h1>Hello world</h1>')
->paperFormat(PaperFormat::A4)
->save('my-a4-pdf.pdf')