LaravelDaily / laravel-invoices

Laravel package to generate PDF invoices from various customizable parameters
GNU General Public License v3.0
1.39k stars 303 forks source link

DomPDF options are not aplied #186

Closed krls2020 closed 1 year ago

krls2020 commented 1 year ago

Hi, there is a misconfiguration in the config key. Please remove square brackets otherwise a 'dompdf_options' from config/invoices.php are not applied.

https://github.com/LaravelDaily/laravel-invoices/blob/fef6f5386c6f2e67d08e248a3b7dd787322344b8/src/Invoice.php#L201

huanes commented 1 year ago

As this package is using barryvdh/laravel-dompdf package, I'd also propose setting the options in this class as following

$this->options = array_merge(config('invoices.dompdf_options') ?? ['enable_php' => true], app('dompdf.options')); 

The app('dompdf.options') is binded in the package of Barryvdh at \Barryvdh\DomPDF\ServiceProvider::register and basically resolves to config('dompdf.options'), which includes all the default values that are defined for the package and used when resolving app('dompdf.wrapper') via the PDF facade.

Currently this package is using the facade, but instantly overrides all the default values that are set, such as font_dir etc.

mc0de commented 1 year ago

@huanes good point, i think i would prefer overriding default dompdf options instead of overriding with default options using array merge

$this->options = array_merge(app('dompdf.options'), config('invoices.dompdf_options') ?? ['enable_php' => true]);