diff --git a/composer.json b/composer.json index a1aa717..673eeef 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "keywords": ["Laravel", "Invoice", "Invoices", "PDF"], "require": { "php": ">=8.2", - "barryvdh/laravel-dompdf": "^v2.0", + "barryvdh/laravel-dompdf": "^v3.0", "illuminate/http": "^10|^11", "illuminate/support": "^10|^11", "symfony/http-foundation": "^6|^7" diff --git a/config/invoices.php b/config/invoices.php index 9bdf1d6..16fb707 100644 --- a/config/invoices.php +++ b/config/invoices.php @@ -112,4 +112,8 @@ */ 'logOutputFile' => '/dev/null', ], + + 'security' => [ + 'encryption' => true, + ] ]; diff --git a/src/Invoice.php b/src/Invoice.php index 06b86b9..a506b84 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -8,6 +8,7 @@ use Illuminate\Http\Response; use Illuminate\Support\Collection; use Illuminate\Support\Facades\View; +use Illuminate\Support\Str; use LaravelDaily\Invoices\Classes\InvoiceItem; use LaravelDaily\Invoices\Classes\Party; use LaravelDaily\Invoices\Contracts\PartyContract; @@ -276,8 +277,13 @@ public function render() $this->pdf = PDF::setOptions($this->options) ->setPaper($this->paperOptions['size'], $this->paperOptions['orientation']) ->loadHtml($html); - $this->output = $this->pdf->output(); + if (config('invoices.security.encryption')) { + // By definition an invoice should not be changable by anyone, so use a random master password + $this->pdf->setEncryption('', Str::random(40), array('copy','print')); + } + + $this->output = $this->pdf->output(); return $this; }