Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions config/invoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@
*/
'logOutputFile' => '/dev/null',
],

'security' => [
'encryption' => true,
]
];
8 changes: 7 additions & 1 deletion src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down